![如何调整页眉和页脚与文本框之间的间距,且页眉、页脚和文本之间不留空白?](https://linux22.com/image/350953/%E5%A6%82%E4%BD%95%E8%B0%83%E6%95%B4%E9%A1%B5%E7%9C%89%E5%92%8C%E9%A1%B5%E8%84%9A%E4%B8%8E%E6%96%87%E6%9C%AC%E6%A1%86%E4%B9%8B%E9%97%B4%E7%9A%84%E9%97%B4%E8%B7%9D%EF%BC%8C%E4%B8%94%E9%A1%B5%E7%9C%89%E3%80%81%E9%A1%B5%E8%84%9A%E5%92%8C%E6%96%87%E6%9C%AC%E4%B9%8B%E9%97%B4%E4%B8%8D%E7%95%99%E7%A9%BA%E7%99%BD%EF%BC%9F.png)
由于我的项目细节,我不能让任何页眉/页脚文本超出 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}
这会导致脚和头位于指定的文本高度内(顶部和底部边距之外)。