由于我的项目细节,我不能让任何页眉/页脚文本超出 2.0 厘米。由于外边距拒绝我的几何代码,有什么方法可以让页眉和页脚恰好位于文本框的边框上吗?
\documentclass[11pt]{article}
\usepackage{sectsty,fancyhdr}
\sectionfont{\LARGE\bfseries}%this will keep the formating of sections
\usepackage{geometry}
\usepackage{lipsum}%remove
\pagestyle{fancy}
\fancyhf{}
\rhead{} % right side of upper footer
\lhead{Project tile}
\renewcommand{\headrulewidth}{2.0pt}% Width of the top line
\renewcommand{\footrulewidth}{1.0pt}
\setlength{\headheight}{13.6pt}%used to remove the \fancyhf{} \headheight error
\rfoot{Page \thepage}% opposite of above
\lfoot{\leftmark}% show the name of section
\geometry{% margin settings
paper=a4paper,
inner=2.0cm, % Inner margin
outer=2.0cm, % Outer margin
bindingoffset=0.0cm, % Binding offset
top=2.0cm, % Top margin
bottom=2.0cm, % Bottom margin
showframe,% show how the type block is set on the page
}
\makeatletter
\renewcommand{\sectionmark}[1]{%this avoids the \makecaptical of footers
\markboth{\ifnum \c@secnumdepth>\z@%this allowes symbols in foorters
\thesection\hskip 1em\relax
\fi #1}{}}
\makeatother
\begin{document}
\section{Introduction}
\subsection{Super introduction}
\lipsum[4-11]%remove
\end{document}
有任何想法吗?
答案1
有一个名为 的选项includeheadfoot
。geometry
若要额外更改头部和文本之间的间距,您可以使用headsep
和 来更改脚部和文本之间的间距footskip
:
\documentclass[11pt]{article}
\usepackage{sectsty,fancyhdr}
\sectionfont{\LARGE\bfseries}%this will keep the formating of sections
\usepackage{geometry}
\usepackage{lipsum}%remove
\pagestyle{fancy}
\fancyhf{}
\rhead{} % right side of upper footer
\lhead{Project tile}
\renewcommand{\headrulewidth}{2.0pt}% Width of the top line
\renewcommand{\footrulewidth}{1.0pt}
\setlength{\headheight}{13.6pt}%used to remove the \fancyhf{} \headheight error
\rfoot{Page \thepage}% opposite of above
\lfoot{\leftmark}% show the name of section
\geometry{% margin settings
paper=a4paper,
inner=2.0cm, % Inner margin
outer=2.0cm, % Outer margin
bindingoffset=0.0cm, % Binding offset
top=2.0cm, % Top margin
bottom=2.0cm, % Bottom margin
showframe,% show how the type block is set on the page
includeheadfoot,
headsep=5mm,
footskip=5mm
}
\makeatletter
\renewcommand{\sectionmark}[1]{%this avoids the \makecaptical of footers
\markboth{\ifnum \c@secnumdepth>\z@%this allowes symbols in foorters
\thesection\hskip 1em\relax
\fi #1}{}}
\makeatother
\begin{document}
\section{Introduction}
\subsection{Super introduction}
\lipsum[4-11]%remove
\end{document}
这会导致脚和头位于指定的文本高度内(顶部和底部边距之外)。