0

I have a followup question to the previously provided answer. Since my text is NOT fixed and might change dynamically I have problems to center the watermark in the middle of the page

\documentclass{article}
\usepackage{pdfpages,xcolor}
\usepackage{eso-pic}
\usepackage{kantlipsum}
\usepackage[Export]{adjustbox} 
\usepackage{transparent} % used in watermark
\AddToShipoutPictureFG{
    \AtPageCenter{
    {
        \rotatebox[origin=c]{55}{
            \adjustbox{cfbox=red {\fboxrule} 5mm, width=28cm, min height=2cm, max height=2cm}
            {\transparent{0.3}\fontsize{3cm}{3cm}\bfseries\textcolor{red}{
                    %DRAFT%
                    Automatischer Text%
            }}
        }
    }
}
}
\begin{document}
\kant
\end{document}

end up with something like enter image description here

I know I use some \put to adjust the rotated box but this is dependent on the length of the text. Basically I want to have the center of the rotated in the middle of the page. Various attempts of using \AtPageCenter, \AtPageLowerLeft failed as well to specify the origin of the \rotatebox. The angle of 55° fits well for a A4 paper.

Any hints how to solve it?

BTW: Using lualatex 1.16.

LeO
  • 1,451

1 Answers1

2

\AtPageCenter places the left edge there, not the whole box. You can use \makebox to really center it. Also, remember that any line which ends with a brace adds a space.

\documentclass{article}
\usepackage{pdfpages,xcolor}
\usepackage{eso-pic}
\usepackage{kantlipsum}
\usepackage[Export]{adjustbox} 
\usepackage{transparent} % used in watermark
\AddToShipoutPictureFG{
    \AtPageCenter{%
    {%
        \makebox[0pt]{\rotatebox[origin=c]{55}{
            \adjustbox{cfbox=red {\fboxrule} 5mm, width=28cm, min height=2cm, max height=2cm}
            {\transparent{0.3}\fontsize{3cm}{3cm}\bfseries\textcolor{red}{
                    %DRAFT%
                    Automatischer Text%
            }}%
        }}%
    }%
}
}
\begin{document}
\kant
\end{document}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • Thx for providing a full example. This works :-) – LeO May 09 '23 at 13:28
  • Another way is the package "background". – jotagah May 09 '23 at 13:40
  • I've linked my previous question as well. I have suffered quite some performance issue and found this solution upon recommendation. But I have to confess - I didn't run performance measurements with background at the time - especially since I found this solution. Would be interesting to see what difference it has nowadays. – LeO May 10 '23 at 15:14