Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to insert a figure float in landscape orientation within an otherwise portrait-oriented document. The figure is inserting as it should, but for some reason it is obscuring a page of text where it is inserted.

For some context: I am using LyX (v2.03) and a custom template for my school's thesis formatting requirements (available from http://cpbl.wordpress.com/2010/01/24/ubc-thesis-under-lyx-manuscript-based-thesis-under-latex/). I have two other such landscape environments in an earlier chapter within the same document (one table, one figure), and neither of them gives the same problem. The same code was used for all three to insert the landscape page. When I put the 'problem figure' in the place of the well-behaved landscape figure it seems fine, but copying the earlier figure into the same place as the 'problem figure' somehow does give the desired result with no missing text. Gradually re-introducing elements from the 'problem figure' shows that putting a reference to this figure in the text gives the problem, but I'm not sure how to fix this (the 'well behaved' figure is also referenced in the text, in the same way and the with the same placement relative to the figure, with no issues). Placing the code for the figure at the end of the preceding subsection results in all of the text being shown properly, but this means that my figure shows up before any reference to it, which is something I was told to fix for an earlier figure. Similarly, placing the code for the figure at the start of the next subsection shows all of my text and gives the reference before the figure, but means that my figure shows up much later in the text than the discussion of this figure (not necessarily fatal to this solution, but certainly not ideal either). Again comparing this to the 'well behaved' figure, the code for this one is also inserted at the end of the subsection preceding where it is referenced, but in that case the float happens to give the appropriate order of reference and figure in the final document.

My question is; why am I losing this text, and why only in this case?

I have tried to make a MWE, but can't get the problem to repeat. The following might at least give some idea of what packages are being used and what I am trying to do:

\documentclass[british,english]{ubcthesis}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage{graphicx}
\makeatletter
\usepackage{lipsum}
\usepackage{ifthen}
\usepackage{afterpage}
\usepackage{pdflscape}
\usepackage{float}
\usepackage[unicode=true,
linktocpage,
linkbordercolor={0.5 0.5 1},
citebordercolor={0.5 1 0.5},
linkcolor=blue,breaklinks]{hyperref}
\makeatother
\usepackage{babel}

\begin{document}
\setboolean{@twoside}{false}

\chapter{Chapter 1}

\lipsum

\afterpage{\begin{landscape}
\begin{figure}
\includegraphics{fig.eps}
\caption{a landscape figure\label{fig:a-landscape-figure}}
\end{figure}
\end{landscape}
}

\lipsum
\ref{fig:a-landscape-figure}
\lipsum

\chapter{Chapter 2}

\lipsum

\afterpage{\begin{landscape}
\begin{figure}
\includegraphics{fig.eps}
\caption{another landscape figure\label{fig:another-landscape-figure}}
\end{figure}
\end{landscape}
}

\lipsum
\ref{fig:another-landscape-figure}
\lipsum
\end{document}
share|improve this question
2  
can't really help much given this amount of info but I would observe that inserting figures by \afterpage{\begin{landscape} \begin{figure} is a relatively fragile and scary operation (well it scares me anyway:-) Also it doesn't give much flexibility in figure positioning. It's almost certainly better to use rotating package and \begin{sidewaysfigure} without the afterpage and lscape code. –  David Carlisle Feb 23 '13 at 0:53
    
@DavidCarlisle that does indeed work better, and fixes the problem. (I'd still be curious to know what was going on with the original hacked-together version in case it comes up again, if anybody else has any ideas) –  SAKJ Feb 25 '13 at 18:10
add comment

1 Answer

up vote 1 down vote accepted
\afterpage{\begin{landscape} \begin{figure} 

is a relatively fragile and scary operation (well it scares me anyway:-) Also it doesn't give much flexibility in figure positioning.

It's almost certainly better to use rotating package and

\begin{sidewaysfigure}

without the afterpage and lscape code.

share|improve this answer
add comment

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.