[Tex/LaTex] Creating multi-language document

babellanguagestable of contents

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)

Thanks in advance.

Best Answer

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}%
    \addcontentsline{toc}{#1}{%
      \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}%
      \addcontentsline{toc}{#1}{%
        \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}{%
      \addcontentsline{ftoc}{section}{\protect\numberline{\csname thesection\endcsname}#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}

enter image description here