0

I have two figures which I have already combined next to each other (horizontally) into one .eps figure via Stata. How do I now use the subfigure command to label both separately (horizontally). Leaving out the /includegraphics command twice within subfigure command (as I have already inserted the combined graph using includegraphics) does not give me the desired result. Is this not possible? Any work around?

\documentclass[11pt]{article}
\usepackage{setspace,graphicx,epstopdf,amsmath,amsfonts,amssymb,amsthm,versionPO}
\usepackage[utf8x]{inputenc}
\usepackage{graphicx}
\usepackage{epsfig}
\begin{figure}[htb]%
    \centering
    \includegraphics[width=7in]{Figure1.eps}
    \subfloat[label 1]%
    \qquad
    \subfloat[label 2]%
    \caption{2 Figures side by side}%
    \label{fig:example}%
\end{figure}
5
  • Hi, welcome. If I turn your code into a complete document, it compiles without error. Can you tell us exactly which error you get, and perhaps make a complete minimal working example? (See tex.meta.stackexchange.com/questions/228 for more on MWEs.) – Torbjørn T. Apr 16 '20 at 15:10
  • Tried to edit my question. – PSA Apr 16 '20 at 16:50
  • A couple of things: 1) The first code you posted used syntax from the subcaption package, the new code uses syntax from subfig. Do you have any requirements for which package to use? 2) versionPO is not a standard package (i.e. it is not on ctan.org), so if it's not needed, it would be better to remove it from the example. – Torbjørn T. Apr 16 '20 at 19:07
  • Thank you. Indeed, versionPO is not mandatory for me (I use a template). As far as I understood, the subfig syntax is the newer (more often used) syntax. As I am a newbie to LaTeX, I think I don't have any requirements for the package. I am mostly interested in getting to know whether I have to recreate all my figures to have separate ones or whether I can use existing syntax to achieve the subcaption despite not having two separated figures. @TorbjørnT. – PSA Apr 16 '20 at 19:42
  • subfig might be more used, but subcaption is newer. (There is also a package called subfigure, but that is considered deprecated I believe, one of the other two should be used.) – Torbjørn T. Apr 16 '20 at 19:45
1

I would use the subcaption package and its \subcaption macro, as in the example below.

enter image description here

A couple of unrelated comments:

  • it's not recommended to use utf8x for inputenc (utf8x vs. utf8 (inputenc)). I believe utf8became default last year, so if you have a new system then you don't need inputenc at all, but anyway prefer utf8 over utf8x if loading it.

  • epsfig is just a wrapper over graphicx I believe, and today it's not needed at all. Remove that, and keep just graphicx.


\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{subcaption}

\begin{document}
\begin{figure}[htb]%
    \captionsetup[subfigure]{skip=10pt,position=bottom}
    \centering
    \includegraphics[width=\linewidth]{example-image-16x10}
    \parbox{0.45\linewidth}{\subcaption{First subfig}}\hfill
    \parbox{0.45\linewidth}{\subcaption{Second subfig}}
    \caption{2 Figures side by side}%
    \label{fig:example}%
\end{figure}
\end{document}
2
  • Thanks! How can I increase the space between the figure and the subcaption? I tried /midskip (no effect), \setlength{\abovecaptionskip} (don't want that it applies to my general caption setup). @Torbjørn T. – PSA Apr 16 '20 at 20:35
  • @PSA Add \captionsetup[subfigure]{skip=10pt,position=bottom} inside the figure environment. – Torbjørn T. Apr 16 '20 at 20:41

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.