当我在定理环境中使用时,我发现\ref{}
没有指向我标记的内容。例如,我使用了\label{1.1.1}
和\ref{1.1.1}
,但结果却是Theorem 1.1.
我不知道为什么?有人能帮我吗?谢谢。
\documentclass{book}
\usepackage{amsmath}
\usepackage{amsthm}
\newtheoremstyle{plain}
{\topsep} % ABOVESPACE
{\topsep} % BELOWSPACE
{\itshape} % BODYFONT
{0pt} % INDENT
{\bfseries} % HEADFONT
{ } % HEADPUNCT
{5pt plus 1pt minus 1pt}
{\thmname{#1}~\thmnumber{#2}\thmnote{(#3)}}
\newtheorem{theorem}{Theorem}
\begin{document}
\chapter{}
\section{Word}
\begin{theorem}\label{1.1.1}This is good.
\end{theorem}
By theorem (\ref{1.1.1}), this word is also good.
\end{document}
答案1
\label
与\ref
定理数字的创建和显示方式无关。要获得 1.1.1,您需要对theorem
各节中的数字进行编号。这是通过可选参数中的
\newtheorem{theorem}{Theorem}[section] %<--- here
代码:
\documentclass{book}
\usepackage{amsmath}
\usepackage{amsthm}
\newtheoremstyle{plain}
{\topsep} % ABOVESPACE
{\topsep} % BELOWSPACE
{\itshape} % BODYFONT
{0pt} % INDENT
{\bfseries} % HEADFONT
{ } % HEADPUNCT
{5pt plus 1pt minus 1pt}
{\thmname{#1}~\thmnumber{#2}\thmnote{(#3)}}
\newtheorem{theorem}{Theorem}[section]
\begin{document}
\chapter{}
\section{Word}
\begin{theorem}\label{1.1.1}This is good.
\end{theorem}
By theorem (\ref{1.1.1}), this word is also good.
\end{document}
另外,在 中使用具体数字并不是一个好主意\label
。使用一些你能记住的键,键显示与定理的联系,如本例所示
\begin{theorem}\label{thm:fermat}
\[x^n + y^n = z^n, \qquad xyz \neq 0 \]............
\end{theorem}
By theorem (\ref{thm:fermat}), this word is also good.