2

This tex file generates a full-width image of a blue square on the second page, after a completely blank page. What causes the extra page and how to prevent it?

\documentclass{article}
\usepackage{graphicx}
\usepackage[margin=0cm]{geometry}
\usepackage{tikzpagenodes}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt}

\begin{document}
\begin{tikzpicture}
\node[inner sep=0pt] (blue) at (0,0)
{\includegraphics[width=\paperwidth]{b0.jpg}};
\end{tikzpicture}%
\end{document}

pdfTeX 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian)

pgf 3.0.1a

10
  • 1
    Is b0.png a blue square? Try replacing b0.jpg with example-image, do you see the same problem?
    – caverac
    Feb 11 '18 at 15:34
  • If the image is so high that it can't fit on the page, LaTeX will try and fail to place it on the first page, and then put it on the second page. What are the dimensions of that image? Feb 11 '18 at 15:38
  • @TorbjørnT. image dimensions are 150x200 pixels. Is there some way to force the first attempt?
    – M.T
    Feb 11 '18 at 15:41
  • Can't you just resize the image? If it's just a blue rectangle, then that shouldn't be a problem. Make sure the proportions are the same as that of the papersize (A4 or letter). But what is your purpose here? If you want a blue page, there is \pagecolor{blue}. Feb 11 '18 at 15:52
  • 1
    Try for example the methods described in tex.stackexchange.com/questions/167719/… Feb 11 '18 at 16:00
3

Try

\documentclass{article}
\usepackage{graphicx}
\usepackage[margin=0cm]{geometry}
\usepackage{tikzpagenodes}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt}
\usepackage{eso-pic}
\begin{document}
\AddToShipoutPictureBG*{%
 \AtPageLowerLeft{%
 \begin{tikzpicture}
\node[inner sep=0pt] (blue) at (0,0)
{\includegraphics[width=\paperwidth]{example-image-10x16}};
\end{tikzpicture}}}
%
~\clearpage
second page
\end{document}

If you really want only one page, remove \clearpage and the stuff below it.

1

i cant reproduce your problem ... if you like to have this picture on page center, see if this is what you looking for:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage[margin=0cm]{geometry}
\usepackage{tikzpagenodes}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt}

\begin{document}
\begin{tikzpicture}[remember picture,overlay]
\node[inner sep=0pt] (blue) at (current page.center) {\includegraphics[width=\paperwidth]{b0.jpg}};
\end{tikzpicture}%
\end{document}

you need to compile at least two times.

enter image description here

addendum: full page image:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage[margin=0cm]{geometry}
\usepackage{tikzpagenodes}
%\setlength{\parindent}{0pt}
%\setlength{\parskip}{0pt}

\begin{document}
\begin{tikzpicture}[remember picture,overlay]
\node[inner sep=0pt] (blue) at (current page.center) {\includegraphics[width=\paperwidth,height=\paperheight]{b0.jpg}};
\end{tikzpicture}%
\end{document}

enter image description here

2
  • I believe it is caused by height exceeding a certain value. Please tell me if you still cannot reproduce my issue once you set height=\paperheight
    – M.T
    Feb 11 '18 at 19:47
  • do you can't test this yourself? in my test this work fine, however not to forget to compile document at list twice :-)
    – Zarko
    Feb 11 '18 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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