我对 LateX 还不太熟悉,我需要帮助完成我的学士论文。我正在写一篇数学论文,里面有很多例子,我需要标注和引用我的例子。
我给你举一个例子,我到底需要什么:
\chapter{chapter_name}
some text
\section{section_name}
some text
%dunno how to get this number and reference here
\textbf{Example chapter_number.section_number.example_number:} \\
$Here is some mothematical example$\\
\\
...
%dont know how to reference the example
In example chapter_number.section_number.example_number we can find ...
我尝试了 \label 和 \ref,但它只是引用了章节而不是示例。
答案1
将其example
视为定理结构。您可以轻松地使用该ntheorem
包执行您想要的操作:您要求的是 break
此包中的样式。我添加了该cleveref
包以便更有效地管理交叉引用(例如,如果您的一些示例后来成为注释,您将不必去追逐所有出现的“example”一词,以将其中一些替换为“remark”):
\documentclass{report}%]
\usepackage[utf8]{inputenc}%
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage[thmmarks, amsmath, framed]{ntheorem}%
\usepackage{cleveref}
\theoremstyle{break}
\theoremheaderfont{\bfseries}
\theorembodyfont{\mdseries}
\theoremseparator{\smallskip }
\newtheorem{example}{Example}[section]
\begin{document}
\chapter{An Interesting Chapter}
\section{A First Section}
\begin{example}[Title] \label{ex-a}
This is the first example. The counter will be reset at each section.
\end{example}
\begin{example}[Title the Second]\label{ex-b}
This is the second example of the first section. It’s the continuation and development of \cref {ex-a}.
\end{example}
\section{Another Section}
\begin{example}[Title title]\label{ex-c}
This is the first example of the second section, referring to \cref{ex-b}. The counter was reset.
\end{example}
\end{document}
答案2
新定理正好满足了我的需要。首先我创建了定理:
\newtheorem{mydef}{Example}[section]
那么我的例子看起来就像这样
\begin{mydef}
\label{example:math}
$Mathematical examlpe$
\end{mydef}
In example \ref{example:math} we can find ...