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 would like to put three pictures with sub-captions in two rows using the subfig package. I want to center the single picture in the second row. I use the following code :

\documentclass[12pt,leqno]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage{lmodern} 
\usepackage{graphicx}                 
\usepackage{float}
\usepackage{keyval,caption,subfig}
\captionsetup[subfigure]{%format=hang, singlelinecheck=false, font={tt,bf,sc}}
\newsubfloat[position=top,listofformat=subsimple]{figure}

\parindent 1cm
\parskip 0.2cm
\topmargin 0.2cm
\oddsidemargin 1cm
\evensidemargin 0.5cm
\textwidth 15cm
\textheight 21cm

\DeclareGraphicsExtensions{.png}

\begin{document}

\begin{figure}[H]%
\centering
\subfloat[First subtitle]{
\begin{picture}(226,139)
{\includegraphics{abra_1_a}}
\end{picture}
}
\qquad
\subfloat[Second subtitle]{
\begin{picture}(226,139)
{\includegraphics{abra_1_b}}
\end{picture}
}\\
\subfloat[Third subtitle]{
\begin{picture}(226,139)
{\includegraphics{abra_1_c}}
\end{picture}
}%
\caption{Assignment}
\end{figure}

\end{document}    

Result : The pictures appear in three rows.

Question : What is wrong in my code ?

share|improve this question

2 Answers 2

up vote 6 down vote accepted

Why do you use the picture environment? The following does what you require:

\documentclass[12pt,leqno]{book}
\usepackage[demo]{graphicx}                 
\usepackage{float}
\usepackage{subfig}

\begin{document}

\begin{figure}[H]%
\centering
\subfloat[First subtitle]{\includegraphics{abra_1_a}}\hfill%
\subfloat[Second subtitle]{\includegraphics{abra_1_b}}\\
\subfloat[Third subtitle]{\includegraphics{abra_1_c}}
\caption{Assignment}
\end{figure}

\end{document}

enter image description here

Using the optional argument of \includegraphics you can change the figure attributes, e.g.,

\includegraphics[width=.3\linewidth]{abra_1_a}

I used the demo option for graphicx to make my example compilable for everyone; do not use that option in your actual document.

share|improve this answer

There is no need for the picture environment. Use the width option

\documentclass[12pt,leqno]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage{lmodern} 
\usepackage[demo]{graphicx}% DELETE [DEMO] after trying
\usepackage{keyval,caption,subfig}
\captionsetup[subfigure]{format=hang, singlelinecheck=false, font={tt,bf,sc}}

\begin{document}
\begin{figure}
\centering
\subfloat[First subtitle]{\includegraphics[width=0.49\textwidth]{abra_1_a}}
\hfill
\subfloat[Second subtitle]{\includegraphics[width=0.49\textwidth]{abra_1_b}}

\subfloat[Third subtitle]{\includegraphics{abra_1_c}}

\caption{Assignment}
\end{figure}

\end{document}   

enter image description here

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.