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.

I have prepared a series of macros in order to simplify the incorporation of pictures into long documents. All of them are based onthe MWE below. However I have just noticed that the text following the pictures is no longer justified properly on the right margin. What is the good way to correct this? Obviously I would like the macros calling pictures to be neutral regarding the surrounding text.

\documentclass [draft]{article}
\usepackage{lipsum}
\usepackage[draft]{graphicx} 
\newcommand{\ThreePicturesThreeCaptions}[7]{%
%Usage[7 arguments]{file1}{caption1}{file2}{caption2}{file3}{caption3}{global-caption}
\centering
\begin{figure}[htbp]
\centering
\begin{minipage}[b]{.3\textwidth}
\centering
\includegraphics[width=.98\linewidth] {#1}\caption {#2}
\end{minipage}
\begin{minipage}[b]{.3\textwidth}%
\centering
\includegraphics[width=.98\linewidth]{#3}\caption {#4}
\end{minipage}
\begin{minipage}[b]{.3\textwidth}
\centering
\includegraphics[width=.98\linewidth]{#5}\caption {#6}
\end{minipage}
\caption{#7}
\end{figure}
\raggedright
}%

\begin{document}
\lipsum[1]
\ThreePicturesThreeCaptions {144415-0009.jpg}{contacts \#22}{144615-0012.jpg}{contacts  \#16}{143207-0005.jpg}{\label{Quadrax}quadrax}{\label{ThreePictures}Typical picture layout generated for a laboratory report}
\lipsum[1]
\end{document}
share|improve this question
1  
Remove the first \centering at the beginning and the \raggedright at the end of your macro. –  cgnieder Aug 4 '13 at 10:22
    
It works... Can you please convert your suggestion into an answer, so I can close my question? –  Yves Aug 4 '13 at 10:33

1 Answer 1

up vote 5 down vote accepted

Your definition of \ThreePicturesThreeCaptions sets \centering before the {figure} environment and also (more important here) \raggedright after the {figure} environment. Both are not wanted. The effect of the \centering is cancelled by \raggedright, anyway, and \raggedright switches to -- well -- ragged right text. If you remove both everything should be fine.

\newcommand{\ThreePicturesThreeCaptions}[7]{%
  \centering % <= unwanted
  \begin{figure}[htbp]
  \centering
   ...
  \end{figure}
  \raggedright % <= unwanted
}
share|improve this answer

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.