latexsubfigure

How to disable scaling in the subfigure latex package?


I have some chemical structures with different image widths. As they can grouped thematically I want to place them within the same figure with subfigures. However, I want to present the images in their original size and don't want to apply any scaling on them.

Is this easily possible with the subfigure or subcaption or any similar package?

I calculated the scaling ratio by hand using the image widths. This is however not very handy and therefore I was looking for a automatic solution.

\begin{figure}
  \begin{subfigure}{0.4\textwidth}
    \input{width_2cm.pdf}
  \end{subfigure}
  \begin{subfigure}{0.6\textwidth}
    \input{width_3cm.pdf}
  \end{subfigure}
\end{figure}

Solution

  • If you just want to place your images besides each other, you don't need a subfigure at all.

    \documentclass{article}
    
    \usepackage{graphicx}
    \usepackage{geometry}
    
    \begin{document}
    
    \begin{figure}
      \includegraphics[scale=1]{example-image-1x1}
      \hfill
      \includegraphics[scale=1]{example-image-duck}
    \end{figure}
    
    
    \end{document}
    

    ([scale=1] is the default, I just included it for clarity)

    Or with captions:

    \documentclass{article}
    
    \usepackage{graphicx}
    \usepackage{geometry}
    \usepackage{subcaption}
    
    \begin{document}
    
    \begin{figure}
          \centering
          \subcaptionbox{A cat\label{cat}}
            {\includegraphics[scale=1]{example-image-1x1}}
            \hfill
          \subcaptionbox{An elephant\label{elephant}}
            {\includegraphics[scale=1]{example-image-duck}}
          \caption{Two animals}\label{animals}
    \end{figure}
    
    
    
    \end{document}