我想使用某种命令\eachpageornament
在文档的每一页上放置装饰边框。我可以在每一页上使用那个新命令来做到这一点,但假设我们的文档有 200 页,那么就会有问题。我在这里找到了这个(不完全是)代码http://altermundus.com/pages/downloads/packages/pgfornament/ornaments.pdf。它在第 12 页。第 11 页他们正在讨论其他解决方案,但我没能(因为我对 LaTeX 还很陌生)实现这种方式。如果更简单的话,你可以向我展示这种方式。
\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[object=vectorian]{pgfornament}
\usepackage{lipsum}
\newcommand{\eachpageornament}{%
\begin{tikzpicture}[remember picture, overlay]
\node[anchor=north west] at (current page.north west){%
\pgfornament[width=2cm]{63}};
\node[anchor=north east] at (current page.north east){%
\pgfornament[width=2cm,symmetry=v]{63}};
\node[anchor=south west] at (current page.south west){%
\pgfornament[width=2cm,symmetry=h]{63}};
\node[anchor=south east] at (current page.south east){%
\pgfornament[width=2cm,symmetry=c]{63}};
\end{tikzpicture}
}
\begin{document}
\eachpageornament
\lipsum
\eachpageornament
\lipsum
\eachpageornament
\lipsum
\eachpageornament
\end{document}
您必须编译两次才能看到效果。
我希望可以对文章 A4 而不是 scrartcl 执行此操作。
答案1
以下是 MWE 使用background
和eso-pic
包的情况:
\documentclass[dvipsnames,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[object=vectorian]{pgfornament}
\usepackage{lipsum}
% Comment below if you are using the eso-pic version
%--------------------------------------------------------------------
\usepackage{background}
%--------------------------------------------------------------------
%--------------------------------------------------------------------
% Uncomment below to obtain the same effect using the eso-pic package
%\usepackage{eso-pic}
%\AddToShipoutPictureBG{%
% \AtPageUpperLeft{\eachpageornament}}
%--------------------------------------------------------------------
% Comment below if you are using the eso-pic version
%--------------------------------------------------------------------
\backgroundsetup{%
contents=\eachpageornament,%
position=current page.north east,%
angle=0,%
scale=1,%
opacity=1%
}
%--------------------------------------------------------------------
\newcommand{\eachpageornament}{%
\begin{tikzpicture}[remember picture, overlay,color=BrickRed]
\node[anchor=north west] at (current page.north west){%
\pgfornament[width=2cm]{63}};
\node[anchor=north east] at (current page.north east){%
\pgfornament[width=2cm,symmetry=v]{63}};
\node[anchor=south west] at (current page.south west){%
\pgfornament[width=2cm,symmetry=h]{63}};
\node[anchor=south east] at (current page.south east){%
\pgfornament[width=2cm,symmetry=c]{63}};
\end{tikzpicture}
}
\begin{document}
\lipsum
\lipsum
\lipsum
\end{document}
注意:pgfornament
Alain Matthes 的包需要手动安装。点击这里下载该软件包。