# Text on the left, figure on the right

I have one technical text with the small figures, which must be placed on the right side of text. I tried manny solutions /wrapfig package, table, 2 columns package, etc./ but I can't get this to work. When the picture gets too low, it is drawn in the footer area.

So I'm starting from blank. What should I use to write text with the following specifications:

1. Text /TEXT/ should be placed on the left side and the picture /FIG/ should be placed on the right - not up, not down and certainlly not the next page from the TEXT - should start on the SAME page. Pictures are small (cca. 5 cm, and the text should be in the landscape mode). The TEXT may be one paragraph or more so it is desirable (but not required) to stay in the left place, while figures stays on the right.

2. When the FIG gets placed too low on the page, so it gets drawn over the bottom text margin, both TEXT and FIG should start on the next page, while leaving empty space on the bottom of the page /no vertical aligning/.

3. The whole process of aligning must be automatic, so when I replace picture with slightly larger one, the whole process must be handled automatically /no manual pagebreaks and stuff/.

4. The TEXT may or may not flow around the FIG, but the margins must be rellatively small /5mm/.

How can I do that?

-
This seems to be multiple questions, so you may want to think about breaking these down and asking a single one at a time (and checking for pre-existing answers). For point one, you have not been clear enough. Do you want two columns, with on just for figures and the other for text, or do you want the text to wrap? In the latter case look into the wrapfig package. –  qubyte Feb 26 '12 at 13:48
On the other hand, point two makes it look like you want a side caption, in which case you should look into the (surprise) sidecap package. –  qubyte Feb 26 '12 at 13:50
Left column for text, right for figures /and I mention I used wrapfig package but because of errors I want to start from blank/. I tried asking the separate questions, but the combination of answer doesn't give me the solution. So I must ask the long question. The main thing is that the figure gets into the fotter area, but that is what I don't want to. So I must put the text and figure on the next page. –  B.T. Feb 26 '12 at 13:53
It'd be best if you put some code that you've tried into the question, or some mock-up pictures of what you want as a descriptive aid. –  qubyte Feb 26 '12 at 14:00
having worked on a similar problem for several books, i can say that it's very difficult to do this entirely automatically. is it permissible, when nearing the bottom of the page, to leave a short page if the next paragraph will contain a figure? if so, and you know the height of the next figure, it may be possible to take advantage of the needspace package. –  barbara beeton Feb 26 '12 at 14:01

From my experience, this type of design never works well by using packages. You rather build your own code around your requirements. Here is an example with rather large figures, that illustrate some of the issues (the code is in the MWE below).

Here the text is positioned either left or right depending if the page is odd or even. as you observe the height of the text is not right. So my suggestion rather describe your requirements first visually (perhaps by lifting ideas from a book you like or an article), then see how this will work in the overall deign of the class you are using.

\documentclass[imperial]{octavo}
\usepackage{geometry}
%\usepackage{textsamples}
\usepackage{graphicx,xcolor}
\usepackage{changepage}
\newcommand\lorem{Fusce adipiscing justo nec ante. Nullam in enim.
Pellentesque felis orci, sagittis ac, malesuada et, facilisis in,
ligula. Nunc non magna sit amet mi aliquam dictum. In mi. Curabitur
sollicitudin justo sed quam et quadd. \par}
\begin{document}
\newpage

\newgeometry{left=10mm,right=10mm,top=1.0cm,bottom=1cm}
%%%%%%%%%%%  RENOIR NARROW
\def\ballatbougival{ballatbougival}
\def\ballatbougivalcaption{\lorem\lorem}
\def\ballatbougivaltitle{{\large\bf Ball at Bougival}}
\checkoddpage
\begin{minipage}[c]{\textwidth}%
\fboxrule0pt%
\fboxsep1pt%
\fbox{%
\ifoddpage\relax\else%
\begin{minipage}[b]{110pt}%
%% odd caption is placed at bottom
\ballatbougivaltitle\par%
\ballatbougivalcaption%
\the\textwidth\rule{0pt}{180pt}
\end{minipage}%
\fi%
\begin{minipage}[b]{\the\dimexpr(\textwidth-150pt)}%
\includegraphics[width=\textwidth]{./graphics/\ballatbougival}
\end{minipage}\hspace*{10pt}%
\ifoddpage%
\begin{minipage}[b]{110pt}%
%% odd caption is placed at bottom
\ballatbougivaltitle\par%
\ballatbougivalcaption%
\the\textwidth\rule{0pt}{180pt}
\end{minipage}%
\fi
}
\end{minipage}
\clearpage

%%%%%%%%%%%  RENOIR NARROW
\def\ballatbougival{ballatbougival}
\def\ballatbougivalcaption{\lorem\lorem}
\def\ballatbougivaltitle{{\large\bf Ball at Bougival}}
\checkoddpage
\begin{minipage}[c]{\textwidth}%
\fboxrule0pt%
\fboxsep0pt%
\fbox{%
\ifoddpage\relax\else
\begin{minipage}[b]{110pt}%
%% odd caption is placed at bottom
\ballatbougivaltitle\par%
\ballatbougivalcaption%
\the\textwidth\rule{0pt}{180pt}
\end{minipage}%
\hspace*{10pt}%
\fi%
\begin{minipage}[b]{\the\dimexpr(\textwidth-130pt)}%
\includegraphics[height=\textheight, width=\textwidth, keepaspectratio]{./graphics/Pierre-Auguste_Renoir_019}%
\end{minipage}%
\ifoddpage%
\hspace*{10pt}%
\begin{minipage}[b]{110pt}%
%% odd caption is placed at bottom
\ballatbougivaltitle\par%
\ballatbougivalcaption%
\the\textwidth\rule{0pt}{180pt}
\end{minipage}%
\fi
}
\end{minipage}
\end{document}


As you will observe from the code, the image and caption is placed within minipages, so effectively ensuring that it stays together. If you want them to float, enclose them in

\begin{figure}...\end{figure}


If you want numbered captions or the captions to go to the contents, you can style them, using the caption package.

Minor adjustments on the position of text, you can add rules (make them invisible using a zero width or add space via vspace).

Although this might appear as tedious and requiring a lot of work to set up, for a book at most you will have about 3-5 layout designs. Once you are happy you can change everything to environments or macros to make life easier.

-

Without a MWE it's hard to know why wrapfig isn't working for you. In the document below with 14 lines, the second 'figure' goes to the second page, if you increase that to 15 lines, it comes back to the first page along with the adjacent text lines.

EDIT example updated to address barbara's case, using e-tex widow penalty control.

\documentclass[draft]{article}

\usepackage{lipsum,wrapfig}
\setlength\intextsep{0pt}
\textheight15\baselineskip

\makeatletter
\def\widows{%
\count@-\c@WF@wrappedlines
\ifnum\count@>\z@
\edef\@tempa{\widowpenalties \the\count@\space}
\loop
\ifnum\count@>\z@
\edef\@tempa{\@tempa 10000\space}%
\repeat
%\show\@tempa
\@tempa
\fi}
\makeatother
\begin{document}

\begin{wrapfigure}{r}{0pt}
\fbox{\parbox{2cm}{a\\b\\c}}
\end{wrapfigure}\widows
\lipsum[1]

\begin{wrapfigure}{r}{0pt}
\fbox{\parbox{2cm}{a\\b\\c\\d}}
\end{wrapfigure}\widows
\lipsum[1]

\end{document}

-
if you change the \textheight to 15, and you change the contents of the \parbox to be 4 lines long, you'll see why this doesn't work. –  barbara beeton Feb 26 '12 at 17:15
@barbarabeeton example extended to address this case –  David Carlisle Feb 26 '12 at 18:32
that did it. might want to take out the \show for actual compilation. –  barbara beeton Feb 26 '12 at 18:40
@barbarabeeton oops, edited, I did take most of the \show out, one got away... –  David Carlisle Feb 26 '12 at 18:41