1

In the following pictures How to get the two captions horizontally aligned while keeping the top alignment of the two figures unchanged ?

enter image description here

\documentclass[draft]{article}
    \usepackage{tcolorbox,caption}
    \tcbset{sidebyside,
            center upper,
            center lower,
            colbacktitle=red!50,
            coltitle=black,
            fonttitle=\sffamily\bfseries\large}
    \begin{document}
        \begin{tcolorbox}[sidebyside align=top seam,
                        title=The captions are not aligned]
                \includegraphics{file1.png}
                \captionof{figure}{file1}
            \tcblower
                \includegraphics[scale=1.5]{file2.png}
                \captionof{figure}{file2}
        \end{tcolorbox}
        \vspace{2cm}
        \begin{tcolorbox}[sidebyside align=bottom seam,
                        title= The figure's top borders are not aligned
                        ]
                \includegraphics{file1.png}
                \captionof{figure}{file1}
            \tcblower
                \includegraphics[scale=1.5]{file2.png}
                \captionof{figure}{file2}
        \end{tcolorbox}

    \end{document}
2

In this case I think it's better to avoid sidebyside option and use a tabularx inside the tcolorbox to organize figures and captions or declare them inside a tcboxedraster or tcboxeditemize with equal height rows.

\documentclass[draft]{article}
\usepackage[most]{tcolorbox}
\usepackage{capt-of, tabularx}

\newcolumntype{Y}{>{\centering\arraybackslash}X}
\tcbset{colbacktitle=red!50,
        coltitle=black,
        fonttitle=\sffamily\bfseries\large}
\begin{document}
\begin{tcolorbox}[title=The captions are not aligned]
    \begin{tabularx}{\linewidth}{YY}
        \vspace{0pt}\includegraphics{file1.png} & 
        \vspace{0pt}\includegraphics[scale=1.5]{file2.png}\\
      \captionof{figure}{file1} &\captionof{figure}{file2}
    \end{tabularx}
\end{tcolorbox}

\begin{tcboxeditemize}[blankest, halign=center, valign=top, raster equal height=rows]{title=The captions are not aligned}
    \tcbitem \includegraphics{file1.png} 
    \tcbitem \includegraphics[scale=1.5]{file2.png}
    \tcbitem \captionof{figure}{file1} 
    \tcbitem \captionof{figure}{file2}
\end{tcboxeditemize}

\end{document}

enter image description here

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