Re: TOC and Appendices: problem redefining \l@section



On 28/2/08 8:13 AM, in article ce9.47c65efd.847de@xxxxxxxxxxx, "Ulrich M.
Schwarz" <brotherelf@xxxxxxx> wrote:

On Wed, 27 Feb 2008 21:42:43 +0100, Luci Ellis wrote:
[...]
In principle, it should be possible to redefine \l@section within the
redefinition of \appendix, like this: \def\l@section#1#2{
\setlength{\parskip}{6pt}\selectfont%
\@dottedtocline{1}{0cm}{\myLabelWidth}{\appendixname~#1}{#2}}

But whenever I try this or the Latex-style "\renewcommand" equivalent, I
get an error message like this:
?
! Illegal parameter number in definition of \resetAppTOC.

So you're redefining \l@section within another macro. The thing to
remember here is that #1 is a parameter of the outermost macro, ##1 is
the parameter of the next-inner macro, ####1 one level deeper yet and so
on. So, TeX is getting confused because it wants to replace the #1 in
\l@section#1 with the first parameter to \resetAppTOC, which doesn't have
any. Replacing with ##1 and ##2 should fix that.

HTH
Ulrich

Dear Ulrich,
Thank you, this was helpful in that it removed the error (the #1 ##1
distinction was something I never understood before). Unfortunately it
doesn't actually redefine the TOC entry. I thought I needed to put the
redefinition of \l@section inside an \addtocontents but when I try that, it
falls over completely and the TOC entries all bunch together without any
spacing at all.

Similarly, if I define the \l@section originally as
\newcommand{\startsectoc}{}
\renewcommand{\@dotsep}{0.7}
\newlength{\myLabelWidth}
\setlength{\myLabelWidth}{1cm}%
\renewcommand*\l@section[2]{
\setlength{\parskip}{6pt}\selectfont%
\@dottedtocline{1}{0cm}{\myLabelWidth}{\startsectoc #1}{#2}}

And then try to redefine \startsectoc inside the redefinition of \appendix,
nothing happens if I don't put it inside \addtocontents{toc}, and errors
happen if I do.

Using \addtocontents seems to be necessary for any change to the TOC that
the Appendices require. My class file also has the following line in the
redefinition of \appendix, to make room for the word "Appendix", if only I
could make it show.
\addtocontents{toc}{\addtolength{\myLabelWidth}{1.2cm}}

But actually changing the TOC label to "Appendix A" _without_ also changing
\thesection seems infeasible. If I could tell people to change their text to
remove the "Appendix" text before cross-references in the text, none of this
would matter. But they're not going to write "Section~\ref{sec.this}" but
only "\ref{app.that}".

Best regards,
Luci

.



Relevant Pages

  • Re: A question about ifndef
    ... > Some compilers allow redefinition of macros with identical replacement ... An identifier currently defined as an object-like macro shall ... p1 gives a definition for replacement lists being identical. ...
    (comp.lang.c)
  • Re: TOC and Appendices: problem redefining l@section
    ... But whenever I try this or the Latex-style "\renewcommand" equivalent, ... get an error message like this: ... So you're redefining \l@section within another macro. ...
    (comp.text.tex)
  • Re: Macrology and automated invocation of defclass?
    ... |> way that there is an underlying functional abstraction to which the ... |> macro expands which is also part of the official API. ... (cond ((funcall test-fun) ... the same redefinition problem as macros. ...
    (comp.lang.lisp)
  • chapter capitalization in the TOC
    ... I'm trying to make chapter entries in upper case in the TOC. ... A redefinition of \l@chapterlike ... (TOC, headings, heads), I've tried this other solution ... I also had no better luck with the commands provided by the tocloft ...
    (comp.text.tex)
  • BOOKMARK redefinition
    ... The error message is given below. ... error C2371: 'BOOKMARK': redefinition; different basic types ...
    (microsoft.public.vc.database)