2

Tasks package inserts too much vertical space after displayed math:

\documentclass{article}
\usepackage{tasks}
\begin{document}

\begin{tasks}
  \task \[ X\rule{10cm}{1pt}X \]
  \task \[ Y\rule{10cm}{1pt}Y \]
  \task \[ Z\rule{10cm}{1pt}Z \]
\end{tasks}

\begin{enumerate}
  \item \[ X\rule{10cm}{1pt}X \]
  \item \[ Y\rule{10cm}{1pt}Y \]
  \item \[ Z\rule{10cm}{1pt}Z \]
\end{enumerate}

\end{document}

What would be a proper way to fix this?

I know that I can adjust the vertical space manually with \vspace*{-1\baselineskip}, for example, or with a number of other hacks. I would like to know if I am missing some configuration option, or if this behavior is somehow expected and desirable, or if this is a bug of tasks package.

2 Answers 2

2

If you replace \[...\] by $...$, you have inline formulas. When you additionally need the behavoiur as inside displaymath, you can add \displaystyle between dollar signs.

\documentclass{article}
\usepackage{tasks}
\begin{document}

\begin{tasks}
  %\task \[ X\rule{10cm}{1pt}X \]
 \task $ Y\rule{10cm}{1pt}Y $
  %\task \[ Z\rule{10cm}{1pt}Z \]
    \task $\displaystyle Z\rule{10cm}{1pt}Z $
\end{tasks}

\begin{enumerate}
 % \item \[ X\rule{10cm}{1pt}X \]
 \item $ X\rule{10cm}{1pt}X $
  \item \[ Y\rule{10cm}{1pt}Y \]
  \item \[ Z\rule{10cm}{1pt}Z \]
\end{enumerate}

\end{document}

enter image description here

4
  • \displaystyle will not make it display math. For example, it will not be numbered, centered or aligned as display math.
    – Alexey
    Commented Nov 14, 2018 at 16:34
  • @Alexey a), b) etc. are also not in display math. An example, more similar to your real needs, it will be easier to guess what should be done. Commented Nov 14, 2018 at 16:48
  • Sorry, i do not understand what you mean. In my example all math was in display mode.
    – Alexey
    Commented Nov 14, 2018 at 17:32
  • I do not understand what you meant by "your real needs" either...
    – Alexey
    Commented Nov 14, 2018 at 17:33
2

Another solution consists in changing the values of \abovedisplayskip and \belowdisplayskip locally and use the amsmath environments:

\documentclass{article}
\usepackage{geometry}
\usepackage{mathtools}
\usepackage{tasks}

\begin{document}

{%% do not forget to chage the default values inside a group
\abovedisplayskip=-\baselineskip
\belowdisplayskip=0pt
\begin{tasks}
  \task\begin{gather}X\rule{10cm}{1pt}X \end{gather}
  \task \[ Y\rule{10cm}{1pt}Y \]
  \task \begin{gather} Z\rule{10cm}{1pt}Z \end{gather}
\end{tasks}
\begin{subequations}
\begin{enumerate}
  \item \begin{gather}X\rule{10cm}{1pt}Y \end{gather}
  \item \begin{gather}Y\rule{10cm}{1pt}Z\end{gather}
  \item \begin{gather}Z\rule{10cm}{1pt}Y \end{gather}
\end{enumerate}
\end{subequations}
}%

\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 .