0

My aim is to use the recent macro \AddToHook{shipout/background} instead of the depreciated package background. How can I change the following MWE for this purpose ?

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}

enter image description here

jowe_19
  • 939

1 Answers1

2
\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}

enter image description here

Ivan
  • 4,368
  • 1
    Thanks. And would it be possible to disable the option on some pages ? – jowe_19 Mar 20 '21 at 21:56
  • Not a solution, but only a workaround for me. You can overwrite the background using a white rectangle in: \AddToHook{shipout/background} {\begin{tikzpicture}[remember picture,overlay] \draw[draw=none,fill=white] (current page.north west) rectangle (current page.south east);\end{tikzpicture}} – Ivan Mar 21 '21 at 11:33