兩側頁腳產生額外的垂直空間

兩側頁腳產生額外的垂直空間

下面的程式碼為奇數側頁產生正確的間距,但為偶數側頁產生錯誤的間距。

正確的間距:

在此輸入影像描述

錯誤的間距:

在此輸入影像描述

當我嘗試從視覺上區​​分這兩個聲明時,我發現了三個差異:

  1. 我聲明為左頁腳而不是右頁腳。
  2. 我在偶數頁而不是奇數頁上聲明了頁腳。
  3. 我的聲明順序是相反的:我從mark第一個聲明中的 開始,然後\rlap是它的旁邊。當我發出\llap並跟隨我的時,會產生錯誤的間距mark

我可以在不發出 的情況下產生正確的間距\llap,但我真的很想在那裡有我的頁碼。

如何去除\fancyfoot[LE]聲明產生的多餘空間? / 如何在偶數頁上產生正確的間距,與奇數頁上的間距完全相同?

代碼:

\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}

答案1

正如egreg所說他的回答\makebox也用在這裡。

\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}

在此輸入影像描述

相關內容