5

I would like to place an overlay picture on a page without disturbing the rest of the page's content. However, when I put the source code for the overlay picture above or below a section command, either the section header or the following text are shifted downward.

Can this be circumvented? Or is there maybe another, entirely different way for placing additional text above/below the regular page content?

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[remember picture,overlay] 
\draw [line width=1mm,opacity=.25] (current page.center) circle (3cm); \end{tikzpicture}

\section{Section}

\begin{tikzpicture}[remember picture,overlay] 
\node [rotate=60,scale=10,text opacity=0.2] 
    at (current page.center) {Example};
\end{tikzpicture}

Both, the section header and this text, are shifted because of the overlay TikZ pictures.

\end{document}
2

2 Answers 2

2

Even though a tikzpicture with overlay has zero size, it's still there, as far as TeX is concerned. So you have "something" on a line, then \section, which starts a new paragraph. After the \section you again have something, then a paragraph break, then the text. If you place both tikzpictures immediately before the text after \section, without any spaces or empty lines, you'll get what you're after. Or just as well, use just one tikzpicture.

The frame is from the showframe package.

enter image description here

\documentclass{article}
\usepackage{tikz,showframe}

\begin{document}


\section{Section}

\begin{tikzpicture}[remember picture,overlay] 
\draw [line width=1mm,opacity=.25] (current page.center) circle (3cm);
\node [rotate=60,scale=10,text opacity=0.2] at (current page.center) {Example};
\end{tikzpicture}% <- end of line comment to remove space from newline
No spaces or paragraph breaks around the tikpicture, so no apparently empty lines, and thus no shifting.

\end{document}
2

A viable solution is to use the background package:

\documentclass{article}
\usepackage{tikz, showframe}
\usepackage[pages=some]{background} 

\begin{document}

\backgroundsetup{opacity=1, scale=1, angle=0, contents={%
    \begin{tikzpicture}[remember picture,overlay]
    \draw [line width=1mm,opacity=.25] (current page.center) circle (3cm);
    \node [rotate=60,scale=10,text opacity=0.2] 
        at (current page.center) {Example};
    \end{tikzpicture}}}
\BgThispage

\section{Section}

Neither the section header nor this text are shifted because of the overlay TikZ pictures.

\clearpage
No background on this page.

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .