如何在LaTeX中将含页眉页脚的文本纳入四边2cm缩进的边框内?
解决LaTeX页眉页脚超出边框的问题
你的问题出在geometry包的选项冲突上:同时使用includeheadfoot和noheadfoot会强制取消页眉页脚的预留空间,最终导致页脚跑到边框外。
修正后的代码
\documentclass[12pt, a4paper, titlepage]{extreport} \usepackage{fontspec} \setmainfont{CMU Serif} \setsansfont{CMU Sans Serif} \setmonofont{CMU Typewriter Text} \usepackage{polyglossia} \setdefaultlanguage{latin} \setotherlanguage{english} \usepackage[ a4paper, margin=2cm, includeheadfoot, nomarginpar, showframe ]{geometry} \usepackage{blindtext} \begin{document} \Blinddocument \end{document}
关键参数说明
includeheadfoot:告知geometry包将页眉、页脚的高度纳入边距计算逻辑,确保它们被包含在你设置的2cm边距范围内- 移除
noheadfoot:该选项会直接取消页眉页脚的预留空间,与includeheadfoot完全冲突,必须删除 margin=2cm:定义页面四边(页面顶端到页眉顶部、页面底端到页脚底部,以及左右两侧)的边距均为2cm,完全匹配你的需求
编译后,页眉会从页面顶端2cm处开始,页脚会在距离页面底端2cm处结束,所有内容(包括页眉页脚)都会被包含在showframe显示的边框内。
内容的提问来源于stack exchange,提问作者Timothée
相关产品推荐
相关产品推荐

