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.

How can I position a figure (picture) so that it:

  • is aligned on the left-hand side with the text (this is in two column page)
  • touches (or exceeds) the right-hand side of the page?

An example can be found here: http://library.fes.de/pdf-files/akademie/berlin/04801.pdf (go to any page with a picture and see how the picture is placed.) Note: The example is not what I would call pretty; I think the design is hideous. None the less, I'd like to know how to accomplish this style design for pictures.

share|improve this question
    
See Place figures side by side, spill into outer margin. You need to use \makebox[\columnwidth][r]{\includegraphics[width=\dimexpr\columnwidth+\rightmar‌​gin\relax]{image}} in this case. I'm not sure about the margin length, though. –  Martin Scharrer May 13 '11 at 15:50
    
@Martin: sorry, but \rightmargin is definitely wrong; it's a parameter for lists. –  egreg May 13 '11 at 16:19
    
@egreg: Indeed, but the principle stands. –  Martin Scharrer May 13 '11 at 16:25
add comment

1 Answer 1

up vote 5 down vote accepted
\documentclass[a4paper,twocolumn]{article}
\usepackage{lipsum,graphicx}
\newcommand{\mydimright}{%
  \dimexpr\paperwidth-1in-\hoffset-\oddsidemargin-
  \columnwidth-\columnsep\relax}
\newcommand{\mydimleft}{%
  \dimexpr1in+\hoffset+\oddsidemargin+\columnwidth\relax}

\begin{document}
\lipsum[1]
\begin{flushleft}
\makebox[\columnwidth][r]{%
\includegraphics[height=1cm,width=\mydimleft]{try}}
\end{flushleft}
\lipsum[1-5]
\begin{flushleft}
\makebox[\columnwidth][l]{%
\includegraphics[height=1cm,width=\mydimright]{try}}
\end{flushleft}
\end{document}

There is no immediate access to the right margin width, which has to be computed in an indirect way.

With the command \layout of the layout package, one can look at the relevant lengths. I've put also \hoffset, because some classes might change it.

Here try is the graphic file I always use for tests. I've used flushleft just in order to avoid LaTeX trying to be smart with figure placement.

-- Extended version for automatic placement in the figure environment --

Here it is, following Martin's suggestion; the command \touchmarginincludegraphics works like its sibling \includegraphics except, of course, that the keyword width should not be specified.

\documentclass[a4paper,twocolumn]{article}
\usepackage{lipsum,graphicx}

\makeatletter
\def\tmig@r{\dimexpr\paperwidth-1in-\hoffset-
  \oddsidemargin-\columnwidth-\columnsep\relax}
\def\tmig@l{\dimexpr1in+\hoffset+\oddsidemargin+\columnwidth\relax}
\newcommand{\touchmarginincludegraphics}[2][]{%
  \begingroup
  \if@firstcolumn
    \def\tmig@place{r}%
  \else
    \def\tmig@place{l}%
  \fi
  \makebox[\columnwidth][\tmig@place]{%
    \includegraphics[#1,width=\@nameuse{tmig@\tmig@place}]{#2}}
  \endgroup}
\makeatother

\begin{document}
\lipsum[1]

\begin{figure}[!h]
\touchmarginincludegraphics[height=1cm]{try}
\end{figure}

\lipsum[1-4]

\begin{figure}[!h]
\touchmarginincludegraphics[height=1cm]{try}
\end{figure}

\lipsum[2]
\end{document}
share|improve this answer
    
The images in the linked PDF look like floats to me. You might want to update your code to insert \begin{figure}[t] and use \if@firstcolumn to select the direction. –  Martin Scharrer May 13 '11 at 16:27
    
@Martin: I've added the code, thanks for suggesting \if@firstcolumn. –  egreg May 13 '11 at 17:05
    
Thank you, that works! I removed the height=1cm option, that makes the aspect ratio stay. –  Unapiedra May 14 '11 at 15:09
    
@Unapiedra: Yes, the height=1cm was there just to make a one page example with figures in both columns. –  egreg May 14 '11 at 16:56
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.