Problema nel comporre una Table Of Contents personalizzata

  • Questo topic ha 2 risposte, 2 partecipanti ed è stato aggiornato l'ultima volta 21 anni fa da Gus.
  • Creatore
    Topic
  • #4043
    Up
    0
    Down
    ::


    Salve a tutti.
    Sto cercando di ottenere una table of contents personalizzata, sulla falsariga dell’esempio riportato a pag. 36 del `LaTeX Companion’
    Per vedere come funziona, ho utilizzato esattamente l’esempio del testo e cioè:

    \newcommand{listofexamples}{\@starttoc{xmp}}
    \newcommand{\ecaption}[1]{\addcontentsline{xmp}{example}{#1}}
    \newcommand{\l@example}[2]{\par\noindent#1 {\itshape #2}}

    Il problema è che durante la compilazione il mio LaTeX (versione 2001/06/01 in SuSE Linux 8.2) sembra non gradire affatto la presenza del carattere `@’ all’interno dei comandi, come si può vedere dall’estratto del log che ho riportato sotto. Se ho ben capito (ma ne dubito..) , per il comando \@starttoc{xmp} il programma è convinto che io abbia voluto passare al modo matematico e che poi mi sia dimenticato di chiuderlo, mentre per \l@example legge il comando solo prima del `@’, dicendomi infatti che il comando \l è già stato definito.

    Vi sto chiedendo una banalità allucinante (nel qual caso chiedo umilmente scusa) oppure c’è effettivamente qualcosa che non va?

    Vi ringrazio anticipatamente.

    Questa è la parte di log che riguarda \l@example

    ! LaTeX Error: Command \l already defined.
    Or name \end… illegal, see p.192 of the manual.

    See the LaTeX manual or LaTeX Companion for explanation.
    Type H for immediate help.

    l.24 …example}[2]{\par\noindent#1 {\itshape #2}}

    Your command was ignored.
    Type I to replace it with another command,
    or
    to continue without it.

    ! Missing number, treated as zero.

    e
    l.24 …example}[2]{\par\noindent#1 {\itshape #2}}

    A number should have been here; I inserted `0′.
    (If you can’t figure out why I needed to see a number,
    look up `weird error’ in the index to The TeXbook.)

    ! You already have nine parameters.
    \reserved@a …def \expandafter \l \reserved@b #10
    e{
    l.24 …example}[2]{\par\noindent#1 {\itshape #2}}

    I’m going to ignore the # sign you just used.

    ! You can’t use `macro parameter character #’ in horizontal mode.
    ##

    l.24 …example}[2]{\par\noindent#1 {\itshape #2}}

    Sorry, but I’m not programmed to handle this case;
    I’ll just pretend that you didn’t ask for it.
    If you’re in the wrong mode, you might be able to
    return to the right one by typing `I}’ or `I$’ or `I\par’.

    ! You can’t use `macro parameter character #’ in horizontal mode.
    \par \noindent ##1 {\itshape ##
    2}
    l.24 …example}[2]{\par\noindent#1 {\itshape #2}}

    Sorry, but I’m not programmed to handle this case;
    I’ll just pretend that you didn’t ask for it.
    If you’re in the wrong mode, you might be able to
    return to the right one by typing `I}’ or `I$’ or `I\par’.

    Questa è la parte di log che riguarda \@strttoc{xmp}

    ! You can’t use `\spacefactor’ in vertical mode.
    \@->\spacefactor
    \@m
    l.396 \listofexamples

    Sorry, but I’m not programmed to handle this case;
    I’ll just pretend that you didn’t ask for it.
    If you’re in the wrong mode, you might be able to
    return to the right one by typing `I}’ or `I$’ or `I\par’.

    ! Missing $ inserted.

    $
    l.396 \listofexamples

    I’ve inserted a begin-math/end-math symbol since I think
    you left one out. Proceed, with fingers crossed.

    ! Missing $ inserted.

    $
    l.397 \listoffigures

    I’ve inserted a begin-math/end-math symbol since I think
    you left one out. Proceed, with fingers crossed.

Visualizzazione 1 filone di risposte
  • Autore
    Risposte
    • #4044
      Up
      0
      Down
      ::

      Salve a tutti.
      Sto cercando di ottenere una table of contents personalizzata, sulla falsariga dell’esempio riportato a pag. 36 del `LaTeX Companion’
      Per vedere come funziona, ho utilizzato esattamente l’esempio del testo e cioè:

      \newcommand{listofexamples}{\@starttoc{xmp}}
      \newcommand{\ecaption}[1]{\addcontentsline{xmp}{example}{#1}}
      \newcommand{\l@example}[2]{\par\noindent#1 {\itshape #2}}

      Taglio tutto il resto perché la risposta è semplice:`\makeatletter
      … % tutte le tue definizioni
      \makeatother`Il Companion specifica per bene questa faccenda, ma in modo non del tutto chiaro, almeno le prime volte che lo si guarda.
      Ciao
      Enrico

      Grazie mille! Effettivamente era una cosa banale, ma se non me la segnalavi non so quanto tempo ci avrei messo a scovarla…

    • #4045
      Gus
        Up
        0
        Down
        ::


        Ciao a tutti,

        continuo questa discussione perchè il titolo è adatto a quel che sto facendo. Per una serie di motivi non posso usare i pacchetti tocloft, minitoc e la classe memoir, quindi sto personalizzando a mano la \tableofcontents.

        Lo scopo è avere una (strana) \tableofcontents senza numeri di pagina, con solo le sezioni (in un article) e i numeri di sezione in grassetto. Alla fine, aggiustando qualche altro parametro ho risolto un po’ “sporcamente” così:
        `\renewcommand{\section}[1]{
        \refstepcounter{section}
        \begin{center}\normalfont\normalsize{\bfseries\thesection. #1}
        \addcontentsline{toc}{subsection}{\protect\noindent{\bfseries\thesection.} #1\hspace{2\textwidth}}\end{center}}`

        e mi va bene per le esigenze attuali. Quello che vorrei sapre da un vero TeXnico è perchè se nel secondo argomento di \addcontentsline metto, come sarebbe naturale, “section” invece che “subsection” mi si inchioda su un errore del tipo “maybe a missing \item” come se non volesse nulla nell’argomento di \contentsline (nel file toc).

        Spero di essermi spiegato, grazie e ciao,

        Gus

    Visualizzazione 1 filone di risposte
    • Devi essere connesso per rispondere a questo topic.

    Go to top