所以我目前正在将我们大学使用的一些文档转换为使用 LaTeX,但我遇到了一些问题。我已经能够掌握所有基础知识,使用绘图等;但我似乎无法弄清楚如何重新创建标题和页面外观。
这是标题页上的页眉示例(上部将贯穿整个文档):
我能够使用 pgfpages 创建页面边框,但似乎无法使连贯的页表显示并工作。使用 LaTeX 可以实现这些功能吗?
答案1
以下是使用background
和tikzpagenodes
包来生成标题和框架;代码包含一些解释性注释:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[scale=1,angle=0,opacity=1,color=black!60]{background}
\usepackage{tikzpagenodes}
\usepackage{lastpage}
\usepackage{lmodern}
\usepackage{lipsum}
\makeatletter
% A length to control the separation of the text and the frame
\newlength\AUCFrameSep
\setlength\AUCFrameSep{2cm}
% A length to control the height of the minipages used in the header
\newlength\AUCBoxHt
\setlength\AUCBoxHt{1.5cm}
% A length to control the width of the frame
\newlength\AUCFrameWd
\setlength\AUCFrameWd{\textwidth}
\addtolength\AUCFrameWd{2\AUCFrameSep}
% Definition of the user commands to fill the header
% Initially they are empty
\newcommand\Description[1]{\gdef\@ACUdescription{\textsc{#1}}}
\newcommand\LibNum[1]{\gdef\@ACUlibnum{\textsc{#1}}}
\newcommand\Rev[1]{\gdef\@ACUrev{#1}}
\Description{}
\LibNum{}
\Rev{}
% Command to build each one of the boxes for the header
% \AUCBox{<width>}{<title>}{<contents>}
% The optional argument controls the height of the minipages;
% default value= \AUCBoxHt
\newcommand\AUCBox[4][\AUCBoxHt]{%
\fbox{\begin{minipage}[t][#1][t]{#2}
\begin{flushleft}\footnotesize #3\end{flushleft}
\centering#4
\end{minipage}}}
% We define the background: the header and the frame
\backgroundsetup{%
contents={%
\begin{tikzpicture}[remember picture,overlay]
\draw
([xshift=-\AUCFrameSep,yshift=-2cm]current page text area.north west|-current page.north west)
rectangle
([xshift=\AUCFrameSep,yshift=-1.5\AUCFrameSep]current page text area.south east);
\node[anchor=north west,xshift=-\the\dimexpr\AUCFrameSep+\fboxrule\relax,yshift=-2cm,inner sep=0pt,outer sep=0pt] at (current page text area.north west|-current page.north west)
{%
\sffamily\small%
\setlength\fboxsep{2pt}%
\AUCBox{\dimexpr.6\AUCFrameWd-3\fboxrule-8\fboxsep\relax}{Description}{\@ACUdescription}\kern-\fboxrule%
\AUCBox{.175\AUCFrameWd}{Lib Num}{\@ACUlibnum}\kern-\fboxrule%
\AUCBox{0.10\AUCFrameWd}{Rev.}{\@ACUrev}\kern-\fboxrule%
\AUCBox{0.125\AUCFrameWd}{Page}{\scshape\thepage\ of \pageref{LastPage}}%
};%
\end{tikzpicture}%
}
}
\makeatother
\Description{\vskip-2ex%
Description line 1 \\
Description line 2 \\
Description line 3 \\
}
\LibNum{Doc 12345}
\Rev{---}
\begin{document}
\lipsum[2-20]
\end{document}
该文件的图片:
标题的放大图: