5

I'm currently writing a report where all of my titles are in French and hence my table of contents is also in French. I however need to also include a contents table in English and I was wondering if there was any way of adding in a section title in the other language to automatically produce an additional contents page?

For example is I wanted to use these two titles for one single section...

\section{Méthodes et matériaux}
\section{Methods and materials}

I know it might not be something that's often done but if anyone has any suggestions it would be fantastic. If you need me to provide any other information, please don't hesitate to ask.

  • Do I understand this correctly in that the text "Methods and material" in this English ToC is only found in the ToC? There is no extra header with that text in the section itself or anywhere else? – pst Apr 11 '14 at 9:59
  • In this case it is ONLY the French title that is in the report and therefore ToC at the moment. I would like to know if it is possible to add the English title within the document and hence make a second ToC in English as well as the French one. – user18056 Apr 11 '14 at 13:54
5

Replicate what \tableofcontents does. For defining the English titles you have to type them just below the French one, with the macro \addtoetoc

\documentclass[a4paper]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,french]{babel}

\makeatletter
\newcommand\englishtableofcontents{%
  \if@twocolumn
    \@restonecoltrue\onecolumn
  \else
    \@restonecolfalse
  \fi
  \begin{otherlanguage}{english}
  \chapter*{%
    \contentsname
    \@mkboth{\MakeUppercase\contentsname}
            {\MakeUppercase\contentsname}%
  }%
  \@starttoc{tec}%
  \end{otherlanguage}
  \if@restonecol\twocolumn\fi
}
\newcommand{\addetoc}[2]{%
  \addcontentsline{tec}{#1}{\protect\numberline{\csname the#1\endcsname}#2}%
}
\makeatother

\begin{document}
\frontmatter
\tableofcontents
\englishtableofcontents

\mainmatter
\chapter{Introduction}
\addetoc{chapter}{Introduction}

\section{Méthodes et matériaux}
\addetoc{section}{Methods and materials}

\end{document}

Here is page i from the example:

enter image description here

and here is page iii:

enter image description here


Here's a complete version for the article class, where we can exploit the fact that the list commands are defined in a very similar way:

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,french]{babel}

\usepackage{etoolbox,pdftexcmds}
\let\englishtableofcontents\tableofcontents
\patchcmd\englishtableofcontents{{toc}}{{tec}}{}{}
\preto\englishtableofcontents{\begin{otherlanguage}{english}}
\appto\englishtableofcontents{\end{otherlanguage}}
\let\englishlistoffigures\listoffigures
\patchcmd\englishlistoffigures{{lof}}{{lef}}{}{}
\preto\englishlistoffigures{\begin{otherlanguage}{english}}
\appto\englishlistoffigures{\end{otherlanguage}}
\let\englishlistoftables\listoftables
\patchcmd\englishlistoftables{{lot}}{{let}}{}{}
\preto\englishlistoftables{\begin{otherlanguage}{english}}
\appto\englishlistoftables{\end{otherlanguage}}

\newcommand{\addetoc}[2]{%
  \addcontentsline{tec}{#1}{\protect\numberline{\csname the#1\endcsname}#2}%
}
\makeatletter
\newcommand{\englishcaption}[1]{%
  \ifnum\pdf@strcmp{\@captype}{figure}=\z@
    \addcontentsline{lef}{figure}{\protect\numberline{\thefigure}#1}%
  \else
    \addcontentsline{let}{table}{\protect\numberline{\thetable}#1}%
  \fi
}
\makeatother

\begin{document}

\tableofcontents
\englishtableofcontents

\listoffigures
\englishlistoffigures

\listoftables
\englishlistoftables

\section{Méthodes et matériaux}
\addetoc{section}{Methods and materials}

\subsection{Méthodes}
\addetoc{subsection}{Methods}

\begin{figure}[htp]
\centering{something}
\caption{En français}
\englishcaption{In English}
\end{figure}

\subsection{Matériaux}
\addetoc{subsection}{Materials}

\begin{table}[htp]
\centering{something}
\caption{En français}
\englishcaption{In English}
\end{table}

\end{document}

enter image description here

  • 1
    This is the advantage of people who know TeX! +1 – Keks Dose Apr 11 '14 at 15:16
  • @KeksDose I didn't need some hours just because I spent them on TeX during many years. ;-) – egreg Apr 11 '14 at 15:19
  • Amazing, thank you! Would a similar layout be possible for a table of figures do you reckon? – user18056 Apr 12 '14 at 13:14
  • @user18056 Yes; replicate the commands \listoffigures and \listoftables, say with extensions .lef and .let, defining \addelof and \addelot commands in the same vein. If you have problems, let me know. – egreg Apr 12 '14 at 13:16
  • After finally getting round to it, I'm having problems setting even the ToC part up. Does this have to be done specifically for a book or can it be done for an article (my file)? – user18056 Apr 14 '14 at 7:07
1

Yes, this seems possible, and there even is a detailed Howto, if you are using a KOMA-script class for you document. Please have a look at the KOMA-script manual, section »Management of Tables and Lists of Contents Using tocbasic«, a way which is a bit easier is described in section 15.5: »Everything with One Command Only«, but you may read the example under 15.4 as well for starters...

I'm not sure it will work with a second TOC with more than two levels, but chapter and sections seem possible. At least in Table 15.1 M. Kohm describes that there may be two counters in such a new TOC.


Answering comment of OP:

@user18056 No, you have misunderstood my suggestion: Make your TOC in french, like always (\tableofcontents). Additionally create a second TOC, with its own extension file, e.g. *.foo. After every chapter (\chapter{Méthodes}) and section you write \addtocontents{foo}{Methods}. At the place where you'd like to have the english toc, you'll have to add something like \listoftoc{foo}.

To find out in detail, how to do that, I confess, I'd need some hours. And right now I'll give up for this week. Maybe you can start by writing a MWE and posting it here along with your questions.

  • I appreciate the suggestion. I have had a quick skim through the document. I'm not sure whether it's possible to completely recreate a second ToC especially when I still need to create the titles in the other language somewhere...? – user18056 Apr 11 '14 at 13:59
  • Ok, I'll have another look and try. Thank you =) – user18056 Apr 11 '14 at 14:49
  • @user18056 In case you are using memoir, I think it is also possible with that class. The documentation describes how to create additional tables of whatever you want, so you could use that, and the same \addtocontents macro. – ienissei Apr 11 '14 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.