![更新](https://linux22.com/image/297696/%E6%9B%B4%E6%96%B0.png)
我已经定义了页边距和页眉,如下面的代码所示,但我希望页眉也覆盖页边距宽度,在第 2 页之后的页面(除第一页以外的所有页面)。我在网上搜索过,但没有找到任何解决方案。
\documentclass[standalone]{article}
\usepackage{marginnote}
\usepackage{fancyhdr}
\usepackage[pages=some]{background}
\usepackage{geometry}
\geometry{a4paper,
total= {210mm,297mm},
left= 37.5mm,
right= 12.5mm,
top= 25mm,
bottom= 25mm,
bindingoffset= 0mm}
\pagestyle{fancy}
\lhead{\Huge \bf Title1}
\rhead{\Large \bf Title2}
\begin{document}
\noindent Some text here.Some text here.Some text here.
\reversemarginpar\marginpar{\raggedleft {\large \bf Subtitle} \\*[-.8pc]}
\\Some text here.Some text here.Some text here.
\end{document}
答案1
我不太确定您希望结果是什么样子。我猜是两张图片中的一张,但哪一张呢?
这里开始使用偏移选项fancyhdr
:
\documentclass[a4paper]{article}
\usepackage{marginnote,calc,kantlipsum}
\usepackage{fancyhdr}
\usepackage{geometry}
\geometry{%
left=37.5mm,
right=12.5mm,
top=25mm,
bottom=25mm,
bindingoffset=0mm,
headheight=30pt,% output from geometry tells you what this needs to be set to as a minimum
}
\newlength{\myoddoffset}
\setlength{\myoddoffset}{\marginparwidth + \marginparsep}
\pagestyle{fancy}
\fancyheadoffset[leh,roh]{\marginparsep}
\fancyheadoffset[loh,reh]{\myoddoffset}
\lhead{\Huge \bfseries Title1}% Don't use \bf it is a LaTeX 2.09 command, long deprecated
\rhead{\Large \bfseries Title2}
\begin{document}
\noindent Some text here.Some text here.Some text here.
\reversemarginpar\marginpar{\raggedleft {\large \bfseries Subtitle} \\*[-.8pc]}
\\Some text here.Some text here.Some text here.
\kant[1-20]
\end{document}
如果你将twoside
选项添加到geometry
,你将会得到如下结果:
更新
这将撤消对右偏移的更改。(您不需要将其设置为零 - 您只需不要像我最初根据您发布的图像所做的那样更改它。)
它还为第一页设置了单独的样式,该样式在文档开头使用 来应用\thispagestyle{}
。如果您不想在那里添加标题,只需使用plain
或empty
而不是 ,具体fancyfirst
取决于您是否需要在页脚中添加页码。在这种情况下,您可以省去定义两个花哨样式所带来的复杂性。
\documentclass[a4paper]{article}
\usepackage{marginnote,calc,kantlipsum}
\usepackage{fancyhdr}
\usepackage{geometry}
\geometry{%
left=37.5mm,
right=12.5mm,
top=25mm,
bottom=25mm,
bindingoffset=0mm,
headheight=30pt,% output from geometry tells you what this needs to be set to as a minimum
}
\newlength{\myoddoffset}
\setlength{\myoddoffset}{\marginparwidth + \marginparsep}
\fancypagestyle{fancyfirst}{%
\lhead{\Huge \bfseries Title1}% Don't use \bf it is a LaTeX 2.09 command, long deprecated
\rhead{\Large \bfseries Title2}%
\fancyheadoffset{0pt}}
\fancypagestyle{fancyoffset}{%
\fancyheadoffset[loh,reh]{\myoddoffset}%
\lhead{\Huge \bfseries Title1}% Don't use \bf it is a LaTeX 2.09 command, long deprecated
\rhead{\Large \bfseries Title2}}
\pagestyle{fancyoffset}
\begin{document}
\thispagestyle{fancyfirst}
\noindent Some text here.Some text here.Some text here.
\reversemarginpar\marginpar{\raggedleft {\large \bfseries Subtitle} \\*[-.8pc]}
\\Some text here.Some text here.Some text here.
\kant[1-20]
\end{document}