3

The goal is to remove the white line after the 1. in the second enumerate in the picture, so it will look like the first enumerate.

I don't like the first enumerate because it uses inline math, needs the white line in the code to make a new paragraph, and uses \displaystyle which I think is not the way to go: it feels like a 'hack'. Maybe I am mistaken, in that case say so, but I think there must be a good solution.

MWE:

\documentclass[english]{exam}
\usepackage[fleqn]{amsmath}

\begin{document}

    \begin{enumerate}  %result looks fine, but code ugly
        \item 
        $\displaystyle \pi$ 

        $\displaystyle 2\pi$
    \end{enumerate}

    \begin{enumerate} %code looks fine, but result ugly
        \item 
        \[\pi\]
        \[2\pi\]
    \end{enumerate}

\end{document}
4
  • Welcome, you are using a displayed math environment. Their purpose is to present their content on an extra line.
    – Johannes_B
    Commented May 16, 2016 at 14:45
  • @Johannes_B But even in an enumerate? So I should use the \displaystyle?
    – PHPirate
    Commented May 16, 2016 at 14:51
  • I think this is a classical XY-question. So you want math in an enumerate? Or do you want to enumerate math? If you ake that clear, an experienced user can help you find a solution.
    – Johannes_B
    Commented May 16, 2016 at 14:52
  • @Johannes_B I want math in an enumerate, as said like in the first enumerate in the picture. But I want to avoid using \displaystyle because I don't like typing that every time in an inline math environment.
    – PHPirate
    Commented May 16, 2016 at 14:55

4 Answers 4

4

One problem is that \[...\] environments always add extra vertical space and try to center their contents (the fleqn might help to avoid that). Using a \tesxtstyle approach with $ delimiters is the typical approach for what you seem to want. But if \item is just a bunch of left-aligned stacked math, this might be more streamlined.

Maybe one of (or some combination of) the following three stack approaches would work for you (no fleqn required).

\documentclass[english]{exam}
\usepackage{tabstackengine}
\stackMath
\makeatletter\renewcommand\TAB@delim[1]{\displaystyle#1}\makeatother
\setstackEOL{\cr}% ROW DELIMITER FOR STACKS
\renewcommand\stackalignment{l}% LEFT ALIGNMENT OF STACKS
\setstackgap{S}{8pt}% INTER-ROW PADDING OF SHORT STACKS
\begin{document}
    \begin{enumerate}  %result looks fine, but code ugly
        \item 
%       FOR SIMPLE REGULAR-HEIGHT STACKS
        \Longunderstack{\pi\cr 2\pi}
        \item 
%       FOR IRREGULAR HEIGHT STACKS IN \textstyle
        \Shortunderstack{\pi\cr \frac{2\pi}{x}\cr \frac{\pi^3}{\pi_x}}
        \item 
%       FOR IRREGULAR HEIGHT STACKS IN \displaystyle
        \tabbedShortunderstack{\pi\cr \frac{2\pi}{x}\cr \frac{\pi^3}{\pi_x}}
    \end{enumerate}
\end{document}

enter image description here

If typing \tabbedShortunderstack was too much work each time, one could, for example, \let\Estack\tabbedShortunderstack in the preamble.

3
  • Looks fine, but my tex installation can't find the package file, so hang on a minute.
    – PHPirate
    Commented May 16, 2016 at 15:00
  • @PHPirate Try ctan.org/pkg/tabstackengine and ctan.org/pkg/stackengine. Commented May 16, 2016 at 15:02
  • Thanks, that worked! Indeed, for individual cases I'll just use the \textstyle approach as you say, but the stacking is a good bonus for when you have a lot of it.
    – PHPirate
    Commented May 16, 2016 at 15:08
5

Simply try this:

\documentclass{article}
\usepackage[fleqn]{amsmath}
\newcommand\mathitem{\item\leavevmode\vspace*{-\dimexpr\baselineskip+\abovedisplayskip\relax}}

\begin{document}

    \begin{enumerate} %
        \mathitem \begin{gather*}
          \pi\\2\pi
        \end{gather*}

    \end{enumerate}

\end{document} 

enter image description here

3
  • Good one, a big advantage is that you don't need to install an extra package locally, and I like the use of gather.
    – PHPirate
    Commented May 16, 2016 at 15:26
  • @PHPirate Don't forget to upvote a question you like especially if you have accepted ;-)
    – Tarass
    Commented May 16, 2016 at 16:01
  • @Tarass That is exactly what I wanted to, except that SE complains I don't have enough reputation yet :D
    – PHPirate
    Commented May 16, 2016 at 16:11
1

One more (simple) solution:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{enumerate} 
  \item $\begin{aligned}[t]
          x & = 0   \\
          y & = \frac{1}{2}
        \end{aligned}$
\end{enumerate}
\end{document}

enter image description here

0

With the extension witharrows correctly parameted, you have directly the result. Of course, the main purpose of the extension witharrows is to add arrows. That's, why, in the following example, I have added an arrow.

\documentclass[english]{exam}
\usepackage[fleqn]{amsmath}
\usepackage{witharrows}
\WithArrowsOptions{fleqn,displaystyle,mathindent = 0pt,notag}
\begin{document}
\begin{enumerate}
\item
\begin{DispWithArrows}[format=c]
\frac{2\pi}{3} \Arrow[tikz=-]{which one?}\\
\frac{5\pi}{4}
\end{DispWithArrows}
\end{enumerate}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .