# Creating multi-language document

I am trying to write a document in both English and French (like the ones you can find on some planes). I use following declaration to use babel:

\usepackage[english,frenchb]{babel}
\babeltags{en = english}
\babeltags{fr = frenchb}


This works nice for paragraphs and typography.

Now I also want to add titles (\sections). I followed this previous answer: https://tex.stackexchange.com/a/170963/27327. This allows to create 2 different Table of contents, but only French titles are shown in the document (all \addetoc ones are dismissed).

So is there a simple way to create multi-language documents?

What I want is something like:

The TOC page:

|------------------------+-------------------------|
| table of content       | Table des matieres      |
|------------------------+-------------------------|
| Fist section         3 | Première section      3 |
| Second section      10 | Deuxième section     10 |
| ...                    | ...                     |
|                        |                         |
|------------------------+-------------------------|


On a \section page:

|--------------------------------------------------|
| First Section  -  Première Section             3 |
|--------------------------------------------------|
| Text in English                                  |
|                                                  |
|--------------------------------------------------|
| Text in French                                   |
|                                                  |
|--------------------------------------------------|


The only things I am missing are:

• how to display a section in several languages
• how to display a 2-column toc in the same page (one for each language)

• For the ToC see my answer here please: tex.stackexchange.com/questions/300169/… – user31729 May 30 '16 at 17:20
• @ChristianHupfer Thanks that solved the first part of my problem. I don't see though how to display section titles in both languages. – renard May 30 '16 at 17:31
• I didn't claim it would solve the section issue :-P, I wrote for the ToC... What is the 3 in the section header? The page number? – user31729 May 30 '16 at 17:34
• @ChristianHupfer Yes 3 is a page number. BTW I guess tex.stackexchange.com/questions/237637/… may also be a part of the solution. – renard May 30 '16 at 17:39
• Do you provide the section titles or are they auto generated, i.e. 1st section, 2nd section, without any special name? – user31729 May 30 '16 at 17:45

Something like this perhaps? (warning, the section title does not wrap around correctly!)

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,frenchb]{babel}
\babeltags{en = english}
\babeltags{fr = frenchb}
\usepackage{xpatch}
\usepackage{xparse}

\usepackage{blindtext}

\usepackage{parcolumns}

\makeatletter

\patchcmd{\pc@placeboxes}{\vrule}{{\VRULE}}{}{}
\newcommand\VRULE{\color{SOME_COLOR}\vrule width 0.2mm}

\def\@sect#1#2#3#4#5#6[#7]#8{%
\ifnum #2>\c@secnumdepth
\let\@svsec\@empty
\else
\refstepcounter{#1}%
\protected@edef\@svsec{\@seccntformat{#1}\relax}%
\fi
\@tempskipa #5\relax
\ifdim \@tempskipa>\z@
\begingroup
#6{%
\@hangfrom{\hskip #3\relax}%\@svsec}
\interlinepenalty \@M  #8 \hfill\thepage\@@par}%
\endgroup
\csname #1mark\endcsname{#7}%
\ifnum #2>\c@secnumdepth \else
\protect\numberline{\csname the#1\endcsname}%
\fi
#7}%
\else
\def\@svsechd{%
#6{\hskip #3\relax
\@svsec #8}%
\csname #1mark\endcsname{#7}%
\ifnum #2>\c@secnumdepth \else
\protect\numberline{\csname the#1\endcsname}%
\fi
#7}}%
\fi
\@xsect{#5}}

\let\latex@@section\section
\RenewDocumentCommand{\section}{somo}{%
\IfBooleanTF{#1}{%
\latex@@section*{#3}%
}{%
\def\@temp@@a{#3}
\IfValueT{#4}{%
\xdef\@temp@@a{#3 -- #4}
}
\IfValueTF{#2}{%
\latex@@section[#2]{\@temp@@a}%
}{%
\latex@@section[#3]{\@temp@@a}
}%
\IfValueT{#4}{%
}%
}%
}

\renewcommand\tableofcontents[1][toc]{%
\section*{\contentsname
\@mkboth{%
\MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
\@starttoc{#1}%
}

\makeatother

\begin{document}

\begin{parcolumns}[nofirstindent,rulebetween=true]{2}
\colchunk{%
\selectlanguage{english}
\tableofcontents
}
\colchunk{%
\selectlanguage{french}
\tableofcontents[ftoc]
}
\end{parcolumns}
\pagebreak

\section{First section}[Première Section]
\selectlanguage{english}
\blindtext
\selectlanguage{frenchb}
\blindtext
\section{Second Section}[Deuxième Section]
\selectlanguage{english}
\blindtext

\selectlanguage{frenchb}
\blindtext

\end{document}


• That do the job. Thanks. BTW \color{SOME_COLOR} generate an error. But the rest is correct. I'll see if I can find a workaround for the wrap. – renard May 30 '16 at 22:03
• @renard: The \color{SOME_COLOR} works out of the box for me, because the \VRULE command is never actually. – user31729 May 31 '16 at 6:10

Using following macro does the job for me:

\newlength{\sect@@width}
\usepackage{calc}
\newcommand\mlsection[2]{%
\refstepcounter{section}
\begingroup
\def\temp@@a{\noindent{#1}\hfill{#1}}
\setlength{\sect@@width}{\widthof{\temp@@a}}
\ifdim \sect@@width>\textwidth
\noindent#1\newline
\noindent#2
\else
\temp@@a
\fi
\endgroup
}%


beware: this is NOT a generic solution it does handle section numbering numbering (except in the TOC) or formating.

EDIT: The TOC links in the generated PDF doc does not work well either. Only links from the toc table are shown, ftoc links are not.

EDIT2: I eventually found a minimalistic working solution (no par skip, widow, club etc) but links in PDF document work:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,frenchb]{babel}
\babeltags{en = english}
\babeltags{fr = frenchb}
\usepackage{xpatch}
\usepackage{xparse}

\usepackage{blindtext}

\usepackage{parcolumns}

\usepackage{bookmark}

\makeatletter

\usepackage{printlen}
\newlength{\sect@@width}
\usepackage{calc}
\newcommand\@mlsection[4]{%
\refstepcounter{section}%
\begingroup%
\currentpdfbookmark{#1}{section.\csname thesection\endcsname}%
\currentpdfbookmark{#2}{section.\csname thesection\endcsname}%
\vspace{1em}%
\def\temp@@a{\LARGE\noindent{#3}\hfill{#4}}%
\setlength{\sect@@width}{\widthof{\temp@@a}}%
\ifdim \sect@@width>\textwidth%
\noindent\LARGE#3\newline%
\noindent\LARGE#4%
\else%
\temp@@a%
\fi%
\newline
\endgroup%
}%

\newcommand\mlsection[2]{%
\begingroup%
\@mlsection{#1}{#2}{\selectlanguage{english}#1}{\selectlanguage{frenchb}#2}%
\endgroup%
}%

\renewcommand\tableofcontents[1][toc]{%
\section*{\contentsname
\@mkboth{%
\MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
\@starttoc{#1}%
}

\makeatother

\begin{document}

\begin{parcolumns}[nofirstindent,rulebetween=true]{2}
\colchunk{
\selectlanguage{frenchb}
\tableofcontents[frtoc]
%\shorttableofcontents{\contentsname}{1}
}
\colchunk{
\selectlanguage{english}
\tableofcontents[entoc]
}
\end{parcolumns}

\newpage

\mlsection{First section}{Première Section}
{\selectlanguage{english}\blindtext}

{\selectlanguage{frenchb}\blindtext}

\mlsection{Second Section}{Deuxième Section}
{\selectlanguage{english}\blindtext}

{\selectlanguage{frenchb}\blindtext}

\mlsection{Third Section}{Troisième Section}
{\selectlanguage{english}\blindtext}

{\selectlanguage{frenchb}\blindtext}

\mlsection{Fourth Section}{Quatrième Section}
{\selectlanguage{english}\blindtext}

{\selectlanguage{frenchb}\blindtext}

\end{document}


the trick is to use toc to generate the anchors (section.N) and \currentpdfbookmark to create PDF links pointing to section.N. OTOH create both entoc and frtoc to display dual language table of content.

• Your question did not reveal that you wanted bookmarks for the 2nd language as well. Using portions of code from my answer without refering to it is also not very kosher! – user31729 Jun 5 '16 at 5:21
• Sorry if you feel harmed. Since your answer was a starting point and a part of this question I assume you're still credited for your work. If you want I can correct my answer and put your name on part of your code. – renard Jun 7 '16 at 0:52