0

I just started working with Latex and I'm stuck with the following issue: instead of getting 'Figure 1 Caption' and 'Subfigure 1 Caption', I get 'fnum@figure Caption' and 'fnum@subfigure A Caption'

This is my source file:

\begin{figure}
\begin{subfigure}{.5\textwidth}
\centering
\includegraphics[width=.8\linewidth]{fig1}
\caption{Caption}\label{fig:1a} 
\end{subfigure}
\begin{subfigure}{.5\textwidth}
\centering
\includegraphics[width=.8\linewidth]{fig1}
\caption{Caption}\label{fig:1b}
\end{subfigure}
\caption{Caption}\label{fig:1}  
\end{figure}

(The code is obviously not mine, I found it somewhere)

I'm using the following packages:

\usepackage{graphicx}
\usepackage[spanish]{babel}
\usepackage[export]{adjustbox}
\usepackage{fancyhdr}

\usepackage{caption}
\usepackage{subcaption}

\usepackage{geometry}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{eucal}
\usepackage{setspace}\singlespacing

Besides, I'm TexMaker provides the following error messages:

Missing \endcsname inserted.\aftergroup \caption{Caption}

Extra \endcsname. ...csname fnum@\@subcaptype \endcsname}\fi \caption{Caption}

Any ideas?

Thank you. Regards

--EDIT--

The example worked for me, until I embedded it in my document. It turned out that the problem was caused by this:

\renewcommand{\captionlabelfont}{\textbf}

The thesis template I'm trying to adapt to my needs used caption2, which I replaced by subcaption to make the subfigure code work. I guess subcaption could not parse the above, as it was meant for another package.

Thanks for your help.

  • 2
    Welcome to TeX.Se. Please post a full MWE, to make it easier to diagnose your problem, and for you question to be helpful to other users. I tried adding a \documentclass{article}, and \begin{document}``\end{document}around your code, and it worked, so the problems probably lies with some other code. Possible a missing }. – Runar May 28 '16 at 15:50
  • I've removed the texmaker tag -- it's not related to that editor – user31729 May 28 '16 at 16:23
  • As you pointed out, the problem was elsewhere. I've edited my question. I'm marking the question as solved. Thank you. – javierjsa May 28 '16 at 20:20
0
\documentclass[a4paper,10pt]{report}

\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{geometry}


\begin{document}

\begin{figure}[]
\begin{subfigure}{.5\textwidth}
    \centering
    \includegraphics[width=.8\linewidth]{example-image}
    \caption{Caption 1}\label{fig:1a} 
\end{subfigure}
\begin{subfigure}{.5\textwidth}
    \centering
    \includegraphics[width=.8\linewidth]{example-image}
    \caption{Caption 2}\label{fig:1b}
\end{subfigure}
\caption{Caption}\label{fig:1}  
\end{figure}
\end{document}

enter image description here

  • In the above example, I've only included the packages required – user95439 May 28 '16 at 16:49
  • Okay great, you've showed something that works. Now why doesn't the OP's setup work as expected? – Werner May 28 '16 at 17:08
  • too many unnecessary packages included, which conflict each other – user95439 May 28 '16 at 17:19
  • Could you identify them? – Werner May 28 '16 at 17:47
  • I got it working with the same result using all the packages. I still don't think this would help the OP, or others, without an MWE – Runar May 28 '16 at 17:48

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.