GeneralDocument with ToC written in two Languages

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
VOST
Posts: 3
Joined: Mon Jun 03, 2013 6:31 pm

Document with ToC written in two Languages

Post by VOST »

Hello everyone,

I'm new to the world of LaTeX and I'm having trouble to generate a PDF file from a source mainly written in French with bits in Amharic. The problem occurs only when I try to generate a ToC, using \tableofcontents, with the rest of the document. In other words, without the table of content I have a PDF file that looks like as it has been set up but when adding the ToC I simply cannot generate the document in PDF.

Here are the packages used for this document regarding the languages.

Code: Select all

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{ethiop}
Here is how I proceed to switch between languages inside the document. French being the main language of the document I start with \selectlanguage{french} put before \maketitle. When I need to write in Amharic I type \selectlanguage{ethiop}.
And here is how I do when writing in Amharic with a short example: typing tAhesAse in the source code, I obtain "ታህሳስ" in the PDF file.

The error messages I have contain a lot of "! Missing $ inserted." or "! Missing } inserted". And in case it is relevant, when generating a PDF without the ToC, even if it works, I have the following error.

Code: Select all

Package frenchb.ldf Warning: The definition of \@makecaption has been changed,
I am thinking that maybe I should manually change something in the ToC using a package like tocloft?

I will appreciate any ideas that can bring some light on that table of content problem. And if, by any chance, you know a way of writing Amharic symbols (in source code) that can be recognized as such, I will also take it gladly.

Thank you


PS: I got the information on how writing Amharic from ethiop.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Document with ToC written in two Languages

Post by Johannes_B »

Well, my first guess would be a missing }, or one too many. Do you know what a Minimal example is?
You should try it out, it helps in finding the error.
Right now, we could only guess.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
VOST
Posts: 3
Joined: Mon Jun 03, 2013 6:31 pm

Document with ToC written in two Languages

Post by VOST »

It seems that the combination of apostrophe with the ethiop package in my document is causing trouble with the table of content.
Here is what I observed, according to the example below: when I remove the apostrophe (in the chapter title), the TOC in the pdf file is generated and the Amharic part is correctly printed; if I leave the apostrophe but I removed the \usepackage{ethiop} line and \selectlanguage{ethiop}, the TOC in the pdf file is generated and the Amharic symbols are not there anymore; and if I leave everything in place but I remove the \tableofcontents line, the apostrophe is there and the Amharic symbols also.

Code: Select all

\documentclass {book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{ethiop}

\begin{document}
\selectlanguage{french}
\tableofcontents

\chapter{Et d'une}
27 décembre 2012 \selectlanguage{ethiop}(tAhesAse 18 qane 2005 A.me.)

\end{document}
Going through the toc file being generated here is what I have instead of "Et d'une", where the apostrophe lies: Et d^\bgroup \prime \futurelet \@let@token \egroup une.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Document with ToC written in two Languages

Post by Johannes_B »

Very good example.

The ethiop-package makes characters like ' ~ ^ _ . active (It says so in the documentation in the section called common pitfalls).

The ' (U+0027) acts in mathmode as the prime symbol, in textmode it is converted to the apostophe.
Now LaTeX sees the prime symbol in the toc-file (there are your headings and their pagenumbers stored) and complains about not beeing in math mode. I don't have a solution right now, maybe i overlooked something. You could also ask the maintainer of the ethiop-package.

But here is a different approach: You are using a utf8-encoded file. That means you can write the typographically correct symbol (U+2019) [1] into the file and it will be typeset correctly. Back in the days when TeX was programmed, computers simply wheren't powerfull enough for so many characters. I'll give you an example:

Code: Select all

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{ethiop}

\begin{document}
\selectlanguage{french}
\tableofcontents

\chapter{Et d’une} 
Compare: ’ (typographically correct input) and ' and the same in math mode: $'$

27 décembre 2012 \selectlanguage{ethiop}(tAhesAse 18 qane 2005 A.me.)

\end{document}

[1] apostrophe and how to enter it (Wikipedia)


EDIT: Load babel after ethiop. This works for your example. Maybe it's going to conflict with some other things
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
VOST
Posts: 3
Joined: Mon Jun 03, 2013 6:31 pm

Document with ToC written in two Languages

Post by VOST »

Both your solutions work Johannes.

Using a typographically correct symbol and keeping all the packages as it is, the TOC can be generated. And here is what "Et d'une" looks like in the toc file: Et d\IeC {\textquoteright }une.

If I load the babel after the ethiop package, even by keeping the wrong apostrophe symbol, it also works. And here is what "Et d'une" looks like in the toc file: Et d'une.

The second solution might confirm that only the apostrophe causes trouble as I also have accents or ç in the titles of my document; meaning, the problem seems not to come from a conflict with the French package.

At the end, a mix of the two solutions makes it possible to generate a TOC in a final pdf file:

Code: Select all

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{ethiop}
\usepackage[french]{babel}

\begin{document}
\selectlanguage{french}
\tableofcontents
\chapter{Et d’une} 
27 décembre 2012 \selectlanguage{ethiop}(tAhesAse 18 qane 2005 A.me.)
\end{document}
Concerning the fact that this prime symbol in the TOC is being recognised as something that should be in math mode, intrigues me; I will edit my post if information about it come later to me.
But for now I will put this topic as solved as the TOC can be generated properly, thanks to you Johannes and your efficient and fast observation.
Post Reply