是否可以创建一个theorem
环境
\begin{corollary-list}
\item Let x be real number. You can choose a real number y greater than x.
\item Let q be rational number. You can choose a rational number z greater than q.
\end{corollary-list}
这样每个项目条目都会自动将 +1 添加到定理计数器,结果如下?:
我的代码是:
\documentclass{article}
\usepackage{amsmath,amsthm,amsfonts,amssymb}
\newtheorem{mytheorem}{Theorem}[section]
\newenvironment{corollary}
{\addtocounter{mytheorem}{1} \noindent\textbf{Corollary \thesection.\arabic{mytheorem}}. \begin{itshape}}
{\end{itshape}}
\newenvironment{corollaries}{\begin{itemize} \renewcommand\labelitemi{$\blacksquare$}}
{\end{itemize}}
\begin{document}
\begin{corollaries}
\item \begin{corollary} corollary 1 \end{corollary}
\item \begin{corollary} corollary 2 \end{corollary}
\end{corollaries}
\end{document}
我的目标是创建一个列表环境,在该环境中我不需要在每个项目中开始单独的定理,即项目本身标记定理并使用计数器。
答案1
为此,可以定制enumerate
环境枚举项包以生成具有特定格式的定理列表(推论、练习、定义等),其中包含根据文档中的章节和/或小节进行编号。
查看与文档各部分相关的推论的编号计数器。
代码
\documentclass{article}
\usepackage{amsmath,amsthm,amsfonts,amssymb}
\usepackage{enumitem}
\renewcommand{\theenumi}{\thesection.\arabic{enumi}}
\renewcommand{\thesubsection}{\arabic{subsection}}
\renewcommand{\thesection}{\arabic{section}}
\setlist[enumerate,1]{%
%noitemsep, % <-- Uncomment it If you want no space between items
align = left,
labelwidth = 1em,
leftmargin = 3.5em,
labelindent = \itemindent,
label = {%
$\blacksquare$ \bfseries Corollary \thesubsection.\theenumi
}
}
\newcommand{\myitem}{\item}
\begin{document}
\section{First Section}
\subsection{First Subsection}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ac molestie ipsum. Duis vitae neque ut sapien tincidunt porta a sed odio. Pellentesque eu fermentum justo, ut vulputate metus. Ut eget cursus dui, sed condimentum felis. Suspendisse egestas, urna eu pharetra lacinia, turpis massa blandit leo, nec dapibus libero metus in lorem.
\begin{enumerate}
\myitem {\it Let $x\in\mathbb{R}$. A real number $x$ is negative if and only if $-x$ is positive.}
\myitem {\it Let Let $x,y\in\mathbb{R}$. If $x$ and $y$ are positive, then so are $x+y$ and $xy$.}
\myitem {\it Let $x$ be real number. You can choose a real number $y$ greater than $x$.}
\myitem {\it Let $q$ be rational number. You can choose a rational number $z$ greater than $q$.}
\end{enumerate}
\subsection{Second Subsection}
Phasellus condimentum volutpat massa, sed aliquet lorem rutrum nec. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In pulvinar mi id tellus pretium, a mollis eros bibendum.
\begin{enumerate}
\myitem {\it Let $x\in\mathbb{R}$. A real number $x$ is negative if and only if $-x$ is positive.}
\myitem {\it Let Let $x,y\in\mathbb{R}$. If $x$ and $y$ are positive, then so are $x+y$ and $xy$.}
\myitem {\it Let $x$ be real number. You can choose a real number $y$ greater than $x$.}
\myitem {\it Let $q$ be rational number. You can choose a rational number $z$ greater than $q$.}
\end{enumerate}
\noindent Cras venenatis, mauris id vestibulum consectetur, ex mi volutpat dolor, ut sodales sem nisi in felis. Mauris eu hendrerit lacus. Sed purus massa, tristique a nulla in, lacinia hendrerit eros. Nam fermentum euismod erat et elementum.
\section{Second Section}
\subsection{First Subsection}
\begin{enumerate}
\item {\it Let $x\in\mathbb{R}$. A real number $x$ is negative if and only if $-x$ is positive.}
\item {\it Let Let $x,y\in\mathbb{R}$. If $x$ and $y$ are positive, then so are $x+y$ and $xy$.}
\item {\it Let $x$ be real number. You can choose a real number $y$ greater than $x$.}
\item {\it Let $q$ be rational number. You can choose a rational number $z$ greater than $q$.}
\end{enumerate}
\subsection{Second Subsection}
Duis tempus ante ex, rutrum varius quam iaculis id. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam ut nibh leo. Fusce pharetra vestibulum elementum. Praesent faucibus justo non elit dapibus dignissim.
\begin{enumerate}
\item {\it Let $x\in\mathbb{R}$. A real number $x$ is negative if and only if $-x$ is positive.}
\item {\it Let Let $x,y\in\mathbb{R}$. If $x$ and $y$ are positive, then so are $x+y$ and $xy$.}
\item {\it Let $x$ be real number. You can choose a real number $y$ greater than $x$.}
\item {\it Let $q$ be rational number. You can choose a rational number $z$ greater than $q$.}
\end{enumerate}
\end{document}