
以下のコードは、奇数側ページには正しい間隔を生成しますが、偶数側ページには間違った間隔を生成します。
正しい間隔:
間隔が間違っています:
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
エグレが言うように彼の答え\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}