这就是我制作边框的方式:
\documentclass{article}
\usepackage{background}
\usepackage{tikz}
\usetikzlibrary{calc}
\backgroundsetup{angle = 0, scale = 1, vshift = -2ex,
contents = {\tikz[overlay, remember picture]
\draw [rounded corners = 15pt, line width = 2pt, color = black]
($(current page.north west)+(2cm,-2cm)$)
rectangle ($(current page.south east)+(-2,2)$);}}
\begin{document}
Hello World!
\end{document}
答案1
作为一种快速的解决方法,您可以使用彩色页面并用白色填充您的框架:
\documentclass{article}
\usepackage{background}
\usepackage{tikz}
\usetikzlibrary{calc}
\pagecolor{red}
\backgroundsetup{angle = 0, scale = 1, vshift = -2ex, opacity=1,
contents = {\tikz[overlay, remember picture]
\path [fill=white,rounded corners = 15pt, line width = 2pt, draw=black]
($(current page.north west)+(2cm,-2cm)$)
rectangle ($(current page.south east)+(-2,2)$);}}
\begin{document}
Hello World!
\end{document}
如果你需要透明背景,例如因为你使用了包pdfpages
,你可以使用来自的反向剪辑方法https://tex.stackexchange.com/a/290508/36296
\documentclass{article}
\usepackage{background}
\usepackage{tikz}
\usetikzlibrary{calc}
\tikzset{
clip even odd rule/.code={\pgfseteorule}, % Credit to Andrew Stacey
invclip/.style={
clip,insert path=
[clip even odd rule]{
[reset cm](-\maxdimen,-\maxdimen)rectangle(\maxdimen,\maxdimen)
}
}
}
\backgroundsetup{
angle = 0,
scale = 1,
vshift = -2ex,
opacity= 1,
contents = {
\begin{tikzpicture}[overlay, remember picture]
\draw [rounded corners = 15pt, line width = 4pt, color = black]
($(current page.north west)+(2cm,-2cm)$)
rectangle ($(current page.south east)+(-2,2)$);
\clip[invclip,rounded corners=15pt] ($(current page.north west)+(2cm,-2cm)$) rectangle ($(current page.south east)+(-2,2)$);
\fill[red] (current page.south west) rectangle (current page.north east);
\end{tikzpicture}
}
}
\begin{document}
Hello World!
\end{document}