1

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}
JakobJakobson13
  • 135
  • 1
  • 4
  • 13
  • Can you share `width_2cm.pdf` and `width_3cm.pdf` to better understand your problem? Do you need captions for the subfigures? And can you please make a [mre]? – samcarter_is_at_topanswers.xyz Nov 04 '19 at 11:43
  • Why do you use \input on a pdf file? The standard way is to use \includegraphics. And by default, \includegraphics do not change image size. For the subfigures, you can use the subfig or subcaption package. But avoid the subfigure package; it is by the same author as subfig, and the author considers it as obsolete and recommands to use subfig instead. – Alain Merigot Nov 04 '19 at 12:01
  • @samcarter: The file width_2cm.pdf has a with of 2 cm, the file with_3cm.pdf has a width of 3 cm. Otherwise the file content is not important. – JakobJakobson13 Nov 04 '19 at 12:18
  • @AlainMerigot: You are right. The proper command is includegraphics that does not scale by default, but subcaption demands a given width of a subfigure. – JakobJakobson13 Nov 04 '19 at 12:21

1 Answers1

0

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}