7

Lets say that I want to create a feature environment, which has two columns, in one column there is a picture (with a caption), in the second there is text. For the odd pages, I want the picture on the left, text on the right, and, for the even pages, I want the text on the left, picture on the right.

What is the best way to achieve this, Does someone have an example?

I have something working, using tikz, but the code is messy (lots of manual tweaking on a case-by-case basis). I am sure a cleaner example exists....

1

1 Answer 1

9

You can use the changepage package to detect if it is an odd or even page, and switch the order you place things:

enter image description here

Notes:

  • Text block near image shows how to use tikz to place text at the appropriate points relative to the image.

Code:

\documentclass{article}
\usepackage[paperwidth=9.0cm, margin=0.5cm]{geometry}% For better illustrative image
\usepackage{graphicx}
\usepackage{array}
\usepackage{booktabs}

\usepackage{changepage}
\strictpagecheck

\newcommand*{\ImageSize}{3.5cm}%  Set the width of the images here

\newcommand*{\TextSize}{\dimexpr\linewidth-\ImageSize-4\tabcolsep}%
\newcommand{\MyTwoColumn}[2]{%
\medskip\par\noindent%
\centering\checkoddpage%
    \noindent
    \ifoddpage
        \begin{tabular}{m{\ImageSize}m{\TextSize}}\toprule
        \includegraphics[width=\ImageSize]{#1} &  {\raggedright#2\par} \\
    \else
        \begin{tabular}{m{\TextSize}m{\ImageSize}}\toprule
        {\raggedright#2\par} & \includegraphics[width=\ImageSize]{#1}\\
    \fi\bottomrule
\end{tabular}%
\medskip\par%
}

\begin{document}
\MyTwoColumn{../images/EiffelWide}{Awesome Vacation on left page}
\clearpage
\MyTwoColumn{../images/EiffelWide}{Awesome Vacation on right page}
\end{document}
2
  • the picture on the right in the graphic is indented more from the edge than the one on the left. better if the spacing is a mirror image. Nov 30, 2012 at 13:42
  • @barbarabeeton: Good point. Have updated solution. Dec 1, 2012 at 7:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .