编号定理及推论

编号定理及推论

我怎样才能得到以下计数,例如:定理 1,推论 1.1 我的意思是与前一个定理的数量相关的推论的数量?

答案1

amsthm包装

如果推论列于之后定理(与其他中间定理)解决方案,使用amsthm包可以

\documentclass{article}
\usepackage{amsmath,amsthm}
\newtheorem{theorem}{Theorem}
\newtheorem{corollary}{Corollary}[theorem] % Use theorem counter as `parent`
\begin{document}
\noindent Now
\begin{theorem}
    First theorem
\end{theorem}
\begin{corollary}
    This is a corollary
\end{corollary}
\begin{corollary}
    This is a other corollary
\end{corollary}
\begin{theorem}
    Second theorem
\end{theorem}
\begin{corollary}
    This is a corollary
\end{corollary}
\end{document}

在此处输入图片描述

一种采用封装的方法tcolorbox

如果你喜欢彩色盒子,你可以尝试使用该包tcolorbox

\documentclass{article}
\usepackage{amsmath}
\usepackage{tcolorbox}
\tcbuselibrary{breakable,theorems,skins}
%-----------------------------------------------
% Theorem environments definitions
\newcounter{theo} % Extern counter for theorems
\newtcbtheorem%[]% init options
{theorem}% name environment
{Theorem}% Title
{enhanced,before title={\stepcounter{theo}},colback=blue!10,colframe=blue!35!black,fonttitle=\bfseries,%
attach boxed title to top left={xshift=5mm,yshift*=-\tcboxedtitleheight/2},%
boxed title style={colback=blue!35!black}}% options
{th}% label prefix

\newtcbtheorem[number within=theo]% init options
{corollary}% name environment
{Corollary}% Title
{enhanced,colback=green!10,colframe=green,fonttitle=\bfseries,colbacktitle=green!10,coltitle=black,%
attach boxed title to top left={xshift=5mm,yshift*=-\tcboxedtitleheight/2},%
boxed title style={boxrule=0.6pt}}% options
{co}% label prefix
%------------------------------------------------
\begin{document}
\section{Any theorems}
\noindent Now
\begin{theorem}{}{first}
    First theorem
\end{theorem}
\begin{corollary}{}{}
    This is a corollary
\end{corollary}
\begin{corollary}{}{}
    This is a other corollary to the Theorem \ref{th:first} ...
\end{corollary}
\begin{theorem}{Pythagorean theorem}{t2}
    For a \textit{right} triangle with \textbf{legs} $a$ and $b$ and \textbf{hypotenuse} $c$,
    \[a^2+b^2=c^2.\]
\end{theorem}
\begin{corollary}{}{c1}
    This is a corollary
\end{corollary}
A reference to Corollary \ref{co:c1} of the Theorem \ref{th:t2}.
\end{document}

在此处输入图片描述

相关内容