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'm having an issue compiling with the subcaption package. I'm starting to write my thesis, and I originally started a chapter with a separate document. This compiled fine and had the following pre-amble

\documentclass[11pt,a4paper]{article}
\usepackage{fullpage,graphicx,amsmath,verbatim,float,caption,subcaption}
\numberwithin{equation}{section}
\numberwithin{figure}{section}

\begin{document}

I then moved to a template for a thesis, (full template is here http://www.sunilpatel.co.uk/thesis-template/ ) I copied across the chapter I have completed into the chapter1.tex file as specified. I also copied across my \usepackage line to give the following preamble in the thesis document:

%% ----------------------------------------------------------------
%% Thesis.tex -- MAIN FILE (the one that you compile with LaTeX)
%% ---------------------------------------------------------------- 

% Set up the document
\documentclass[a4paper, 11pt, oneside]{Thesis}  % Use the "Thesis" style, based on the            ECS Thesis style by Steve Gunn
\graphicspath{{Figures/}}  % Location of the graphics files (set up for graphics to be     in PDF format)

% Include any extra LaTeX packages required
\usepackage[square, numbers, comma, sort&compress]{natbib}  % Use the "Natbib" style    for the references in the Bibliography
\usepackage{verbatim}  % Needed for the "comment" environment to make LaTeX comments
\usepackage{vector}  % Allows "\bvec{}" and "\buvec{}" for "blackboard" style bold vectors in maths
\usepackage{fullpage,graphicx,amsmath,float,caption,subcaption}
\hypersetup{urlcolor=blue, colorlinks=true}  % Colours hyperlinks in blue, but this can   be distracting if there are many links.

When I compile the Thesis.tex file it now has three errors for each of the figures I'm trying to use

  1. ! Use of \@subfloat doesn't match its definition.
  2. ! Missing number, treated as zero.
  3. ! Illegal unit of measure (pt inserted).

An example of the code for one of my figures is as follows:

\begin{figure}[!h]
    \centering
    \begin{subfigure}[b]{0.3\textwidth}
        \includegraphics[scale=0.35]{figure1}
        \caption{figure1 caption}
        \label{fig: figure1 }
    \end{subfigure}
    \hspace{20mm}
    \begin{subfigure}[b]{0.3\textwidth}
        \includegraphics[scale=0.35]{figure2}
        \caption{figure2 caption}
        \label{fig: figure2 }
    \end{subfigure}
    \caption{Caption}
\end{figure}

If I remove the subfigure package then the file will compile, but the formatting is all screwed up. I'm guessing there are conflicting packages, but i can't find which one it is.

I'm pretty new to latex and just learning the ropes, so if it something silly then I apologise in advance.

Thanks in advance for any help

John

share|improve this question
7  
The Thesis.cls loads subfigure, which has been obsolete for at least ten years; it also loads vmargin which is incompatible with several packages. I wouldn't recommend using it. –  egreg Aug 23 '13 at 14:28
    
I'm using the template by Steve Gunn as well and I had the same problem. Unless I'm mistaken, you'll also want to move \usepackage{hyperref} from Thesis.cls to just before \begin{document} in case you load a package that needs to come before it. (Are you a University of Southampton student by any chance? :-)) –  sudosensei Aug 23 '13 at 14:34
    
Ah, I hadn't noticed that Thesis.cls loaded packages aswell!! I'll give it ago to see if I can get it working, If not I'll do the formatting myself. I'm actually a University of Newcastle Student :) probably as far away from Southampton in the UK you can get! Thanks for the help –  speeder1987 Aug 23 '13 at 15:48

1 Answer 1

The class loads subfigure which conflicts with subcaption and has been obsolete for several years.

Remove the call of this package from the template. It should do no harm and will allow you to load and use subcaption.


Also the vmargin package that's used by the class has problems of compatibility with other packages, notably atbegshi; it's probably better two switch to geometry for setting the page parameters. You can find an example of conversion in this answer of mine

share|improve this answer

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.