[Tex/LaTex] How to make a math version of itemize, enumerate, and description environments

listsmath-mode

tabular is to array as itemize is to …?

I'd like to have a list like

\documentclass{article}
\begin{document}
\begin{eqlist}
\item E=mc^2
\item e^{i\pi}+1=0
\item \text{ducks} + \text{caffeine}
    = \text{\url{http://i.stack.imgur.com/GVksc.gif}}
\end{eqlist}
\end{document}

I'm already using enumitem, but I don't think that package will be of any help. Of course, any solution will work πŸ™‚

Important variations:

  • What about display math?
  • What about the other list environments – like description and enumerate?

Use Case

The use-case is pretty trivial, actually – to have a list of equations. You could call this 'for fun', but I have in the past actually hacked something together for class notes that allowed me to do something like this (e.g. listing out and naming the properties of algebraic groups). I had thought the idea was limited to that so I never generalized my (terribly messy) solution, but I'm seeing the pattern pop-up more and more in various documents where it actually doesn't look absolutely awful as you'd expect. Conveniently, I don't have any solid examples except this newbie document that popped up on reddit.com/r/LaTeX.

Best Answer

Here is a solution (it doesn't use, but I hope it will be compatible with enumitem)

Note: I don't understand what the OP want to do with display math

Limitation: blank lines not supported (this code will not work)

\begin{mathitem}
\item E=mc^2

\item e^{i\pi}+1=0
\item \text{ducks} + \text{caffeine}
    = \text{\url{http://i.stack.imgur.com/GVksc.gif}}
\end{mathitem}

Complete code

\documentclass{article}
\usepackage{xpatch}

\usepackage{amsmath,url}
\usepackage{enumitem}


\makeatletter
\newcommand{\mtmathitem}{%
\xpatchcmd{\item}{\@inmatherr\item}{\relax\ifmmode$\fi}{}{\errmessage{Patching of \noexpand\item failed}}
\xapptocmd{\@item}{$}{}{\errmessage{appending to \noexpand\@item failed}}}
\makeatother

\newenvironment{mathitem}[1][]{%
\itemize[#1]\mtmathitem}{$\endlist}                    %$

\newenvironment{mathenum}[1][]{%
\enumerate[#1]\mtmathitem}{$\endlist}                  %$

\newenvironment{mathdesc}[1][]{%
\description[#1]\mtmathitem}{$\endlist}                %$


\begin{document}

\begin{mathitem}
\item E=mc^2
\item e^{i\pi}+1=0
\item \text{ducks} + \text{caffeine}
    = \text{\url{http://i.stack.imgur.com/GVksc.gif}}
\end{mathitem}


\begin{mathenum}
\item E=mc^2
\item e^{i\pi}+1=0
\item \text{ducks} + \text{caffeine}
    = \text{\url{http://i.stack.imgur.com/GVksc.gif}}
\end{mathenum}


\begin{mathenum}[label=\emph{\alph*})]
\item E=mc^2
\item e^{i\pi}+1=0
\item \text{ducks} + \text{caffeine}
    = \text{\url{http://i.stack.imgur.com/GVksc.gif}}
\end{mathenum}

\begin{mathdesc}
\item[some] E=mc^2
\item[thing] e^{i\pi}+1=0
\item[else] \text{ducks} + \text{caffeine}
    = \text{\url{http://i.stack.imgur.com/GVksc.gif}}
\end{mathdesc}

\end{document}

enter image description here