如何$\mathbb{R}^k$
在标签中使用类似的东西?即
\label{three equivalent properties of $\mathbb{R}^k$}
。
目前,当我尝试此操作时出现错误。
以下是 MWE:
\documentclass[a4 paper,11pt]{article}
\usepackage{amsmath, amssymb, amsthm, parskip}
\begin{document}
\newtheorem{thm}{Theorem}
The letter $\mathbb{R}$ prints fine on its own. \\
\begin{thm}
And this theorem causes no issues.
\end{thm}
But putting math in the label is an issue:
\begin{thm}
\label{Putting an $\mathbb{R}$ here is an issue.}
This one can't be printed.
\end{thm}
\end{document}
错误信息:
答案1
标签只是交叉引用的标识符。虽然它不严格要求是字符串,但最好是:参数\label
受“完全扩展”的影响,并且诸如 之类的命令\mathbb
不会幸免于难。参数 中的命令\label
通常在内部使用,例如当标签是从宏自动生成的用于特殊目的时。
允许使用空格,但是我认为最好不要使用空格。
你可以定义\funnylabel
和\funnyref
宏
\documentclass[a4 paper,11pt]{article}
\usepackage{amsmath, amssymb, amsthm, parskip}
\newtheorem{thm}{Theorem}
\newcommand{\funnylabel}[1]{%
\label{\protect\detokenize{\detokenize{#1}}}%
}
\newcommand{\funnyref}[1]{%
\ref{\detokenize{#1}}%
}
\begin{document}
The letter $\mathbb{R}$ prints fine on its own.
\begin{thm}
And this theorem causes no issues.
\end{thm}
But putting math in the label is an issue:
\begin{thm}
\funnylabel{Putting an $\mathbb{R}$ here is an issue.}
This one can't be printed.
\end{thm}
\funnyref{Putting an $\mathbb{R}$ here is an issue.}
\end{document}
但我强烈反对你这样做。此外,我坚信
\label{equiv-properties-Rk}
比
\funnylabel{three equivalent properties of $\mathbb{R}^k$}
因为它更容易打字和记忆。