6

Suppose I have something like

\begin{enumerate}
  \item 
    \begin{equation*} 
      some eq 
    \end{equation*}
  \item 
    \begin{IEEEeqnarray*}{l} 
      eq 1 \\ 
      eq 2 \\ 
      ... 
      eq n 
    \end{IEEEeqnarray*}
\end{enumerate}

how would one go about removing the resulting line break that occurs when the equation starts, for both single line and multi-lined equations, so that the equation and the item numbering are aligned together? I thought this would be a relatively common issue but I can't find another post related to it - preventing the line break when beginning an item in an enumerated list with a new environment.

5

Here are some alternative options for you:

enter image description here

\documentclass{IEEEtran}% http://ctan.org/pkg/ieeetran
\begin{document}
\begin{enumerate}
  \item First item
  \item
    \[
      f(x) = ax^2 + bx + c
    \]
  \item
    \begin{IEEEeqnarray*}{l} 
      f(x) \\ 
      ax^2 \\ 
      bx \\
      c
    \end{IEEEeqnarray*}
  \item Last item
\end{enumerate}
\begin{enumerate}
  \item First item
  \item $f(x) = ax^2 + bx + c$
  \item \hfill $f(x) = ax^2 + bx + c$ \hfill\mbox{}
  \item
    $\begin{array}[t]{@{}l@{}}
      f(x) \\ 
      ax^2 \\ 
      bx \\
      c
    \end{array}$
  \item \null\hfill
    $\begin{array}[t]{@{}l@{}}
      f(x) \\ 
      ax^2 \\ 
      bx \\
      c
    \end{array}$
    \hfill\null
  \item Last item
\end{enumerate}
\end{document}

If you wish to stretch the contents of the array, modify \arraystretch as discussed in Column padding in tables.

  • Is there no known way to suppress the line break caused by using a new environment as the first part of your enumerated list though? Lets say instead of using equation or IEEEeqnarray, the theorem environment by using \newtheorem{theorem}{Theorem} would create the same issue. – Alex Oct 2 '13 at 23:53
3
+50

The IEEEtran class actually makes provisions for such constructions via the IEEEeqnarraybox family of commands. The environment IEEEeqnarrayboxm typesets its material in math mode. The syntax is

\begin{IEEEeqnarrayboxm}[initialcommands][pos][width]{format}
....
\end{IEEEeqnarrayboxm}

Making [pos] equal to [t] means that the baseline of the first line aligns with the surrounding text. [intialcommnads] can be empty, or one might want to try [\IEEEeqnstrutmode] for line spacing that is similar to normal text line breaks.

Here are some samples:

Sample output

\documentclass{IEEEtran}

\begin{document}

\begin{enumerate}
\item A first item in a list.
\item \leavevmode
  \begin{IEEEeqnarrayboxm}[][t]{rCl}
    \int_0^1 e^{-t}\,dt &=& 1-e^{-1},\\
    E &=& mc^2,\\
    0 &=& 6x^2 - 2x + 1.\strut
  \end{IEEEeqnarrayboxm}
\item \strut
  \begin{IEEEeqnarrayboxm}[][t]{cCcCcCl}
    2a &+&3b&-&c&=&3\\
    5a &+&b&+&2c&=&1\\
    -a&+&7b&+&3c&=&7\strut
  \end{IEEEeqnarrayboxm}
  and some further text.
\item A text item of a length that shows the current column width.
\item \leavevmode
  \begin{IEEEeqnarrayboxm}[\IEEEeqnarraystrutmode][t]{cCcCcCl}
    2a &+&3b&-&c&=&3\\
    5a &+&b&+&2c&=&1\\
    -a&+&7b&+&3c&=&7
  \end{IEEEeqnarrayboxm}\\
  and some text explaining this system of equations.
\item \leavevmode
  \begin{IEEEeqnarrayboxm}[][t]{l}
    y = \frac{e^{ax^2+bx+c}}2.
  \end{IEEEeqnarrayboxm}
\item Text item.
\end{enumerate}

\end{document}

Note that it is necessary to get LaTeX in to horizontal mode before entering the environment. This can be done by having some previous text on the line after the label, by issuing \leavevmode or by issuing a box such as \strut (this has the height of a capital letter, so can help with line spacing, but has zero width).

Similarly, \strut on the final line of the equation enviroments can improve the spacing over the default.

The documentation for the IEEEtran class has a comprehensive discription of these enviroments and various strut mechanisms in Appendix F.

3

Remarks

This approach is about the same as @Werner's, but I introduced some new environments to make everything a little more convenient.

I also defined a new environment on basis on IEEEeqnarrayboxm in adaption of Andrew Swann's answer.

Implementation

\documentclass{IEEEtran}
\pagestyle{empty}
\usepackage{amsmath,amssymb,lipsum}

\newenvironment{itemalign}%
    {$\aligned[t]}%
    {\endaligned$\par}

\newenvironment{itemeq}%
    {$\displaystyle}%
    {$\par}

\newenvironment{itemarray}[1]%
    {$\array[t]{#1}}%
    {\endarray$\par}

\newenvironment{itemIEEE}[1]%
    {\minipage[t]{\linewidth}\vskip -\baselineskip\begin{IEEEeqnarray*}{#1}}%
    {\end{IEEEeqnarray*}\endminipage}

\newcommand{\diff}{\mathop{}\!\mathrm{d}}
\begin{document}
\lipsum[11]
\begin{enumerate}
    \item
        \begin{itemeq}
            \mathcal{F}[f](\omega) = \frac{1}{(2 \pi)^{n/2}} \int_{\mathbb{R}^n} f(t) \, \mathrm{e}^{-\mathrm{i} \omega t} \diff t
        \end{itemeq}

    \item
        \begin{itemalign}
            \mathcal{F}[f](\omega) &= \frac{1}{(2 \pi)^{n/2}} \int_{\mathbb{R}^n} f(t) \, \mathrm{e}^{-\mathrm{i} \omega t} \diff t \\
            f(t) &= \mathcal{F}^{-1}[\mathcal{F}[f]](t)
        \end{itemalign}
    \item
        \begin{itemarray}{c@{{}+{}}c@{{}+{}}c@{{}={}}r}
            1 x_1 & 0 x_2    & 0 x_3    & 3 \\
            0 x_1 & (-2) x_2 & 3 x_3    & 6 \\
            0 x_1 & 0 x_2    & (-2) x_3 & 5 \\
        \end{itemarray}
        I don't know, if this is even sovable\dots

    \item
        \begin{itemIEEE}{rl}
            \mathcal{F}[f](\omega) &= \frac{1}{(2 \pi)^{n/2}} \int_{\mathbb{R}^n} f(t) \, \mathrm{e}^{-\mathrm{i} \omega t} \diff t \\
            f(t) &= \mathcal{F}^{-1}[\mathcal{F}[f]](t)
        \end{itemIEEE}
\end{enumerate}
\lipsum[11]
\end{document}

Output

enter image description here

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.