3

I have a peculiar problem with my LaTeX document. I have a twocolumn document and would like to include a figure that is spread over an entire new page and contains a TikZ picture (where I can input a given JPG oder PDF image to fill the entire page and overlay it with a white box for the caption).

My failed attempts thus far include:

  • The wallpaper package, which unfortunately cannot place the image on a new page
    • Combining wallpaper with figure - doesn't appear to work either.
  • The \vspace option, which seems very messy. Basically it screws up the DPI of my image so in print the image pixels do not exactly overlap with the printer dots.
  • The afterpage package, but this doesn't work because my text is twocolumn and \afterpage apparently gets executed even after just a column break.
  • pdfpages but that won't let me overlay a caption box
    • pdfpages in combination with \usetikzlibrary[external] to output the TikZ pictures (background + caption) into a PDF and then include it again, but that doesn't seem to work because pdfpages will interrupt the text immediately, not wait and "float" the figure until after the current page.

Any idea would be greatly appreciated. Basically what I require would seem as simple as placing a command anywhere in the text, and after this page is done, I get a new clear page to place my TikZ picture in, and after that the normal text continues. However this appears impossible to achieve. Am I missing anything?

Thank you for your time,

A13

2

This solution will use a combination of atbegshi for its \AtBeginShipout routine to float the image to the next page in a proper manner; eso-pic for its \AddToShipoutPictureBG routine that will allow us to draw the full-screen pic in the background of the inserted page; and tikz to overlay the caption.

A new command is created:

New command to set full-page figure

Usage: \fullpagefig{<filename>}{<caption>}

The filename is sent directly to \includegraphics, and the caption is passed to \captionof from the caption package to create a caption that matches up with the rest of the figures.

The result, for adding a full-page-image somewhere in the first column of the first page, is a new second page as seen below:

page1

page2

page3

\documentclass[]{article}

\usepackage{multicol} % For two column
\usepackage{blindtext} % For dummy text

\usepackage{eso-pic}
\usepackage{caption}
\usepackage{tikz}
\usepackage{atbegshi}

% New command to set full-page figure
% Usage: \fullpagefig{<filename>}{<caption>}
\newcommand{\fullpagefig}[2]{%
\AtBeginShipoutNext{ % At the end of the page...
\AtBeginShipoutOriginalShipout\box\AtBeginShipoutBox % Ship the current page as is
\stepcounter{page} % Increment page counter to account for new page
% On next page, add the image in the background
\AddToShipoutPictureBG*{
\put(0,0){\parbox[b][\paperheight]{\paperwidth}{
\vfill\centering
\includegraphics[width=\paperwidth,height=\paperheight,keepaspectratio]{#1}
\vfill}}
% tikz picture to include the caption overlay
\begin{tikzpicture}[remember picture,overlay]
    \noindent\node[fill=white] 
    at (0.5\paperwidth,3cm) % placement from bottom-left corner of page
    {\begin{minipage}{3in} % width of the box
    % This will provide a caption numbered and styled like the rest of the figures
    \captionof{figure}{#2}
    \end{minipage}};\end{tikzpicture}
}\shipout\hbox{} % Make a blank page to put the picture on
}}

\begin{document}
\begin{multicols}{2}

\blindtext

{\LARGE Place on next page.}
\fullpagefig{example-image-9x16}{This is a caption of the full page diagram.}

\blindtext[4]

\end{multicols}
\end{document}

Edit: For twocolumn mode (instead of multicols)

The following code works for twocolumn mode in the same manner as above. Note, the two solutions do not seems to be interchangeable in either direction.

\documentclass[twocolumn]{article}

\usepackage{blindtext} % For dummy text

\usepackage{eso-pic}
\usepackage{caption}
\usepackage{tikz}
\usepackage{atbegshi}

% New command to set full-page figure
% Usage: \fullpagefig{<filename>}{<caption>}
\newcommand{\fullpagefig}[2]{%
\AtBeginShipoutNext{ % At the end of the page...
\AtBeginShipoutOriginalShipout\box\AtBeginShipoutBox % Ship the current page as is
% On next page, add the image in the background
\AddToShipoutPictureBG*{
\put(0,0){\parbox[b][\paperheight]{\paperwidth}{
\vfill\centering
\includegraphics[width=\paperwidth,height=\paperheight,keepaspectratio]{#1}
\vfill}}
% tikz picture to include the caption overlay
\begin{tikzpicture}[remember picture,overlay]
    \noindent\node[fill=white] 
    at (0.5\paperwidth,3cm) % placement from bottom-left corner of page
    {\begin{minipage}{3in} % width of the box
    % This will provide a caption numbered and styled like the rest of the figures
    \captionof{figure}{#2}
    \end{minipage}};\end{tikzpicture}}
\vbox{\thispagestyle{empty}}\clearpage % Make a blank page to put the picture on
}}

\begin{document}

\blindtext

{\LARGE Place on next page.}
\fullpagefig{example-image-9x16}{This is a caption of the full page diagram.}

\blindtext[7]

\end{document}
  • This seems to be almost perfect, thank you very much. I think I only have one issue: I cannot use multicols, I need to do it via twocolumns in \documentclass. For some reason the code produces an error and an empty additional page with just a page number after the figure. Would you happen to know why? In any case many thanks, I'm sure I can come up with a way to make this work based on your example! – A13 May 1 '14 at 12:43
  • @A13 I have added an edit to my original post. – cslstr May 1 '14 at 19:45
1

Does this help? The tikzpicture will sit behind the text if you don't put it on a new page.

\documentclass[a4paper]{article}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{multicol}
\usepackage{lipsum}
\begin{document}
\begin{multicols}{2}
\lipsum[1-5]
\newpage
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.center) 
    {\includegraphics[width=\paperwidth]{example-image-9x16}};
\node [fill=white] at (current page.center) {\Large caption text};
\end{tikzpicture}
\newpage
\lipsum[1-5]
\end{multicols}
\end{document}
  • Thank you for your reply. Unfortunately this will not exactly solve my problem. First of all I would get a forced page break in the middle of a text if I included this "figure" anywhere in the text. To avoid this I would manually have to place this at the very spot in the text where the page ends, and effectively I couldn't make any changes afterwards that affect the amount of text without repositioning the figures. Also, in ´twocolumn´ mode (not multicol) this leads to the figure overlapping with the text on the next page. However many thanks still. – A13 May 1 '14 at 12:30

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.