3

I am writing a thesis. But it turned out to be of the wrong format. Following is the format (wrong one):

enter image description here

I want the following format, where header on odd page must be right side and header on the even page must be on the left side (in the following format):

enter image description here

P.S. Following is the TeX code that I used.

\usepackage{fancyhdr}
\pagestyle{fancy}                       % Sets fancy header and footer
\fancyfoot{}                            % Delete current footer settings
\renewcommand{\chaptermark}[1]{         % Lower Case Chapter marker style
  \markboth{\chaptername\ \thechapter.\ #1}{}} %
\renewcommand{\sectionmark}[1]{         % Lower case Section marker style
  \markright{\thesection.\ #1}}         %

\fancyhead[LE,RO]{\bfseries}            % Page number (boldface) in left on even
                                    % pages and right on odd pages                                 
\fancyhead[RE]{\sl\nouppercase\leftmark}% Chapter in the right on even pages
\fancyhead[LO]{\sl\nouppercase\rightmark}% Section in the left on odd pages
%\fancyhead[RE,RO]{\bfseries}

\cfoot{\thepage}
\renewcommand{\headrulewidth}{0.3pt}    % Width of head rule
\makeatletter
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else%
    \hbox{}%
\thispagestyle{empty}%              % Empty header styles
\newpage%
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\parskip 7.5pt
\makeatother \clearpage{\pagestyle{plain}\cleardoublepage}
  • Have you tried \fancyhead[RO]{\sl\nouppercase\leftmark}\fancyhead[LE]{\sl\nouppercase\rightmark} instead of \fancyhead[RE]{\sl\nouppercase\leftmark}\fancyhead[LO]{\sl\nouppercase\rightmark}? – gernot Nov 5 '19 at 14:12
  • Use LE instead of RE and RO instead of LO. R=right, L=left, E=even, O=odd. – leandriis Nov 5 '19 at 14:12
  • @gernotsaysReinstateMonica yeah I tried this but it is showing two headers on the same page – monalisa Nov 5 '19 at 18:27
2

To mark the left side of even pages (LE) and the right side on odd pages (RO), one has to set the header for these two locations:

\fancyhead[LE]{\sl\nouppercase\leftmark}
\fancyhead[RO]{\sl\nouppercase\rightmark}

By default, all sides are marked, so one has to set locations that are supposed to remain empty, here the right side on even pages (RE) and the left one on odd pages (LO) explicitly to empty:

\fancyhead[RE,LO]{}

Here is a sample document:

\documentclass{book}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter.\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
\fancyhead[RE,LO]{}                           
\fancyhead[LE]{\sl\nouppercase\leftmark}
\fancyhead[RO]{\sl\nouppercase\rightmark}
\fancyfoot{}
\cfoot{\thepage}
\renewcommand{\headrulewidth}{0.3pt}
\usepackage{blindtext}
\begin{document}
\Blinddocument
\end{document}

enter image description here

  • Thanks a ton. This helped me a lot. Thank you. – monalisa Nov 6 '19 at 8:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.