![未定义控制序列标题](https://linux22.com/image/332681/%E6%9C%AA%E5%AE%9A%E4%B9%89%E6%8E%A7%E5%88%B6%E5%BA%8F%E5%88%97%E6%A0%87%E9%A2%98.png)
当我编译包含此类代码的文档时:
\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}
我收到错误line 54: Undefined control sequence. \caption{Text here}
。如何解决这个问题?
PS 没有标题一切正常。
答案1
最有可能的错误是labelsep=emdash
。
要么是声明被遗忘了,要么是很容易定义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}