- Questo topic ha 13 risposte, 2 partecipanti ed è stato aggiornato l'ultima volta 14 anni, 8 mesi fa da .
-
Topic
-
Voglio definire un comando \ac (senza caricare il pacchetto acronym) che in generale equivalga a \textsmaller, ma che si annulli all’interno di titoli o altra roba che viene forzata a essere in maiuscolo o minuscolo mediante \MakeTextUpperCase o \MakeTextLowerCase. Ho pensato di fare il controllo su \NoCaseChange:
`\documentclass{report}\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{textcase,relsize,titlesec}\makeatletter
\titleformat{\chapter}[hang]
{\normalfont\Large\sffamily}
{\normalfont\Large\scshape\sffamily\thechapter}
{\marginparsep}{\scshape\MakeTextUppercase}
\titleformat{\section}[hang]
{\normalfont\Large\sffamily}
{\normalfont\Large\scshape\sffamily\thesection}
{\marginparsep}{\scshape\MakeTextLowercase}
\let\old@l@chapter\l@chapter
\renewcommand\l@chapter[2]{\old@l@chapter{\scshape\MakeTextUppercase{#1}}{#2}}
\let\old@l@section\l@section
\renewcommand\l@section[2]{\old@l@section{\scshape\MakeTextLowercase{#1}}{#2}}\newcommand\ac{%
\ifx\NoCaseChange\@firstofone
\expandafter\textsmaller
\else
\expandafter\@firstofone
\fi}
\makeatother\begin{document}
\tableofcontents
\chapter{Logica \ac{BAN}}
Questo capitolo presenta la logica \ac{BAN}…
\section{Particolarità \ac{BAN}}
Questo paragrafo…
\end{document}`Ora, se uso \newcommand, allora il comando \ac viene espanso nei file ausiliari e questo non va bene perché così \NoCaseChange risulta sempre \@firstofone. Il risultato è che gli acronimi compaiono in corpo minore nel testo normale (giusto) e nell’indice (sbagliato) ma non nei titoli (giusto).
Se uso \DeclareRobustCommand, allora \ac non viene espanso nei file ausiliari, però così esce fuori in corpo minore sia nell’indice che nei titoli. Perché succede questo? Come risolvere?
Grazie,
Antonio
- Devi essere connesso per rispondere a questo topic.