2

I have several full-page figures in my LaTeX document that is based off of a two-sided book class. I would like to ensure that these figures are placed on the opposite page of where I first reference the figure using \ref{}, or at least on the opposite page of some possibly-manually-placed code that I can insert.

In other words, if my reference to Figure 5.3 would naturally appear on a "left" even page, I'd like the figure to appear on the corresponding "right" on page. It would also be fine if the figure and reference swapped pages, so long as they face each other.

What I don't want is for the reference and the figure to appear on the back & front of a single page. I don't want the reader to have to flip pages to see the full-page figure.

Here is a simple working example that has the figure on page 4, but the reference on page 3. The user would have to flip.

\documentclass[12pt,twoside]{book}
\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}

\Blindtext
\Blindtext
And this is a reference to Figure~\ref{myfig}.

\begin{figure}
\centering
\rule{6in}{8in}
\caption{Caption here.}
\label{myfig}
\end{figure}

\end{document}
  • 1
    Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Jul 17 '14 at 23:31
  • 1
    I think what you're asking is not possible in general without a fair bit of white space, as you are just swapping the two sides of one page. Specifically, assuming normal page numbers (even=left,odd=right) then a reference that would naturally appear on page 3 can either be on page 3 and have the float on page 4 (oops, that's no good) or you bring the float forward to page 3 and have the paragraph with the reference on page 4 (oops). If it is acceptable to page break before the reference then it could be on page 4 with the float on page 5. Or is it acceptable to have p3=ref, p5=float? – Andrew Kepert Jul 23 '14 at 8:37
  • 1
    Like Andrew Kepert, I suspect this is not possible. As I understand it, TeX will not know that your reference will be on page 3, say, until it typesets page 3. So there is no way for it to think on page 2 that it had better get the matching figure in now so it is ready for the reference on page 3. The only thing you could do would be to test whether you are on an odd or even page. If even, no problem, put the figure on the next page. If not, you'd need to page break before placing the reference and figure on opposite pages. Probably you could fill up the space remaining on the existing page. – cfr Jul 23 '14 at 22:36
2
+50

If you have the reference and the float in a odd page, it is easy left the reference just here and force the float to jump in the next (even) page with afterpage package. The problem is when you are in the even page, because you must move both the float and the reference.

Move the reference as a float is a headache because:

(a) the reference have only a logical place within the text: When the figure best illustrate your speech. The figure can be far from your arguments for formatting constrains (and only for this reason we use the references) but the reference cannot be moved freely above or below what are you explaining.

(b) Move freely a "standalone "reference to the next page as a float or with afterpage will break the flow of text, as in both cases can be placed in the middle of some paragraph, puzzling your text. But even when the reference is placed nicely between two paragraphs, a reference that surely is beside the point will destroy your discourse.

Therefore, IMHO, the best that a macro can do here is print the reference and the figure as usual, but including a warning when the reference is in the even page, so you can imagine how munch you must move your macro and what changes you will need in your surrounding text. Otherwise, the macro just print the reference exactly where you wanted and move the figure to the next even page.

An example: in the code below the reference is printed in page 2 (in blue, just to find it better) and the figure in page 3:

MWE

But if you remove one or two paragraphs in the first page (change \lipsum[1-5] by \lipsum[1-3]) so that the reference move to the page 1, then the reference is red and with a margin note:

MWE2

\documentclass[12pt,twoside]{book}
\usepackage{lipsum,xcolor} % for demo purposes only
\usepackage{afterpage}
\usepackage{graphicx}

\newcommand\FIGandREF[4]{
\ifodd\thepage  % if the wrong page ...
\marginpar{\color{red}{\bfseries WRONG PAGE}\\ Move    
this reference somewhere.}

\textcolor{red}{#1 Figure~\ref{#2}.}
\afterpage{
\clearpage  
\begin{figure}
\centering
\includegraphics[width=\textwidth,height=.8\textheight,keepaspectratio]{#3}
\caption{#4}
\label{#2}
\end{figure}
\clearpage  
}

\else  % in other case ... 
\textcolor{blue}{#1 Figure~\ref{#2}}.
\afterpage{
\clearpage  
\begin{figure}
\centering
\includegraphics[width=\textwidth,height=.8\textheight,keepaspectratio]{#3}
\caption{#4}
\label{#2}
\end{figure}
\clearpage  
}

\fi



}


\begin{document}

\lipsum[1-5]

\FIGandREF{And this is a reference to}{myfig}{example-image-10x16}{Caption here}

\lipsum[6-12]

\end{document}

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.