Document ClassesDifferent header for odd and even pages

Information and discussion about specific document classes and how to create your own document classes.
paulosousa
Posts: 90
Joined: Sun Jun 24, 2012 8:48 pm

Different header for odd and even pages

Post by paulosousa »

Hello all,

I need the header with:
  • even pages at left and chapter name at right
    odd pages at right and section name at left
no capital letters
empty footer

What I am doing wrong?

other question why

Code: Select all

\documentclass[12pt, twoside, a4paper]{book}
enumerate sections like 0.1, 0.2, ...?

example:

Code: Select all

\documentclass[12pt, twoside, a4paper]{article}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[RO,LE]{\small\thepage}
\fancyhead[LO]{\small \emph{\leftmark}} 
\fancyhead[RE]{\small \emph{\rightmark}} 
\fancyfoot[L,R,C]{}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{0pt}

\begin{document}
   \onehalfspacing
   \linespread{1.5}
\begin{titlepage}
...
\end{titlepage}

\pagenumbering{Roman}

\section*{Abstract}
...
\newpage

\tableofcontents
\newpage

\pagenumbering{arabic}

\section{Introduction} 

\chapter{write the name}

\section{State of Art}

\subsection{Modelos ARFIMA ($p,d,q$)}

\section{Conclusions}

\section{References}

\end{document}

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

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

Different header for odd and even pages

Post by Johannes_B »

You can use the command \nouppercase to avoid having the headers all in Capitals.

Code: Select all

\documentclass[12pt, twoside, a4paper]{article}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[RO,LE]{\small\thepage}
\fancyhead[LO]{\small \emph{\nouppercase{\leftmark}}}
\fancyhead[RE]{\small \emph{\nouppercase{\rightmark}}}
\fancyfoot[L,R,C]{}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{0pt}


\usepackage{blindtext}
\begin{document}
   %\onehalfspacing%JB: needs package setspace
   %\linespread{1.5}
\begin{titlepage}
...
\end{titlepage}

\pagenumbering{Roman}

\section*{Abstract}
\blindtext
%\newpage %better use clearpage
\clearpage 

\tableofcontents
\newpage

\pagenumbering{arabic}
\section{Introduction} 
%\chapter{write the name}
\section{State of Art}
\subsection{Modelos ARFIMA ($p,d,q$)}
\section{Conclusions}
\section{References}
\blinddocument
\blinddocument

\end{document}
To your second question. You were talking about chapters and sections, but you are using sections and subsections. Simple reason for that. Article does not provide chapters. Classes like book and report do and number them accordingly.
Having a section without a chapter, you get chapter 0 section 1

If you have the freedom to choose, i advice you to have a look at KOMA-script. This is a whole bunch of useful alternatives and add ons to the standard classes and everything works very smooth together.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
paulosousa
Posts: 90
Joined: Sun Jun 24, 2012 8:48 pm

Re: Different header for odd and even pages

Post by paulosousa »

For now it's perfect, thanks a lot for the help and explanations.
paulosousa
Posts: 90
Joined: Sun Jun 24, 2012 8:48 pm

Different header for odd and even pages

Post by paulosousa »

I am using

Code: Select all

\documentclass[12pt, twoside, a4paper]{book}
and I have, in the document,

Code: Select all

\section{References}


it opens a page with (only) References and other page (the next) with The Bibliography and not References, is it normal in the Book class?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Different header for odd and even pages

Post by Johannes_B »

Above, you gave us compilable code. This makes it easy to help, because testing is easy. There is no guessing involved, since you do all the pre-work. Please read, how to prepare a minimum working example and come back to us.

Normally, the class or a package takes care of putting an appropriate heading.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
paulosousa
Posts: 90
Joined: Sun Jun 24, 2012 8:48 pm

Different header for odd and even pages

Post by paulosousa »

Here it is:

Code: Select all

 
\documentclass[12pt, twoside, a4paper]{book}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[RO,LE]{\small\thepage}
\fancyhead[LO]{\small \emph{\nouppercase{\leftmark}}}
\fancyhead[RE]{\small \emph{\nouppercase{\rightmark}}}
\fancyfoot[L,R,C]{}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{0pt}


\usepackage{blindtext}
\begin{document}

\begin{titlepage}
...
\end{titlepage}

\pagenumbering{Roman}

\section*{Abstract}
\blindtext

\clearpage 

\tableofcontents
\newpage

\pagenumbering{arabic}
\section{Introduction} 

\section{State of Art}

\subsection{Modelos ARFIMA ($p,d,q$)}

\section{Conclusions}

\section{References}
\begin{thebibliography}{}
\bibitem{Miller} Miller WG. The neuropsychology of head injuries. The neuropsychology handbook; behavioural and clinical perspectives. New York: Springer 1986; 347-375
\bibitem{Rudehill} Rudehill A, Bellander BM, Weitzberg E, Bredbacka S, Backheden M and Godon E. Outcome of traumatic brain injuries in 1508 patients: impact od prehospital care. J Neurotrauma, 2002; 19: 855-868
\end{thebibliography}{}

\end{document}
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Different header for odd and even pages

Post by Johannes_B »

Code: Select all

\documentclass[12pt, twoside, a4paper]{book}
\renewcommand{\bibname}{References}
\begin{document}

\begin{thebibliography}{}
\bibitem{Miller} Miller WG. The neuropsychology of head injuries. The neuropsychology handbook; behavioural and clinical perspectives. New York: Springer 1986; 347-375
\bibitem{Rudehill} Rudehill A, Bellander BM, Weitzberg E, Bredbacka S, Backheden M and Godon E. Outcome of traumatic brain injuries in 1508 patients: impact od prehospital care. J Neurotrauma, 2002; 19: 855-868
\end{thebibliography}{}

\end{document}
I really recommend to use the modern package biblatex to take care of the bibliography. Customizing it is much much easier, if you later decide to change something.
You can use Jabref (for instance) to manage your entries.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
paulosousa
Posts: 90
Joined: Sun Jun 24, 2012 8:48 pm

Re: Different header for odd and even pages

Post by paulosousa »

well it solves the problem in the minimal example but not in whole document!
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Different header for odd and even pages

Post by Johannes_B »

Well, then the best way to find the cause is to prepare a minimal example by hacking down. See the link above.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
paulosousa
Posts: 90
Joined: Sun Jun 24, 2012 8:48 pm

Different header for odd and even pages

Post by paulosousa »

hope now you can help me...

Code: Select all

\documentclass[12pt, twoside, a4paper]{book}
\usepackage[portuguese,english]{babel}
\usepackage[applemac]{inputenc}
\usepackage[left=3.0cm,top=3.0cm,right=3.0cm,bottom=3.0cm]{geometry}
\usepackage{amsmath,amssymb,amsfonts,textcomp,setspace,graphicx,makeidx,color,gensymb,mhchem}
\usepackage[compact]{titlesec}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[RO,LE]{\small\thepage}
\fancyhead[LO]{\small \emph{\nouppercase{\leftmark}}}
\fancyhead[RE]{\small \emph{\nouppercase{\rightmark}}}
\fancyfoot[L,R,C]{}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{0pt}

\renewcommand{\bibname}{References}

\begin{document}
\onehalfspacing
\linespread{1.5}
\begin{titlepage}
...
\end{titlepage}

\pagenumbering{Roman}
\section*{Abstract}
TEXT
\clearpage 

\tableofcontents
\newpage

\pagenumbering{arabic}

\chapter{Introduction}
TEXT
\chapter{State of Art}
\section{Epidemiology} 

\section{Pathophysiology}

\section{Conclusions / Results and discussion}

\chapter*{References}

\begin{thebibliography}{}
\bibitem{Miller} Miller WG. The neuropsychology of head injuries. The neuropsychology handbook; behavioural and clinical perspectives. New York: Springer 1986; 347-375
\bibitem{Rudehill} Rudehill A, Bellander BM, Weitzberg E, Bredbacka S, Backheden M and Godon E. Outcome of traumatic brain injuries in 1508 patients: impact od prehospital care. J Neurotrauma, 2002; 19: 855-868
\end{thebibliography}{}

\end{document}
Post Reply