3

Is it possible to create a theorem environment

\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}

so that every item entry will automatically add +1 to the theorem counter, resulting in something like this?:

example

My code is:

\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}

My goal is to I create a list environment, where I don't have to begin separate theorem in each item, i.e. where item itself labels theorems and uses counter.

  • 1
    Welcome to TeX.SX! Yes, it is possible. Please add a MWE (minimal, compilable code example) to help us help you. – TeXnician Jan 22 '18 at 14:14
  • Thank you, @TeXnician. I added the code needed to run the document on the image. – Cebiş Mellim Jan 23 '18 at 9:45
5

For that purpose, one can customize the enumerate environment with enumitem package in order to generate a list of theorems (Corollaries, exescises, definitions, etc.) with specific format that contains numbering according to sections and/or subsections within the document.

enter image description here


enter image description here

Look at the numbering counter of corollaries related of section parts of the document.

The code

\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}
  • 2
    I like the answer, but I think you could improve it by using enumitems \newlist and \setlist macros to define a new environment rather than redefining enumerate. This would also allow to make two versions for, say, corollaries and lemmas. – Tiuri Jan 24 '18 at 9:26
  • @Tiuri I appreciate your suggestion and support on this. Indeed, it was the purpose in the first place. I intented to create a newlist and apply the setlist as you pointed out, however, I got problems with the \theenumii counter, since it did not work and displayed number 0 for every single item. If you check the original answer (not the edited) you can see my firts attempt. Any suggestion to improve the code is highly appreciated. – Cragfelt Jan 25 '18 at 4:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.