答案1
交叉引用机制是 LaTeX 的强项,因此您不需要做任何特殊的事情。
机制很简单:使用命令 为要引用的对象分配一个符号名称\label
;通过调用并输入您分配的符号名称来获取引用\ref
。如果您添加或删除对象,分配可能会不同步,这会更改分配的数字,但您会在 LaTeX 运行结束时收到警告,只需再次运行 LaTeX 即可解决这个暂时的问题。
\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}[section]
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{remark}[theorem]{Remark}
\begin{document}
\section{Test}\label{sec:test}
\begin{definition}\label{def:tableau}
A \emph{tableau} is a very interesting thing.
\end{definition}
\begin{remark}\label{rem:tableau}
We note that the plural of \emph{tableau} is \emph{tableaux}.
\end{remark}
\begin{remark}
In definition~\ref{def:tableau} we were a bit terse.
See theorem~\ref{thm:main} for more information.
\end{remark}
\begin{theorem}\label{thm:main}
This is the main theorem about tableaux.
\end{theorem}
\end{document}
可以使用 获得更高级的设置cleveref
。请注意代码中的细微差别,但输出是相同的。
\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{cleveref}
\newtheorem{theorem}{Theorem}[section]
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{remark}[theorem]{Remark}
\begin{document}
\section{Test}\label{sec:test}
\begin{definition}\label{def:tableau}
A \emph{tableau} is a very interesting thing.
\end{definition}
\begin{remark}\label{rem:tableau}
We note that the plural of \emph{tableau} is \emph{tableaux}.
\end{remark}
\begin{remark}
In \cref{def:tableau} we were a bit terse.
See \cref{thm:main} for more information.
\end{remark}
\begin{theorem}\label{thm:main}
This is the main theorem about tableaux.
\end{theorem}
\end{document}
答案2
这是一个非常简单的设置。由于您没有提供任何代码,我不知道您是否使用任何特定的包,所以我不确定这是否能帮助您。
您可以使用环境参数为每个定义分配一个标签definition
,稍后您可以使用环境参数引用该标签remark
:
\documentclass{article}
\newcounter{definition}
\counterwithin{definition}{section}
\newenvironment{definition}[1]{%
\refstepcounter{definition}\label{#1}%
\noindent\textbf{Definition \thedefinition.}%
}{%
\par%
}
\newenvironment{remark}[1]{%
\noindent\textbf{Remark \ref{#1}.}%
}{%
\par%
}
\begin{document}
\section{Section One}
\begin{definition}{def:a}
This is the first definition.
\end{definition}
\begin{definition}{def:b}
This is the second definition.
\end{definition}
\begin{remark}{def:b}
This is a remark to the seocnd defintion.
\end{remark}
\section{Section Two}
\begin{definition}{def:c}
This is the third definition.
\end{definition}
\begin{remark}{def:c}
This is a remark to the third defintion.
\end{remark}
\begin{remark}{def:a}
This is a remark to the first defintion, referring to defintion \ref{def:b}.
\end{remark}
\end{document}