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.

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....

share|improve this question
    
Welcome to TeX.SE. –  Peter Grill Nov 30 '12 at 6:19

1 Answer 1

up vote 9 down vote accepted

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}
share|improve this answer
    
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. –  barbara beeton Nov 30 '12 at 13:42
    
@barbarabeeton: Good point. Have updated solution. –  Peter Grill Dec 1 '12 at 7:51
    
Thankyou for this... –  Nicholas Hamilton Dec 9 '12 at 1:47

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.