我的目标是使用最新的宏\AddToHook{shipout/background}
而不是已弃用的包background
。如何为此目的更改以下 MWE?
平均能量损失
\documentclass[11pt]{book}
\usepackage{xcolor,tikz}
\usetikzlibrary{calc}
%
\RequirePackage[contents={}]{background}
\backgroundsetup{
scale = 1 ,
opacity = 1 ,
angle = 0 ,
color = gray ,
contents={%
\begin{tikzpicture}[every node/.style={inner sep=0pt}]
\draw[line width=2pt] ($(current page.north west) +(2.3in,-0.15in)$) --
($(current page.north west) +(0.25in,-0.15in)$) -- ($(current page.north west)
+(0.25in,-0.5in)$);
\draw[line width=0.2pt] ($(current page.north west) +(2.3in,-0.15in)$) --
($(current page.north) +(-0.15in,-0.15in)$);
\draw[line width=2pt] ($(current page.south east) +(-2.3in,0.05in)$) --
($(current page.south east) +(-0.25in,0.05in)$) -- ($(current page.south east)
+(-0.25in,0.5in)$);
\end{tikzpicture}%
}
}%
\begin{document}
Test
\end{document}
答案1
\documentclass[11pt]{book}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{calc}
\AddToHook{shipout/background}
{%
\begin{tikzpicture}[remember picture,overlay,every node/.style={inner sep=0pt}]
\draw[line width=2pt] ($(current page.north west) +(2.3in,-0.15in)$) --
($(current page.north west) +(0.25in,-0.15in)$) -- ($(current page.north west)
+(0.25in,-0.5in)$);
\draw[line width=0.2pt] ($(current page.north west) +(2.3in,-0.15in)$) --
($(current page.north) +(-0.15in,-0.15in)$);
\draw[line width=2pt] ($(current page.south east) +(-2.3in,0.05in)$) --
($(current page.south east) +(-0.25in,0.05in)$) -- ($(current page.south east)
+(-0.25in,0.5in)$);
\end{tikzpicture}%
}
\begin{document}
\lipsum[1-4]
\end{document}