\cref 與命題、定義、引理等交織在一起的編號

\cref 與命題、定義、引理等交織在一起的編號

我用了

\newtheorem{definition}{Definition}[section]
\newtheorem{proposition}[definition]{Proposition}

這樣編號就好像命題和定義是「同一個物件」。但問題是,如果我使用 \cref{...某個命題名稱...},那麼輸出不是“命題 2.7”,而是“定義 2.7”。

我該如何解決這個問題?

答案1

這是 p 的摘錄。包的使用者指南的 25 cleveref[添加黃色突出顯示]:

在此輸入影像描述

假設您使用該amsthm包,以下程式碼可讓您實現交叉引用目標:

\documentclass{article} % or some other suitable document class
\usepackage{amsthm}
\usepackage{cleveref} 
% Place all \newtheorem declarations _after_ cleveref is loaded:
\newtheorem{definition}{Definition}[section]
\newtheorem{proposition}[definition]{Proposition}

\begin{document}
\setcounter{section}{2}  % just for this example
\begin{definition}\label{def:1} Hello. \end{definition}
\begin{proposition}\label{prop:1} World. \end{proposition}

\noindent    % Create some cross-references:
As \cref{def:1,prop:1} argue, \dots
\end{document}

相關內容