Devo creare un doppio indice per il mio documento, uno in italiano ed uno in inglese. Avendo scritto tutto in inglese il comando \listofcontents mi crea correttamente l’indice in questa lingua. Ora vorrei creare un indice in italiano ma usando non i titoli originali dei capitoli, delle sezioni, … ma le rispettive traduzioni che potrei mettere come titolo secondario. Come posso fare?
Posso anche cambiare la parola “Contents” dell’indice in inglese con “Index”?
Grazie mille per le risposte.
Copiati il codice seguente in un file che chiamerai dbltoc.sty (da tenere insieme al tuo documento principale):
`\ProvidesPackage{dbltoc}
\newif\if@uniquetoc
\DeclareOption{unique}{\@uniquetoctrue}
\ProcessOptions\relax
\RequirePackage{shorttoc}
\def\secondary@title#1#2{%
\@namedef{secondary#1}##1{%
\addcontentsline{toc}{secondary#1}{%
\ifnum\c@secnumdepth>#2\relax
\protect\numberline{\csname the#1\endcsname}%
\fi
##1}}%
}
\secondary@title{chapter}{-1}
\secondary@title{section}{0}
\secondary@title{subsection}{1}
\secondary@title{subsubsection}{2}
\secondary@title{paragraph}{3}
\secondary@title{subparagraph}{4}
\def\secondaryl@#1{%
\expandafter\let\csname l@secondary#1\expandafter\endcsname
\csname l@#1\endcsname}
\secondaryl@{chapter}
\secondaryl@{section}
\secondaryl@{subsection}
\secondaryl@{subsubsection}
\secondaryl@{paragraph}
\secondaryl@{subparagraph}
\let\@@tableofcontents\tableofcontents
\def\tableofcontents{%
\begingroup
\disable@secondary
\if@uniquetoc
\@@tableofcontents
\else
\shorttoc{\contentsname}{\value{tocdepth}}%
\fi
\endgroup}
\def\secondarytableofcontents{%
\if@uniquetoc\else
\begingroup
\let\contentsname\secondarycontentsname
\disable@primary\@@tableofcontents
\endgroup
\fi}
\def\disable@secondary{%
\let\l@secondarychapter\@gobbletwo
\let\l@secondarysection\@gobbletwo
\let\l@secondarysubsection\@gobbletwo
\let\l@secondarysubsubsection\@gobbletwo
\let\l@secondaryparagraph\@gobbletwo
\let\l@secondarysubparagraph\@gobbletwo}
\def\disable@primary{%
\let\l@chapter\@gobbletwo
\let\l@section\@gobbletwo
\let\l@subsection\@gobbletwo
\let\l@subsubsection\@gobbletwo
\let\l@paragraph\@gobbletwo
\let\l@subparagraph\@gobbletwo}
\endinput`
La struttura del tuo file sarà
`\documentclass[a4paper]{book}
…
\usepackage{dbltoc}
\newcommand{\secondarycontentsname}{Indice}
…
\begin{document}
\frontmatter
…
\tableofcontents
\secondarytableofcontents
…
\mainmatter
\chapter{Here comes the fun}
\secondarychapter{Adesso ci divertiamo}
\section{A nice journey}
\secondarysection{Un bel viaggio}
…
\end{document}`
Se da qualche parte usi \addcontentsline{toc}{chapter}{English text}, aggiungici subito dopo \addcontentsline{toc}{secondarychapter}{Testo in italiano}
Con \usepackage[unique]{dbltoc} la produzione dell’indice supplementare è soppressa e il comando \secondarytableofcontents non fa nulla.
Non ti dico come cambiare “Contents” in “Index” perché “index” in inglese non ha nulla a che vedere con l’indice generale.
Ciao
Enrico
NOTA: modificato il file dbltoc.sty rispetto alla prima versione’; corretto anche un errore di stampa.