2

So I am limited via some style doc on how image elements with captions look like:

some code like in here does what they do:

\renewcommand{\@makecaption}[2]{%
\abovecaptionskip=-5pt
\belowcaptionskip=-27pt
\vspace{\abovecaptionskip}%
\sbox{\@tempboxa}{{\footnotesize {\textbf{#1.}} #2}}
\ifdim \wd\@tempboxa > \hsize
    \begin{center} {\footnotesize {\textbf{#1.}} #2} \par \end{center}
\else
    \global\@minipagefalse
    \hbox to \hsize {\footnotesize \hfil{\textbf{#1.}} #2\hfil}%
\fi
\vspace{\belowcaptionskip}}

\newcommand{\Figure}[3]{\begin{figure}[h]\begin{center}\includegraphics[width=#1]{#2}\caption{#3\vspace{ 1cm}}\end{center}\end{figure}}

\newcommand{\WrapFigure}[5]{\begin{wrapfigure}[#1]{l}{#2}
\includegraphics[width=#3]{#4}\caption{#5}
\end{wrapfigure}\vspace{0.3cm}}

\newcommand{\WrapFigureR}[5]{\begin{wrapfigure}[#1]{r}{#2}
\includegraphics[width=#3]{#4}\caption{#5}
\end{wrapfigure}\vspace{0.3cm}}

I want to place 2 images with captions like in here:

enter image description here

I tried this:

\begin{center}
\begin{array}
\Figure{0.6\textwidth}{d2.eps}{ ~ \label{fig4}} &
\Figure{0.6\textwidth}{d1.eps}{ ~ \label{fig5}} 
\end{array}
\end{center}

But failed. So how to make two custom image layout elements live in one row?

3

One option would be to use two minipages and the \captionof command provided by the caption package; the justification=centering option will cause each line of the captions to be centered:

\documentclass{article}
\usepackage{caption}
\usepackage[demo]{graphicx}

\captionsetup[figure]{justification=centering}

\begin{document}

\begin{center}
\begin{minipage}{.45\textwidth}
\centering
\includegraphics[width=.8\linewidth]{name1}
\captionof{figure}{A test caption for the first of two figures}
\end{minipage}\hfill
\begin{minipage}{.45\linewidth}
\centering
\includegraphics[width=.8\linewidth]{name2}
\captionof{figure}{A test caption for the second of two figures}
\end{minipage}
\end{center}

\end{document}

enter image description here

With this approach, the figures won't be treated as a floating object so their placement will be your responsability. If you want the object to be treated as a floating object, simply use minipages inside a figure environment and the standard \caption command; once again, the justification=centering option from the caption package will cause each line of the captions to be centered:

\documentclass{article}
\usepackage{caption}
\usepackage[demo]{graphicx}

\captionsetup[figure]{justification=centering}

\begin{document}

\begin{figure}
\centering
\begin{minipage}{.45\textwidth}
\centering
\includegraphics[width=.8\linewidth]{name1}
\caption{A test caption for the first of two figures}
\end{minipage}\hfill
\begin{minipage}{.45\linewidth}
\centering
\includegraphics[width=.8\linewidth]{name2}
\caption{A test caption for the second of two figures}
\end{minipage}
\end{figure}

\end{document}

The demo option for graphicx was only used to replace actual images with black rectangles; do not use that option in your actual code.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.