# Custom enumerate and align multiple equations

I'd like to produce the following layout.

I want to be able to choose the numbering like (a) or roman I. but automatically, i don't want to number it myself. I know i can do this with enumitem but the real problem is insert math in each \item and keep a global alignment across the items, the =, the texts for all P.. [Identity]. I've tried with \intertext{\item~\phantom} inside align* and alignat* without success. I leave the text for ease of you.

\begin{enumerate}[label=(\alph*)]
\begin{alignat*}{3}
\item
P+\mathcal{O}
&&\text{para todo $P\in E$.} \quad
\item
P+(-P)
&&\text{para todo $P\in E$.} \quad
&&\text{[Inverso]}
\item
\item
(P+Q)+R
&&\text{para todo $P,Q,R\in E$.} \quad
\item
P+Q
&&\text{para todo $P,Q\in E$.} \quad
\end{alignat*}
\end{enumerate}


The code above of course produces the error LaTeX Error: Command \item invalid in math mode.. I'd really appreciate your help.

• I could agree to align the conditions, but aligning the equals signs makes no real sense, as those symbols are unrelated to one another, Jan 9 '20 at 14:39

I'd not align the equals signs, because they are unrelated to each other. You can use eqparbox for the task.

\documentclass{article}
\usepackage{amsmath,amsthm}

\usepackage{enumitem,eqparbox}

\newcounter{itemalign}
\newcommand{\itemalign}[3]{%
\item
\eqmakebox[\theitemalign-C][l]{#3}
}
\newenvironment{enumalign}
{\stepcounter{itemalign}\begin{enumerate}[font=\upshape,label=(\alph*),leftmargin=*]}
{\end{enumerate}}

\newtheorem{theorem}{Theorem}[section]

\newcommand{\EO}{\mathcal{O}}

\begin{document}

\section{Title}

\begin{theorem}
Let $E$ be an elliptic curve. Then the addition law on $E$ has
the following properties:
\begin{enumalign}
\itemalign{$P+\EO=\EO+P=P$}{for all $P\in E$}{\upshape[Identity]}

\itemalign{$P+(-P)=\EO$}{for all $P\in E$}{\upshape[Inverse]}

\itemalign{$(P+Q)+R=P+(Q+R)$}{for all $P,Q,R\in E$}{\upshape[Associativity]}

\itemalign{$P+Q=Q+P$}{for all $P,Q\in E$}{\upshape[Commutativity]}
\end{enumalign}
\end{theorem}

\end{document}


With a small change to \itemalign you can get the final labels pushed to the right margin, yet left aligned.

\newcommand{\itemalign}[3]{%
\item
\eqmakebox[\theitemalign-B][l]{#2}\hfill
\eqmakebox[\theitemalign-C][l]{#3}\ignorespaces
}


If you insist on the alignment,

\documentclass{article}
\usepackage{amsmath,amsthm}

\usepackage{enumitem,eqparbox}

\newcounter{itemalign}
\newcommand{\itemalign}[4]{%
\item
\eqmakebox[\theitemalign-A][r]{#1}
\eqmakebox[\theitemalign-D][l]{#4}
}
\newenvironment{enumalign}
{\stepcounter{itemalign}\begin{enumerate}[font=\upshape,label=(\alph*),leftmargin=*]}
{\end{enumerate}}

\newtheorem{theorem}{Theorem}[section]

\newcommand{\EO}{\mathcal{O}}

\begin{document}

\section{Title}

\begin{theorem}
Let $E$ be an elliptic curve. Then the addition law on $E$ has
the following properties:
\begin{enumalign}
\itemalign{$P+\EO$}{${}=\EO+P=P$}{for all $P\in E$}{\upshape[Identity]}

\itemalign{$P+(-P)$}{${}=\EO$}{for all $P\in E$}{\upshape[Inverse]}

\itemalign{$(P+Q)+R$}{${}=P+(Q+R)$}{for all $P,Q,R\in E$}{\upshape[Associativity]}

\itemalign{$P+Q$}{${}=Q+P$}{for all $P,Q\in E$}{\upshape[Commutativity]}
\end{enumalign}
\end{theorem}

\end{document}


• Interesting. The format of 3rd argument could defined in the command, right? Since they are supposed to be formatted like that, in upright and inside brackets. Jan 9 '20 at 15:25
• @Sigur Yes; I opted to not go with that optimization. Jan 9 '20 at 15:26

I'm almost sure that there are other solution more elegant. But, this is a possible one:

\documentclass[11pt,a4paper]{report}
\usepackage{amsthm,amsmath,amssymb,amsfonts}
\usepackage{lipsum}

\newcounter{fooeq}
\renewcommand{\thefooeq}{\alph{fooeq}}
\newcommand{\myfooeq}{\refstepcounter{fooeq}\textup{(\thefooeq)}}

\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}
\lipsum[2]
\par\noindent
\begin{aligned} \myfooeq && P+\mathcal{O} &= \mathcal{O}+P=P && \text{para todoP\in E$.} && \textup{[Identidad]}\\ \myfooeq && P+(-P) &= \mathcal{O} && \text{para todo$P\in E.} && \textup{[Inverso]} \end{aligned}
\end{theorem}

\lipsum[2]
\end{document}

• Make the counter referable with \refstepcounter{<newcounter>}. Jan 9 '20 at 14:50
• @azetina, well observed. Thanks. Jan 9 '20 at 14:53