2

I'm very new to Latex and trying my best to adopt it as my method of choice for paper and my Thesis. I have always managed to solve any problems encountered by browsing through this forum but can't find anything on this error.

I have a figure made up of 4 sub-figures in a 2x2 matrix. Somehow my template doesn't allow me to use the subcaption package so I am forced to use the subfig package which seems to work fine if not for the odd error I encountered.

My code is as follows:

\documentclass[11pt, english, doublespacing,]{MastersDoctoralThesis}
\usepackage{graphicx,amsmath,amssymb,rotating,float,cite,multirow,subfig,
array,bm,appendix,epsfig,epstopdf,pdfpages,array,caption}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}

\begin{figure}[!htp]
    \centering
    \label{Saliency_Maps}
    \subfloat[]{\includegraphics[width=0.49\linewidth]{figures/colour_conp.png} \label{Sal:Colour}}
    \subfloat[]{\includegraphics[width=0.49\linewidth]{figures/intensity_conp.png} \label{Sal:Intensity}}
    \\
    \subfloat[] {\includegraphics[width=0.49\linewidth]{figures/orientation_conp.png} \label{Sal:Orit}}
    \subfloat[]{\includegraphics[width=0.49\linewidth]{figures/final_sal_map.png} \label{Sal:Final}}
    \caption{ Conspicuity maps for a sample image showing colour \subref{Sal:Colour}, intensity \subref{Sal:Intensity} and orientation \subref{Sal:Orit} maps which are then combined into the final saliency map \subref{Sal:Final} which will need to be thresholded.}
\end{figure}

\end{document} 

The caption is causing all sort of errors such as:

Argument of \caption@ydblarg has an extra }. ...inal} which will need to be thresholded.}

...and...

Paragraph ended before \caption@ydblarg was complete. ...inal} which will need to be thresholded.}

...among other under full and overfull \hbox errors, which make no sense.

Removing the \caption{...} doesn't show any errors, but obviously shows no cation. Also even though there are errors when the \caption{...} is inserted the figures and caption display correctly..... with the exception that the letters under the figures are uppercase while the letters substituted be \subref{...} are lower case. (See image)

enter image description here

The errors are only suppressed if I set \setcounter{tocdepth}{3}. Setting it to \setcounter{tocdepth}{2} triggers a whole lot of errors which similarly don't make any sense and there are some odd entries in the "List of Figures" page where the offending image entry should be.

Any ideas what could be happening and how I can solve this nagging issue. Alternatives are welcome.

Many thanks

  • Welcome to TeX - LaTeX! Please extend your code snippet to minimal working example (MWE)](meta.tex.stackexchange.com/q/228) including the documentclass and packages needed. – Andrew Swann Apr 5 '16 at 18:34
  • Please update your question with the new information. – Andrew Swann Apr 5 '16 at 18:41
  • Why can't you use subcaption? it should work just fine. – Johannes_B Apr 8 '16 at 21:04
  • I get an error saying "Package subcaption Error: This package can't be used in cooperation(subcaption) with the subfig package. \endinput}{}" and I need to use sibfig as I have some old tex files I'm using in this document that use this and it's laborious to change them all. – PDF417 Apr 9 '16 at 9:58
  • For completeness sake, I corrected the capital letters under the sub figures by inserting "\captionsetup[subfigure]{labelfont=rm}" before the \begin{figure}. – PDF417 Apr 9 '16 at 10:00
3

The cause of your problem is use of \subref{...}. Their use in caption had to be protected: \protect\subref{ ...}. See and test code below:

\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}

\begin{document}
\begin{figure}[htp]
    \centering
\subfloat[\label{Sal:Colour}]{\includegraphics[width=0.49\linewidth]{example-image}}
\hfill
\subfloat[\label{Sal:Intensity}]{\includegraphics[width=0.49\linewidth]{example-image}}
    \\
\subfloat[\label{Sal:Orit}] {\includegraphics[width=0.49\linewidth]{example-image}}
\hfill
\subfloat[\label{Sal:Final}]{\includegraphics[width=0.49\linewidth]{example-image}}
\caption{ Conspicuity maps for a sample image showing colour \protect\subref{Sal:Colour}, intensity \protect\subref{Sal:Intensity} and orientation \protect\subref{Sal:Orit} maps which are then combined into the final saliency map \protect\subref{Sal:Final} which will need to be thresholded.}
\label{Saliency_Maps}
    \end{figure}
\end{document}

enter image description here

By the way, label in figure environment had to be always after caption, othervise the referencing will work wrong.

  • Brilliant, Thanks for your help and comments. The \protect\subre{} was the issue. Noted re: \label after caption. The only difference between mine and yours is that mine still has uppercase letters under each figure and lower case in the caption. Would you have any hints on how to chance the uppercase letter to lower case? Edited the question to include an image of what's happening. – PDF417 Apr 5 '16 at 19:28
  • Ah, seem that the goblin "copy-past" was on the work :-). Corrected! – Zarko Apr 5 '16 at 19:30

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.