The following MWE displays my problem. If I tex it twice I get two pages. The text on the two pages do not begin from the same vertical distance from the top of the page. So it appears that 9. (which happens to be the start of page 2) is higher up the page than 1 as shown in the image composition below.

enter image description here

If the tikzpicture environment is commented out then it works.

Two questions:

1: What's going on here? I assumed that the options [remember picture,overlay] don't affect the rest of the page (whereas they obviously do)

2: How to best solve this issue of adding a logo on a page and not affect anything else?

\documentclass[12pt]{article}
\usepackage[demo]{graphicx}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west] at (current page.north west) {\includegraphics[height=3\baselineskip]{image.png}};
\end{tikzpicture}%

\begin{enumerate}
\item This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. 

\item This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. 

\item This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. 

\item This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. 

\item This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. 

\item This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. 

\item This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. 

\item This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. 

\item This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. 

\item This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. 

\end{enumerate}

\end{document}
share|improve this question
    
You have a paragraph break between the zero-size box that is the tikzpicture and the start of the list. Should the logo be only on this one page? – Torbjørn T. 5 hours ago
    
@TorbjørnT. Yes, the idea is to have the logo only on page 1. – Geoff 5 hours ago
up vote 5 down vote accepted
  1. What's going on here?

    The problem is related to the way pages are built and the particular case in which the page starts with a list (enumerate in your case).

    The trick that TikZ overlay uses is to typeset all its contents in a box of zero width and height, so that the content of that box does not "take space" at TeX eyes, and thus it is "overlaped" on top of its surroundings.

    The problem is that, when a page starts, TeX is in "vertical mode" and even if you insert an empty box, this makes TeX to leave vertical mode, because this first box (even if empty) is considered the beginning of a new paragraph. You can produce the same effect by replacing your tikzpicture by a \leavevmode command.

    If the next tokens after that are part of a "regular" paragraph, there is no noticeable effect. Only, that first paragraphs begins with an empty box which does not alter the paragraph indentation or shape. However, if the next token after the empty box is a list (enumerate in your case), LaTeX inserts a vertical space to separate it from previous paragraph. Usually, when vertical space is the first thing appearing in a page, it is discarded, but it is not your case, since you already have a previous empty box, produced by TikZ.

  2. How to solve it?

    I tried including some \unskip before the enumerate or inside it, without results. I don't really understand what \unskip does, but apparently it has no effect once the empty box was added, so a different approach is required.

    The trick is to avoid issuing the tikz environment as the first thing in the page. Note that, since you are using absolute coordinates inside it, it doesn't really matters where you put the code, as long as it is executed before the current page is shipped out. You could put it after the first \item, for example.

    As a more general solution, you can use the package atbegshi which allows you to add code to a page when it is ready to be shipped out. The command \AtBeginShipoutFirst{} adds the code to the first page on the document. If you want the logo on every page use \AtBeginShipout{} instead. If you want it only in some particular pages, use \AtBeginShipoutNext{} on those pages.

Using this idea, your example will be:

\documentclass[12pt]{article}
\usepackage[demo]{graphicx}
\usepackage{atbegshi}
\usepackage{tikz}

\AtBeginShipoutFirst{
\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west] at (current page.north west) {\includegraphics[height=3\baselineskip]{image.png}};
\end{tikzpicture}
}

\begin{document}

\begin{enumerate}
\item This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. 

\item This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. 

\item This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. 

\item This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. 

\item This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. 

\item This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. 

\item This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. 

\item This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. 

\item This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. 

\item This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. 

\end{enumerate}
\end{document}

Resulting in:

Result

share|improve this answer
    
Many thanks for the in depth answer! It works like a charm. – Geoff 3 hours ago

For me it works and the document has two pages regardless of adding tikzpicture or not. From my experience overlays generated by tikz do not alter the page layout (as thez should) but sometimes require additional compilation runs.

For consistency I would however consider to add the logo to page header. solution to this idea are proposed here and here. I you do not want it on every page you could add above a chapter heading, see here.

EDIT: I see the offset too, so I have to revise my prior statement.

share|improve this answer
    
Two pages are fine, it's where the text begins on each page that is inconsistent (at least for me). – Geoff 5 hours ago
2  
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review – samcarter 2 hours ago
    
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review – Romain Picot 35 mins ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.