![如何使用 LaTeX 制作自定义页面框架?](https://linux22.com/image/240140/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20LaTeX%20%E5%88%B6%E4%BD%9C%E8%87%AA%E5%AE%9A%E4%B9%89%E9%A1%B5%E9%9D%A2%E6%A1%86%E6%9E%B6%EF%BC%9F.png)
我需要制作问卷模板以便自动处理閱讀。为此我需要制作如下页面:
页面的 queXF 要求是
- 每页都有唯一的条形码(借助包、、使用条形码作为页码
fancyhdr
完成)pst-barcode
pstricks-add
- 页面框架定位
我需要像上面的示例页面一样在每个页面上绘制框架(请注意,框架与页面相关,但与文本无关)。
我认为有两种方法可以实现这一目标:
- 设置图像背景
- 画出单独的线条(首选)
可以使用 LaTeX 来实现吗?
答案1
您可以使用背景包裹:
\documentclass{article}
\usepackage[margin=2cm]{geometry}
\usepackage{background}
\usetikzlibrary{calc}
\usepackage{lipsum}% just to generate some text
\SetBgScale{1}
\SetBgColor{black}
\SetBgAngle{0}
\SetBgOpacity{1}
\SetBgVshift{-4}
\SetBgContents{
\begin{tikzpicture}[thick]
\draw (0.55\textwidth,10) -- (0.55\textwidth,0.52\textheight) -- (0.4\textwidth,0.52\textheight);
\draw (-0.55\textwidth,10) -- (-0.55\textwidth,0.52\textheight) -- (-0.4\textwidth,0.52\textheight);
\draw (-0.55\textwidth,-10) -- (-0.55\textwidth,-0.52\textheight) -- (-0.4\textwidth,-0.52\textheight);
\draw (0.55\textwidth,-10) -- (0.55\textwidth,-0.52\textheight) -- (0.4\textwidth,-0.52\textheight);
\end{tikzpicture}
}
\pagestyle{empty}
\begin{document}
\lipsum[1-4]\newpage
\end{document}
答案2
关于我在此处的评论,改编的示例如下pstricks
:
\documentclass[12pt,a4paper]{report}
\usepackage{eso-pic}
\usepackage{pstricks}
\definecolor{myGray}{rgb}{0.9,0.9,0.9}
\newdimen\BorderWidth \BorderWidth=\paperwidth
\newdimen\BorderHeight \BorderHeight=\paperheight
\newdimen\BorderSep \BorderSep=30pt
\advance\BorderWidth by -2\BorderSep
\makeatletter
\newcommand\Border{%
\psset{unit=1pt}
\put(\strip@pt\BorderSep,\strip@pt\BorderHeight){%
\advance\BorderHeight by -\BorderSep
% \psframe[linewidth=3pt]%
% (0,-\BorderHeight)(\BorderWidth, -\BorderSep)
\psline(0,-0.25\BorderWidth)(0,-\BorderSep)(0.25\BorderWidth,-\BorderSep)
\psline(0.75\BorderWidth,-\BorderSep)(\BorderWidth,-\BorderSep)(\BorderWidth,-.25\BorderWidth)
\@tempdima -\BorderHeight
\advance\@tempdima .25\BorderWidth
\psline(0,\@tempdima)(0,-\BorderHeight)(.25\BorderWidth,-\BorderHeight)
\psline(0.75\BorderWidth,-\BorderHeight)(\BorderWidth,-\BorderHeight)(\BorderWidth,\@tempdima)
}}
\makeatother
\AddToShipoutPicture{\Border}
\usepackage{lipsum}
\begin{document}
\lipsum
\end{document}