The reason has to do with an oversize image. As LaTeX cannot fit it on a page it will float to the end. These type of figures are best to insert them manually
. You will need to define a different environment for this. Try modifying the \twopagepicture
by copying it a renaming it and just comment out the begin{figure}
and \end{figure}
.
\newcommand*{\twopagepicture}[4]{% copy twopagepicture an comment out
.....
% \begin{figure}[#1]
....
% \end{figure}%
% \begin{figure}[#1]
.....
% \end{figure}%
......
}
This ensures that the images will be shown exactly where placed.
To have a correctly placed two page spread firstly, one needs a method to clear to an even page, normally I would code it as follows:
\usepackage[strict]{changepage}
\makeatletter
\newcommand{\cleartoevenpage}{%
\clearpage%
\ifoddpage\c@page\hbox{}\clearpage\fi}
The second issue to take into consideration, is that the image width is always larger than the \textwidth
dimension and hence any scaling must be done on the \textheight
. This is important, otherwise you will get a new page.
The even page image is simply placed normally but issuing a \cleartoevenpage
before the placement and a \newpage after
it, producing the image shown above.
\cleartoevenpage
\includegraphics[height=0.95\textheight]{petra}
\newpage
The odd page image, will have to be shifted to the left by \textwidth
.
\hspace*{-\textwidth}\includegraphics[height=0.95\textheight]{petra}\hspace{1em}
The caption can be placed using a parbox
or a minipage
. In this case I have used a parbox
. If your captions will have more than a paragraph of text, then use a minipage. Depending on the amount of text you have it may look better if you shift it slightly up or down. This can be done either using a vspace
command or use a rule (I prefer the latter as I can have a visual clue and only zero the width at the final copy).
\parbox[b]{0.25\textwidth}{\lipsum*[1-2]\par\rule{1pt}{50pt}}
You can see the rule in the last image below.
Full MWE
\documentclass{book}
\usepackage[left=0pt,right=0pt,top=0.5in,bottom=0.5in]{geometry}
\usepackage{graphicx,lipsum,caption,crop}
\usepackage[strict]{changepage}
\makeatletter
\newcommand{\cleartoevenpage}{%
\clearpage%
\ifoddpage\c@page\hbox{}\clearpage\fi}
\begin{document}
First page
\cleartoevenpage
\includegraphics[height=0.95\textheight]{petra}
\newpage
\hspace*{-\textwidth}\includegraphics[height=0.95\textheight]{petra}\hspace{1em}
\parbox[b]{0.25\textwidth}{\lipsum*[1-2]\par\rule{1pt}{50pt}}
\end{document}
Hope this helps.
You shouldn't be using subfigure
, but either subfig
or subcaption
.
Here's the version for subfig
:
\documentclass{article}
\usepackage[demo]{graphicx} % demo is just for the example
\usepackage{subfig}
\begin{document}
\begin{figure}
\centering
\subfloat[]{\includegraphics[width=2in]{Figure 2a.png}}\quad
\subfloat[]{\includegraphics[width=2in]{Figure 2b.png}}
\caption{FE model geometry and boundary conditions; (a)~tension\slash compression,
(b)~simple shear}\label{fig:FEmodel}
\end{figure}
\end{document}
Note that the enclosing \mbox
is not needed.
A very similar output is obtained with subcaption
:
\documentclass{article}
\usepackage[demo]{graphicx} % demo is just for the example
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}{2in}
\centering
\includegraphics[width=2in]{Figure 2a.png}
\subcaption{}
\end{subfigure}\quad
\begin{subfigure}{2in}
\includegraphics[width=2in]{Figure 2b.png}
\subcaption{}
\end{subfigure}
\caption{FE model geometry and boundary conditions; (a)~tension\slash compression,
(b)~simple shear}\label{fig:FEmodel}
\end{figure}
\end{document}
Best Answer
Since the default behaviour is to typeset the caption text and numbering together, rather than break them apart, your hack works. It may just seem awkward since you're using
\caption
without actually giving a caption.To that end, you could define "more convenient" commands that would do the same:
The above example uses the
caption
package to format the float captions via key-value pairs. As such, you can use these key-values to format the separate components of the caption. I've defined\floattitle{<title>}
which typesets the float title using\captiontextfont
(it also stores<title>
for later use). It also adds a gap at below the caption that is equivalent to the gap above the "actual caption" below the image. Also\floatnumber
is a duplicate of\caption{}
, which typesets nothing, but adds the correct reference test so you're able to use\listoffigures
and/or\listoftables
. Note that the command names are general, so you can use them in either afigure
or atable
environment.Finally, for correct referencing, you need to place the
\label
after\floatnumber
(or\caption
in general). See Where to put the \label on a figure environment?graphicx
with thedemo
option was used to be able to typeset an imageimage
without it actually being there - replacing it by a 150pt x 100pt rectangle. Don't use thedemo
option otherwise.