我希望所有文档的几何参数如下:
\usepackage[top=1.5cm, bottom=2cm, left=2.5cm, right=1.25cm, includehead,includefoot, footskip=5mm,headsep=5mm]{geometry}
但是第一页的左边距较小(1.25cm),因此我为第一页定义了新的几何图形。一切正常,但即使设置了右边距,页眉和页脚也会向右移动(但部分文本正常)。
代码:
\documentclass[a4paper,11pt]{article}
\usepackage[top=1.5cm, bottom=2cm, left=2.5cm, right=1.25cm, includehead,includefoot, footskip=5mm,headsep=5mm]{geometry}
%\usepackage[showframe]{geometry}
\usepackage{graphicx}
\usepackage{fancyhdr} % fancy headers/footers
\usepackage[T1]{fontenc}
\usepackage{newtxtext,newtxmath}
% Use fancyheadings stuff
\fancypagestyle{mytitlestyle}{
%Set up new layouts values for title page
\renewcommand{\headheight}{30mm}
% Definition of the header
\renewcommand{\headrulewidth}{0.6pt}
\fancyhead[L]{\bf Number}
\fancyhead[R]{\includegraphics[width=57mm]{Logo}}
%defn of footer
\renewcommand{\footrulewidth}{0pt}
\fancyfoot[L]{\textbf{Title}}
\cfoot{\vspace*{5mm} \bf Page \thepage\ of \pageref{END}}
\fancyfoot[R]{\textbf{Version number}}
}
\fancypagestyle{mypagestyle}{
% Definition of the header
\renewcommand{\headrulewidth}{0.6pt}
\fancyhead[LO,RE]{\bf Number}
\fancyhead[RO,LE]{\bf Commercial in Confidence}
%
\renewcommand{\footrulewidth}{0.6pt}
\fancyfoot[LO,RE]{\textbf{Title}}
\cfoot{\vspace*{5mm} \bf Page \thepage\ of \pageref{END}}
\fancyfoot[RO,LE]{\textbf{Version number}}
}
\begin{document}
\thispagestyle{mytitlestyle}
\newgeometry{top=1.5cm, bottom=5cm, left=1.25cm, right=1.25cm, includehead,includefoot, footskip=5mm,headsep=5mm}
\setcounter{page}{1}
\begin{center}
\vspace*{20mm}
{\Large \textbf{TITLE}}\\
\vspace*{30mm}
{\large \textbf{ABSTRACT}}
\end{center}
\newpage
\pagestyle{mypagestyle}
\restoregeometry
\section{The First Section}
Text text text text text text text text text text text text text text text text text text text text text text text text text.Text text text text text text text text text text text text text text text text text text text text text text text text text.Text text text text text text text text text text text text text
\label{END}
\end{document}
答案1
这显示了如何使用 tikz 创建标题页。由于 [记住图片],因此需要运行两次。
事实证明,这footskip=5mm
太小了,规则最终会进入文本区域,因此我将其增加到,footskip=10mm
然后相应地减小bottom
。我仍然无法完全匹配\textheight
或页脚间距。
\documentclass[a4paper,11pt]{article}
\usepackage[top=1.5cm, bottom=1.5cm, left=2.5cm, right=1.25cm, includehead,includefoot, footskip=10mm,headsep=5mm]{geometry}
%\usepackage[showframe]{geometry}
\usepackage{tikz}
\usepackage{fancyhdr} % fancy headers/footers
\usepackage[T1]{fontenc}
\usepackage{newtxtext,newtxmath}
% Use fancyheadings stuff
\fancypagestyle{mypagestyle}{
% Definition of the header
\renewcommand{\headrulewidth}{0.6pt}
\fancyhead[LO,RE]{\bf Number}
\fancyhead[RO,LE]{\bf Commercial in Confidence}
%
\renewcommand{\footrulewidth}{0.6pt}
\fancyfoot[LO,RE]{\textbf{Title}}
\cfoot{\vspace*{5mm} \bf Page \thepage\ of \pageref{END}}
\fancyfoot[RO,LE]{\textbf{Version number}}
}
\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}[remember picture, overlay]
\path(current page.north) ++(0pt,-1.5cm)% header (top)
node[below,inner sep=0pt,text width={\paperwidth-2.5cm}]{\rule{0pt}{30mm}% strut
\textbf{Title}\hfill\smash{\includegraphics[width=57mm]{example-image}}};% \smash in case logo doesn't fit
\draw[line width=0.6pt] (current page.north west) ++(1.25cm,-4.75cm) -- ++(\paperwidth-2.5cm,0pt);
\path(current page.north) ++(0pt,-5cm)% text area
node[below, inner sep=0pt]{\parbox[c][\dimexpr \paperheight-7.5cm][t]{\dimexpr\paperwidth-2.5cm}{%
\begin{center}
\vspace*{20mm}
{\Large \textbf{TITLE}}\\
\vspace*{30mm}
{\large \textbf{ABSTRACT}}
\end{center}}};
\draw[line width=0.6pt] (current page.south west) ++(1.25cm,1.75cm+0.5\baselineskip) -- ++(\paperwidth-2.5cm,0pt);
\path(current page.south) ++(0pt,1.5cm)% footer (baseline)
node[above, inner sep=0pt, text width={\paperwidth-2.5cm}]{%
\rlap{\textbf{Title}}\hfill
\raisebox{-8mm}[0pt][0pt]{\bf Page \thepage\ of \pageref{END}}\hfill
\llap{\textbf{Version number}}};
\end{tikzpicture}
\newpage
\pagestyle{mypagestyle}
\section{The First Section}
Text text text text text text text text text text text text text text text text text text text text text text text text text.Text text text text text text text text text text text text text text text text text text text text text text text text text.Text text text text text text text text text text text text text
\the\textheight\par
\the\dimexpr \paperheight-5cm\relax
\label{END}
\end{document}