0

In the following example, I have some equations within a list. I was wondering how to place each of the equations in items (ii) and (iv) on the same line with their corresponding item number, while centered, and the text beforehand, if any, aligned to the left.

Thanks.

\documentclass{article}
\usepackage{amsmath}
\usepackage{enumerate}

\begin{document} \begin{enumerate}[(i)] \item Item 1
\item \begin{equation} 3x + 9y = -12. \end{equation} \item Item 3 \end{enumerate} \end{document}

enter image description here

AEW
  • 819

1 Answers1

2

As I was looking for generality, here is a solution, inferred from the answer of @Werner posted here.

enter image description here

\documentclass{article}
\usepackage{amsmath}
\usepackage{enumerate}

\begin{document} \begin{enumerate}[(i)] \item Item 1
\item \hfill $ 3x + 9y = -12. $ \hfill\refstepcounter{equation}\textup{(\theequation)}\label{eq1} \item Item 3 \item Equation 4 \hfill $ 4x - 5y = 15. $ \hfill\refstepcounter{equation}\textup{(\theequation)}\label{eq2}
\end{enumerate} \end{document}


To make the equations centered, @Werner proposes, in his comment below, the following more elegant solution.

enter image description here

\documentclass{article}
\usepackage{amsmath}
\usepackage{enumerate}

\begin{document}
\begin{enumerate}[(i)] \item Item 1
\item \hfill $ 3x + 9y = -12. $ \hfill\llap{\refstepcounter{equation}\textup{(\theequation)}\label{eq1}} \item Item 3 \item \makebox[0pt][l]{Equation 4} \hfill $ 4x - 5y = 15. $ \hfill\llap{\refstepcounter{equation}\textup{(\theequation)}\label{eq2}}
\end{enumerate} \end{document}

AEW
  • 819
  • If you want the equations centered, then you need to place the equation numbers and any text preceding them inside zero-width boxes. – Werner Jun 09 '23 at 01:20
  • @Werner: Could you please show me how to do "zero-width boxes"? – AEW Jun 09 '23 at 01:26
  • \rlap makes a zero-width box with a right overlap (similar to \makebox[0pt][l]) while \llap makes a zero-width box with a left overlap (similar to \makebox[0pt][r]). If used immediately after \item you'll need \makebox or insert a \leavevmode before the overlap command. See this code. – Werner Jun 09 '23 at 05:26