![迁移后台包 > \AddToHook 宏](https://linux22.com/image/430696/%E8%BF%81%E7%A7%BB%E5%90%8E%E5%8F%B0%E5%8C%85%20%3E%20%5CAddToHook%20%E5%AE%8F.png)
我的目标是使用最新的宏\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}