3

The below code produces the correct spacing for odd side pages but incorrect spacing for even side pages.

Correct spacing:

enter image description here

Wrong spacing:

enter image description here

In my attempt to optically distinguish between the two declarations, I could find three differences:

  1. I declared for the left footer rather than the right.
  2. I declared for the footer on the even pages rather than the odd pages.
  3. My declaration order is inverse: I start with the mark in my first declaration and \rlap next to it. The wrong spacing is produced when I issue \llap and follow with my mark.

I can produce the correct spacing without issuing \llap, but I'd really like to have my page number there.

How to get rid of the superfluous space produced by the \fancyfoot[LE] declaration? / How to produce the correct spacing on even pages, exactly the same as the spacing on odd pages?

Code:

\documentclass[twoside]{article}

\usepackage{xcolor}
\usepackage{lipsum}

\usepackage{fancyhdr}
\newlength\titleindent
\setlength\titleindent{.25in}

\pagestyle{fancy}
\fancyhf{}
%\renewcommand{\sectionmark}[1]{\markboth{#1}{}}
%\renewcommand{\subsectionmark}[1]{\markright{#1}}
\fancyfoot[RO]{%
        \leftmark\strut\rlap{\hskip\titleindent\parbox{\titleindent}{\color{blue}\thepage\strut}}%
        }%
\fancyfoot[LE]{%
        \llap{\parbox{\titleindent}{\color{blue}\thepage\strut}}\leftmark\strut%
        }%
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{.4pt}


\begin{document}

\section{Section}

\lipsum\lipsum

\end{document}
2

As egreg says in his answer, use \makebox here also.

\documentclass[twoside]{article}

\usepackage{xcolor}
\usepackage{lipsum}

\usepackage{fancyhdr}
\newlength\titleindent
\setlength\titleindent{.25in}

\pagestyle{fancy}
\fancyhf{}
%\renewcommand{\sectionmark}[1]{\markboth{#1}{}}
%\renewcommand{\subsectionmark}[1]{\markright{#1}}
\fancyfoot[RO]{%
        \leftmark\strut\makebox[0pt][l]{\hspace{\titleindent}\color{blue}\thepage\strut}%
        }%
\fancyfoot[LE]{%
        \makebox[0pt][r]{\color{blue}\thesection\hspace{\titleindent}}\leftmark\strut%
        }%
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{.4pt}


\begin{document}

\section{Section}

\lipsum\lipsum

\end{document}

enter image description here

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.