5

When I compile document that has such code:

\usepackage{caption}
\usepackage{subcaption}
\DeclareCaptionLabelSeparator{emdash}{~--- }
\captionsetup[figure]{labelsep=emdash,font=onehalfspacing,position=bottom}
\captionsetup{%
    singlelinecheck=off,
    skip=2pt,
    justification=centering,
}

% ...

\begin{figure}[h]
    \centering
    \includegraphics[width=0.8\textwidth]{test.png}
    \caption{Text here}
\end{figure}

I get error line 54: Undefined control sequence. \caption{Text here}. How to resolve this issue?

P.S. Without caption all works properly.

1
  • 2
    Your fragment is not really usefull, but labelsep should be labelsep=endash most likely. Also the setspace package is missing!
    – user31729
    Apr 24, 2016 at 15:12

1 Answer 1

5

Most likely the error is labelsep=emdash.

Either the declaration has been forgotten or it's easy to define emdash:

\DeclareCaptionLabelSeparator{emdash}{\textemdash}
\documentclass{article}


\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{setspace}


\DeclareCaptionLabelSeparator{emdash}{\textemdash}
\captionsetup[figure]{labelsep=emdash,font=onehalfspacing,position=bottom}
\captionsetup{%
  singlelinecheck=off,
  skip=2pt,
  justification=centering,
}


\begin{document}

\begin{figure}[h]
    \centering
    \includegraphics[width=0.8\textwidth]{ente}
    \caption{Text here}
\end{figure}

\end{document}

enter image description here

7
  • I have such lines in code: \DeclareCaptionLabelSeparator{emdash}{~--- } %\captionsetup[figure]{labelsep=emdash,font=onehalfspacing,position=bottom}, When \captionsetup is uncomment, all works properly, but when I uncomment it I get error Undefined control sequence.
    – 0x1337
    Apr 24, 2016 at 15:21
  • 1
    @0x1337: Then show us the code, not fragments only
    – user31729
    Apr 24, 2016 at 15:22
  • Thank you! The problem was in the order of \captionsetups.
    – 0x1337
    Apr 24, 2016 at 15:24
  • 1
    @0x1337 The order of \captionsetup is irrelevant, so I doubt that the problem was in the order. If it was anyway, this might be a bug in my caption package so I would like to have a document which actually reproduces the problem. (This is still missing here, and still no-one except you knows what the problem was.)
    – user2574
    Apr 24, 2016 at 16:13
  • @AxelSommerfeldt, I'm sorry, I can not share with the full document. It's very big and messy :(
    – 0x1337
    Apr 24, 2016 at 16:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .