Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How to create an environment for enumerating that allows one to identify the enumeration with the theorem environment?

Example:


Definition 1.1 Let X be a set. An algebra over X is a collection C of subsets of X satisfying

D 1.1.1 If A is an element of C, then X\A is an element of C;

D 1.1.2 If A and B are both elements of C, then the union A U B is an element of C.


Proposition 1.1 Let C be an algebra over a set X; then the following senteces are true

P 1.1.1 The empty set is an element of C;

P 1.1.2 The set X is an element of C;

P 1.1.3 Every finite union of elements of C is an element of C;

P 1.1.4 Every finite intersection of elements of C is an element of C.


It would be quite useful if I could labeled then, to a further reference.

share|improve this question
2  
It is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. This will also serve as a test case and ensure that the solution actually works for you. –  Peter Grill May 13 '12 at 23:57
    
Peter Grill's comment is particularly relevant here because there are so many different ways to create theorems- which one are you using? –  cmhughes May 14 '12 at 2:56
1  
@cmhughes: in this particular case, I disagree. The solution I provided will work with only some minor formatting changes whenever the theorem-like structures are defined as environments and have an associated counter (and those conditions are always satisfied with the usual methods for creating theorems: amsthm, ntheorem, mdframed). –  Gonzalo Medina May 14 '12 at 14:34
    
@GonzaloMedina I agree- your solution is very robust. However, if a specific theorem package was specified then there would be no need for the etoolbox as the setlist trick you wrote could have been built into the environment definition –  cmhughes May 14 '12 at 14:51
    
@cmhughes: Ah, I see your point. Should we delete our comments or do you think we can leave them? –  Gonzalo Medina May 14 '12 at 18:58
show 2 more comments

1 Answer

up vote 13 down vote accepted

Here's one possible solution using the enumitem package to define a new list-like environment whose label uses a variable prefix; this prefix is controlled by a macro and, with the help of the etoolbox package, the theorem-like environments are patched to redefine the prefix. Labeling and cross-referencig items is then done as usual.

According to barbara beeton's comment, provisions were made to have the labels with a final period and the cross-references without it. Also, italicized item numbers were suppressed.

\documentclass{book}
\usepackage{amsthm}
\usepackage{enumitem}
\usepackage{etoolbox}

\newtheorem{prop}{Proposition}[chapter]
\theoremstyle{definition}
\newtheorem{defi}{Definition}[chapter]

\newcommand\EnumPrefix{}

\newlist{senenum}{enumerate}{10}
\setlist[senenum]{label=\EnumPrefix.,ref=\EnumPrefix,leftmargin=*}

\AtBeginEnvironment{defi}{\renewcommand\EnumPrefix{\normalfont\bfseries D.\thedefi.\arabic*}}
\AtBeginEnvironment{prop}{\renewcommand\EnumPrefix{\normalfont\bfseries P.\theprop.\arabic*}}

\begin{document}

\chapter{Test Chapter}

\begin{defi}
Let $X$ be a set. An algebra over $X$ is a collection $C$ of subsets of $X$ satisfying
\begin{senenum}
\item If $A$ is an element of $C$, then $X\setminus A$ is an element of $C$;
\item  If $A$ and $B$ are both elements of $C$, then the union $A\cup B$ is an element of $C$.
\end{senenum}
\end{defi}

\begin{prop}
Let $C$ be an algebra over a set $X$; then the following senteces are true
\begin{senenum}
\item\label{ite:algempty} The empty set is an element of $C$;
\item The set $X$ is an element of $C$;
\item  Every finite union of elements of $C$ is an element of $C$;
\item\label{ite:alginter} Every finite intersection of elements of $C$ is an element of $C$.
\end{senenum}
\end{prop}

In the proof of the equivalence of \ref{ite:alginter} and \ref{ite:algempty}, we used,...

\end{document}

enter image description here

The above approach focuses on the list-like environment, therefore it is ready to use (with only minor changes) in the case in which ntheorem is used to define the theorem-like structures (ntheorem doesn't use a default period at the end of theorem numbering):

\documentclass{book}
\usepackage{ntheorem}
\usepackage{enumitem}
\usepackage{etoolbox}

\newtheorem{prop}{Proposition}[chapter]
\theoremstyle{changebreak}
\newtheorem{defi}{Definition}[chapter]

\newcommand\EnumPrefix{}

\newlist{senenum}{enumerate}{10}
\setlist[senenum]{label=\EnumPrefix,leftmargin=*}

\AtBeginEnvironment{defi}{\renewcommand\EnumPrefix{\normalfont\bfseries D.\thedefi.\arabic*}}
\AtBeginEnvironment{prop}{\renewcommand\EnumPrefix{\normalfont\bfseries P.\theprop.\arabic*}}

\begin{document}

\chapter{Test Chapter}

\begin{defi}
Let $X$ be a set. An algebra over $X$ is a collection $C$ of subsets of $X$ satisfying
\begin{senenum}
\item If $A$ is an element of $C$, then $X\setminus A$ is an element of $C$;
\item  If $A$ and $B$ are both elements of $C$, then the union $A\cup B$ is an element of $C$.
\end{senenum}
\end{defi}

\begin{prop}
Let $C$ be an algebra over a set $X$; then the following senteces are true
\begin{senenum}
\item\label{ite:algempty} The empty set is an element of $C$;
\item The set $X$ is an element of $C$;
\item  Every finite union of elements of $C$ is an element of $C$;
\item\label{ite:alginter} Every finite intersection of elements of $C$ is an element of $C$.
\end{senenum}
\end{prop}

In the proof of the equivalence of \ref{ite:alginter} and \ref{ite:algempty}, we used,...

\end{document}

enter image description here

When using ntheorem, there's even another option, not requiring the etoolbox package since \theoremprework can be used to redefine appropriately the prefix used for the list-like environment (as suggested by cmhughes in a comment to the original question); here's the code corresponding to this approach and producing the same result as before:

\documentclass{book}
\usepackage{ntheorem}
\usepackage{enumitem}

\newcommand\EnumPrefix{}

\theoremprework{\renewcommand\EnumPrefix{\normalfont\bfseries P.\theprop.\arabic*}}
\newtheorem{prop}{Proposition}[chapter]
\theoremstyle{changebreak}
\theoremprework{\renewcommand\EnumPrefix{\normalfont\bfseries D.\thedefi.\arabic*}}
\newtheorem{defi}{Definition}[chapter]

\newlist{senenum}{enumerate}{10}
\setlist[senenum]{label=\EnumPrefix,leftmargin=*}

\begin{document}

\chapter{Test Chapter}

\begin{defi}
Let $X$ be a set. An algebra over $X$ is a collection $C$ of subsets of $X$ satisfying
\begin{senenum}
\item If $A$ is an element of $C$, then $X\setminus A$ is an element of $C$;
\item  If $A$ and $B$ are both elements of $C$, then the union $A\cup B$ is an element of $C$.
\end{senenum}
\end{defi}

\begin{prop}
Let $C$ be an algebra over a set $X$; then the following senteces are true
\begin{senenum}
\item\label{ite:algempty} The empty set is an element of $C$;
\item The set $X$ is an element of $C$;
\item  Every finite union of elements of $C$ is an element of $C$;
\item\label{ite:alginter} Every finite intersection of elements of $C$ is an element of $C$.
\end{senenum}
\end{prop}

In the proof of the equivalence of \ref{ite:alginter} and \ref{ite:algempty}, we used,...

\end{document}
share|improve this answer
    
keeping the period at the end of the xrefs is confusing. also (depending on house style), italicizing item numbers may be deprecated. methods of avoiding those situations would be appreciated. –  barbara beeton May 14 '12 at 13:30
    
@barbarabeeton: thank you for your comment; I've updated my answer incorporating your suggestions. –  Gonzalo Medina May 14 '12 at 13:50
1  
@PauloHenrique it depends on the desired kind of indentation. You can change leftmargin=* for leftmargin=<length>, where <length> is an appropriate length. –  Gonzalo Medina Apr 30 '13 at 14:25
1  
@PauloHenrique What value did you use for leftmargin? Since the labels are wide, you need a rather big value. –  Gonzalo Medina Apr 30 '13 at 14:46
1  
@PauloHenrique as I said, since your labels are wide, you need a bigger value. –  Gonzalo Medina Apr 30 '13 at 14:49
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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