Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I know there was a previous post about this but no matter the changes I make as shown in various posts, I can not get the caption to show a or b like it is suppose to. Instead I get Figure 1.1, Figure 1.2 and then the end caption is Figure 1.3. I want the subfigures labeled a and b and then have the overall figure labeled 1.1. (Note I looked at the previous post and modified it to look like it and it still did not work. I have the packages. Any advice would be great!

\begin{figure}[htb]
  \centering
  \begin{subfigure}
    \includegraphics[width=0.3\textwidth]{Chapter-1/figs/Image1.pdf}
      \caption[Image 1]{Image 1}
      \label{fig:I1}
  \end{subfigure}

  \begin{subfigure}
    \includegraphics[width=0.4\textwidth]{Chapter-1/figs/Image2.pdf}
      \caption[Image 2]{Image2}
  \end{subfigure}
  \caption[Images]{Images}
  \label{fig:images}
\end{figure}
share|improve this question
    
Welcome to TeX.SX! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). –  mvkorpel Aug 30 at 15:54
2  
You should link to "previous post" and "various posts". –  mvkorpel Aug 30 at 15:56
    
At least please tell us which document class you use. –  Mico Aug 30 at 16:15
    
\documentclass[11pt, phd, onehalfspacing]{ncsuthesis} \usepackage{booktabs} \usepackage{amsmath} \usepackage{textcomp} \usepackage{xcolor} \usepackage{lipsum} % filler text \usepackage{subfig} % composite figures \usepackage{feynmf} \usepackage{hyperref} %\usepackage{subcaption} \usepackage[demo]{graphicx} %\usepackage{subfigure} \usepackage[options]{natbib} I go back and forth trying subcaption and subfigure as suggested by many others... still not working closest thing to work is Thanos response... but still does not work perfectly –  pibsquared Sep 8 at 17:17

2 Answers 2

You missed the width for subfigure which is the mandatory argument:

\begin{subfigure}{0.45\textwidth}

Use any length instead of 0.45\textwidth as you need. Also don't leave blank lines in between two subfigures as it will amount to a par break. With this I get:

\documentclass{article}
\usepackage{subcaption}
\usepackage[demo]{graphicx}   %% no demo in your file
\begin{document}
  \begin{figure}[htb]
  \centering
  \begin{subfigure}{0.45\textwidth}
    \centering
    \includegraphics[width=0.3\textwidth]{Chapter-1/figs/Image1.pdf}
      \caption[Image 1]{Image 1}
      \label{fig:I1}
  \end{subfigure}
  \hfill                              %% no blank line here.
  \begin{subfigure}{0.45\textwidth}
    \centering
    \includegraphics[width=0.4\textwidth]{Chapter-1/figs/Image2.pdf}
      \caption[Image 2]{Image2}
  \end{subfigure}
  \caption[Images]{Images}
  \label{fig:images}
\end{figure}
\end{document}

enter image description here

share|improve this answer
    
Unfortunately still does not work. Still shows 1.3 and 1.4 instead of a and b. –  pibsquared Sep 8 at 17:16
    
@pibsquared "does not work" is not enough information. Did you run my code as such? Is it working? Give a MWE. –  Harish Kumar Sep 8 at 23:09
    
If I only use package subcaption it will not compile. If I use both subfig and subcaption it will compile but it will label Image 1 as Figure 1 and Image 2 Figure 2 and Images as Figure 3. Instead of A and B for Image 1 and 2 respectively. I have exactly what you have above except had to add the subfig package to make it compile. If I try it with subfigure instead of subfig it will not compile. –  pibsquared Sep 9 at 18:36

Try the following code

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subfigure}
\begin{document}
\begin{figure}
  \centering
  \subfigure[Title Image 1]{\label{fig:I1}\includegraphics[width=0.3\textwidth]{Chapter-1/figs/Image1.pdf}}\qquad
  \subfigure[Title Image 2]{\label{fig:I2}\includegraphics[width=0.3\textwidth]{Chapter-1/figs/Image2.pdf}}
\caption{Title of the whole image}
\label{fig:I}
\end{figure}
\end{document}

The output is

enter image description here

share|improve this answer
2  
subfigure is deprecated/obsolete (and not supported anymore). Suggestions are to use subfig or subcaption instead. –  Werner Aug 30 at 16:37
    
This started to work but when I substituted the label with the labels I have made, it would not work anymore. It also shows the label next to the caption. SO it would be fig:I1 (a) Title Image 1. Not sure why. –  pibsquared Sep 8 at 17:06
    
@pibsquared : Would you mind posting your code to see what might be wrong? –  Thanos Sep 9 at 6:30
    
Ok I figured out the problem I had both \usepackage{subfig} and \usepackage{subfigure} It prefers subfigure –  pibsquared Sep 9 at 18:17
    
@pibsquared : Glad you could work it out!!! –  Thanos Sep 9 at 18:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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