Page LayoutHeader changes language

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
sentient6
Posts: 3
Joined: Fri May 08, 2009 11:07 am

Header changes language

Post by sentient6 »

Hello everyone!

I'm dealing with a problem at my headings which I can't figure it out. I'm writing a thesis (book document class) and the main language is Greek. At almost all pages headings are working great and are in Greek, but when I have to change the language to English so I can quote some source code (and the code is more than 1 page, or is changing page) the header that is "between" that code is in English :|

So in all document 2-3 headers are in English an all others in Greek. How can I define the header's language so that it won't be interfered by the text inside my document??? :roll:

Thanks in advance :)
\LaTeX ftw.

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Leo__
Posts: 28
Joined: Thu Oct 28, 2010 4:33 pm

Header changes language

Post by Leo__ »

Hello Sentient6,

I have apparently the same problem as yours (with Hebrew/English/French) in a complex document. That's how I found your post (probably well too late, but hopefully this may be of interest anyway...)

Unfortunately I haven't succeeded in solving it in a completely satisfactory way. But it may be sufficient for your purposes: protect the language in the header by adding \selectlanguage{greek} if you want to force latex to write the header in Greek. For instance, in my case, I am using the package fancyhdr, I wrote

\fancyhead[CO]{\selectlanguage{french}CHAPITRE \thechapter: LA
P\'ERIODE ANTIQUE} \fancyhead[CE]{\selectlanguage{french}LA
JUSTIFICATION DE LA LOI} \fancyhead[RO, LE]
{\selectlanguage{french}\thepage}

This solved the language problem: all headers for that chapter are now in French. However, this did not solve it completely because Hebrew is a right to left language and the layout is the mirror opposite of what I want it to be. Any suggestion, anyone ?

Since Greek is a left to right language, this solution might work in your case.

[Other than that, you can manually check the pages where the language of the header changes and make sure that the page change occurs at "the right language". This removed most of my "wrong" headers. Since the way Latex decides the layout is not obvious, it seems difficult to produce a minimal example.]

Leo
Post Reply