Re: [RISOLTO] Extend Captions

#23729
Up
0
Down
::

Il problema era proprio quello, grazie!
Ora ho scritto
`\makeatletter
\newcommand*\ExtendCaptionsM[3]
{ { \@ifundefined{captions#1}
{ \PackageWarning{prova}%
{ Language option #1 not specified
\MessageBreak
Skipping any redefinition
\MessageBreak
}
}
{ \expandafter\let\expandafter\@tempA
\csname captions#1\endcsname
\expandafter\let\expandafter\@tempB
\csname #2name\endcsname
\toks0=\expandafter{\@tempA
\def\@tempB{#3}}
\expandafter\xdef
\csname captions#1\endcsname{\the\toks0}
}
}
}
\makeatother`
In modo da usarlo come
`\ExtendCaptionsM{italian}{preface}{NuovaPrefazione}`
ma non funziona… anche se non dà errori!
Siccome so già di aver fatto qualche stupidata, qualcuno sa aiutarmi?

Stai aggiungendo a \captionsitalian i token
`\def\@tempB{NuovaPrefazione}`
che non è proprio utilissimo. Immagino che tu voglia una cosa del genere:

primo argomento = lingua
secondo argomento = comando che contenga la “fixed tag”
terzo argomento = la fixed tag nella lingua

Il secondo argomento dovrebbe essere proprio un comando: quindi meglio una sintassi come
`\ExtendCaptionsM{italian}{\newprefacename}{Nuova Prefazione}`
e la parte rilevante del codice (cioè il terzo argomento di \@ifundefined) diventa
`\expandafter\let\expandafter\@tempA\csname captions#1\endcsname
\toks0=\expandafter{\@tempA\def#2{#3}}
\expandafter\xdef\csname captions#1\endcsname{\the\toks0 }`
In realtà non ci sarebbe bisogno di \@tempA, con un trucco più bieco.
`\toks0=\expandafter\expandafter\expandafter{%
\csname captions#1\endcsname\def#2{#3}}
\expandafter\xdef\csname captions#1\endcsname{\the\toks0 }`
Il primo \expandafter espande il terzo che espande \csname producendo il token \captionsitalian (se il primo argomento è italian); rimane il secondo che a questo punto espande \captionsitalian, come desiderato.

Ciao
Enrico

Go to top