Fancyhdr - 如何在页脚区域外添加页脚线?

Fancyhdr - 如何在页脚区域外添加页脚线?

我是 LaTeX 的初学者,暂时将其用于工业文档。我正在尝试模仿公司表格。我不明白为什么在 MWE 中,我希望在标题规则下方右侧看到的迷你页面的内容在为标题保留的区域中可见。另外,我希望最后一行“作者:作者姓名 \hfill 批准人:批准人姓名”出现在页面底部,紧靠页脚行上方,而不管第一页的内容如何。我找不到这样做的方法,也无法理解迷你页面的行为。也许还有更好的方法可以在标题规则的右半部分下方显示标题... 补充说明:“作者...”语句应仅出现在字体页面上。事实上,将其添加到首页页脚内容中是有一些逻辑的,并且在“文档参数”列表中添加了附加参数(这些参数位于我原始代码中的单独文件中),例如 \WriterName、\ReleaseDate、\ApproverName 等,但它应该出现在页脚规则线上方。

\documentclass[a4paper, oneside,11pt]{article} 
\usepackage[top=10mm, bottom=40mm, left=19mm, right=19mm]{geometry} 
\usepackage[utf8]{inputenc} 
\usepackage[draft]{graphicx} 
\usepackage{fancyhdr}
\usepackage{xcolor}
\usepackage[T1]{fontenc}
\usepackage{tgheros,textcomp}
\usepackage{lipsum}
\usepackage{lastpage} 
\usepackage[ french,english,]{babel} 

\def\LegalStatement{ %
\footnotesize\noindent\raggedright
\parbox[t]{.45\linewidth}{The Great Company Inc \\ MAILBOX 58670 PARIS TEXAS USA} \parbox[t]{.45\linewidth}{\copyright \thinspace \the\year~Company name The Great Company Corporation \\All international rights reserved\\ (\selectlanguage{french}Tous droits réservés)}
\medskip
\parbox[t]{\linewidth}{Ce document est sujet à modifications. Contacter Company Inc pour identifier la dernière révision et en obtenir une copie. Personnel Company name Inc: consultez la base de données "database centrale".
\selectlanguage{english}This document, managed by Company name Inc, is archived in the Central database. 
A printout cannot be considered as a controlled document}
}

%ARGUMENTS FOR DOCUMENT
\def\DocumentNumber {XXXXXX}
\def\HeaderLogo {Logo.pdf}
\def\DocumentName{DOCUMENT NAME} 
\def\DocumentType{Educational \\Specification}
\def\RevisionNumber{A }
\selectlanguage{english} %main language of document.
%END ARGUMENTS FOR DOCUMENT

\renewcommand{\familydefault}{\sfdefault}
%--------------------------------------------------------------------------
%HEADERS AND FOOTERS EXCEPT FRONT PAGE
\fancypagestyle{plain}{% Redefining in next lines  headers and their style.
\fancyhf{}
\chead{\bfseries\large{\DocumentType}}
\rhead{\textcolor{blue}{\large\bfseries{\DocumentNumber} \\ \footnotesize{\today}  \\ Rev \quad  \RevisionNumber}}
\lhead{\includegraphics[width=2.5cm]{\HeaderLogo}}
\lfoot{\bfseries\large{Rev \RevisionNumber}}
\rfoot{\bfseries{\thepage\ of \pageref{LastPage}}}
\renewcommand{\headrulewidth}{2pt}
\renewcommand{\footrulewidth}{2pt}
\renewcommand{\headheight}{2 cm} %  [thickness header line]-
\renewcommand{\headwidth}{\linewidth}%  [horizontal length header line]
\renewcommand{\headsep}{0.5 cm}%   [distance header-main text]
\renewcommand{\footskip}{2 cm} %  [distance footer-main text]
} %
% END HEADERS AND FOOTERS EXCEPT FRONT PAGE

%HEADER AND FOOTER FOR FRONT PAGE 
\fancypagestyle{FrontPage}{% Redefining in next lines  headers and their style.
\fancyhf{}
\chead{\bfseries\large{\DocumentType}}
\rhead{\textcolor{blue}{\large\bfseries{\DocumentNumber} \\ \footnotesize{\today}  \\ Rev \quad  \RevisionNumber - PRELIMINARY }}
\lhead{\includegraphics[height=1.5cm, width=2.5cm]{\HeaderLogo}}
\cfoot{\LegalStatement}
\rfoot{\bfseries{\thepage\ of \pageref{LastPage}}}
\renewcommand{\headrulewidth}{2pt}
\renewcommand{\footrulewidth}{2pt}
\renewcommand{\headsep}{0 cm}%   [distance header-main text] --
\renewcommand{\footskip}{1 cm} %  [distance footer-main text]--
} %
 %--END HEADERS FOOTER FRONT PAGE

%---BEGIN FRONT PAGE
\begin{document}  

\thispagestyle{FrontPage}
\raggedleft
\vspace{4cm}
\begin{minipage}[c][][c]{.5\textwidth}
\centering\Large{\textcolor{blue}{\textbf{\DocumentName}}} \\
\normalsize\rule{\linewidth}{2pt}
\end{minipage}

\raggedright
\section{Scope}
\lipsum[2-4]

Written by:  Writer's name \hfill   Approved by: Approver's name
\end{document}

答案1

如果这是一份 1 页的文档,\vfill在“作者”行之前添加一个简单的 就足以确保它位于底部。由于它可能有几页,一种方法是定义一个\customfooter包含该行并替换原始的 的命令\footrule。此外,\footrulewidth必须设置为零,这样您就不会得到两个规则。

关于 minipage,它的行为是正常的,问题是它从一行文本开始 - 并且第一行文本就在标题之后。由于\headheight太小,它从那个位置开始。\headheight需要更大才能容纳标题中的所有内容。当我尝试您的示例时,在编译时将其设置为建议的值是有效的(附加一个\vspace{0.5cm} 里面小頁面。

以下在我的设置中有效:

\documentclass[a4paper, oneside,11pt]{article} 
\usepackage[top=10mm, bottom=40mm, left=19mm, right=19mm]{geometry} 
\usepackage[utf8]{inputenc} 
\usepackage[draft]{graphicx} 
\usepackage{fancyhdr}
\usepackage{xcolor}
\usepackage[T1]{fontenc}
\usepackage{tgheros,textcomp}
\usepackage{lipsum}
\usepackage{lastpage} 
\usepackage[ french,english,]{babel} 

\def\LegalStatement{ %
\footnotesize\noindent\raggedright
\parbox[t]{.45\linewidth}{The Great Company Inc \\ MAILBOX 58670 PARIS TEXAS USA} \parbox[t]{.45\linewidth}{\copyright \thinspace \the\year~Company name The Great Company Corporation \\All international rights reserved\\ (\selectlanguage{french}Tous droits réservés)}
\medskip
\parbox[t]{\linewidth}{Ce document est sujet à modifications. Contacter Company Inc pour identifier la dernière révision et en obtenir une copie. Personnel Company name Inc: consultez la base de données "database centrale".
\selectlanguage{english}This document, managed by Company name Inc, is archived in the Central database. 
A printout cannot be considered as a controlled document}
}

%ARGUMENTS FOR DOCUMENT
\def\DocumentNumber {XXXXXX}
\def\HeaderLogo {Logo.pdf}
\def\DocumentName{DOCUMENT NAME} 
\def\DocumentType{Educational \\Specification}
\def\RevisionNumber{A }
\selectlanguage{english} %main language of document.
%END ARGUMENTS FOR DOCUMENT

\renewcommand{\familydefault}{\sfdefault}
%--------------------------------------------------------------------------
%HEADERS AND FOOTERS EXCEPT FRONT PAGE
\fancypagestyle{plain}{% Redefining in next lines  headers and their style.
\fancyhf{}
\chead{\bfseries\large{\DocumentType}}
\rhead{\textcolor{blue}{\large\bfseries{\DocumentNumber} \\ \footnotesize{\today}  \\ Rev \quad  \RevisionNumber}}
\lhead{\includegraphics[width=2.5cm]{\HeaderLogo}}
\lfoot{\bfseries\large{Rev \RevisionNumber}}
\rfoot{\bfseries{\thepage\ of \pageref{LastPage}}}
\renewcommand{\headrulewidth}{2pt}
\renewcommand{\footrulewidth}{2pt}
\renewcommand{\headheight}{2 cm} %  [thickness header line]-
\renewcommand{\headwidth}{\linewidth}%  [horizontal length header line]
\renewcommand{\headsep}{0.5 cm}%   [distance header-main text]
\renewcommand{\footskip}{2 cm} %  [distance footer-main text]
} %
% END HEADERS AND FOOTERS EXCEPT FRONT PAGE

%HEADER AND FOOTER FOR FRONT PAGE 
\fancypagestyle{FrontPage}{% Redefining in next lines  headers and their style.
\fancyhf{}%
\chead{\bfseries\large{\DocumentType}}%
\rhead{\textcolor{blue}{\large\bfseries{\DocumentNumber} \\ \footnotesize{\today}  \\ Rev \quad  \RevisionNumber - PRELIMINARY }}%
\lhead{\includegraphics[height=1.5cm, width=2.5cm]{\HeaderLogo}}%
\cfoot{\customfooter}%
\rfoot{}%
\renewcommand{\headrulewidth}{2pt}%
\renewcommand{\footrulewidth}{0pt}%
\renewcommand{\headheight}{47 pt}%
\renewcommand{\headsep}{0 cm}%   [distance header-main text] --
\renewcommand{\footskip}{1 cm}%  [distance footer-main text]--
} %
 %--END HEADERS FOOTER FRONT PAGE

\newcommand{\customfooter}{
\vspace{-1.2cm}
Written by:  Writer's name \hfill   Approved by: Approver's name
\rule{\textwidth}{2pt} 
\bfseries{\thepage\ of \pageref{LastPage}}\hfill\LegalStatement\hfill}


%---BEGIN FRONT PAGE
\begin{document}  

\thispagestyle{FrontPage}
\raggedleft
\begin{minipage}[b]{.5\textwidth}
\vspace{.5cm}
\centering\Large{\textcolor{blue}{\textbf{\DocumentName}}}
\rule{.5\textwidth}{2pt}
\end{minipage}

\raggedright
\section{Scope}

\lipsum[2-5]

\end{document}

相关内容