# Math fills entire column with multicol and enumitem

With the following code:

\documentclass[12pt]{article}

\usepackage[margin=2.7cm]{geometry}
\usepackage{multicol,enumitem}

\begin{document}

\begin{enumerate}[itemindent=\parindent]
\setlength\columnsep{4em}
\begin{multicols}{3}
\everymath{\displaystyle}
\item $\int_0^5 \big(x^5 - \exp(-x)\big)dx$.\hfill
\item $\int_0^\pi x\sin(x)dx$.
\item $\int_0^{\log 3}x\sinh(2x)dx$.
\item $\int_{-1}^1 x^2\exp(-x)dx$.
\item $\int_{-1}^1 x^3\exp(-x)dx$.
\item $\int_{-19^{75}}^{19^{75}} x^3dx$.
\item $\int_{-1}^2 x^3dx$.
\item $\int_0^2 x^4dx$.
\item $\int_{-2}^2x^4dx$.
\item $\int_{-5}^{-1} (x+3)^3dx$.
\item $\int_{-\pi}^{\pi} x^3\cos(x^2)dx$.
\item $\int_{-\log 7}^{\log 7}\sinh(2x)dx$.
\item $\int_{-\log 7}^{\log 7}\cosh(2x)dx$.
\item $\int_0^{+\infty} x^2\exp(-x)dx$.
\item $\int_{-\infty}^{+\infty} x^2\exp(-x^2)dx$.
\end{multicols}
\end{enumerate}

\end{document}


I get the output of the first picture; as you can see with the first item, if the expression is too long, it tends to fill the entire space of the column. However, if I comment out the itemident=\parindent option (with the rest of the code unchanged), I get the second picture, which looks as one would expect this sort of thing to look. How do I solve this? I really need the itemindent parameter here, because I encountered this problem when using a customised list declared with enumitem's \newlist and \setlist. Thanks!

EDIT: The second picture is also produced if I comment out the line with the \columnsep macro.

I would (a) exchange the order of the itemize and multicols environments and (b) replace \begin{enumerate}[itemindent=\parindent] with \begin{enumerate}[left=0pt]. Semi-optionally, insert thinspace before all instances of dx.

\documentclass[12pt]{article}
\usepackage[margin=2.7cm]{geometry}
\usepackage{multicol,enumitem}
\setlength\columnsep{4em}

\begin{document}
\begin{multicols}{3}
\begin{enumerate}[left=0pt]
\everymath{\displaystyle}
\item $\int_0^5 \big(x^5 - \exp(-x)\big)\,dx$
\item $\int_0^\pi x\sin(x)\,dx$
\item $\int_0^{\log 3}x\sinh(2x)\,dx$
\item $\int_{-1}^1 x^2\exp(-x)\,dx$
\item $\int_{-1}^1 x^3\exp(-x)\,dx$
\item $\int_{-19^{75}}^{19^{75}} x^3\,dx$
\item $\int_{-1}^2 x^3\,dx$
\item $\int_0^2 x^4\,dx$
\item $\int_{-2}^2 x^4\,dx$
\item $\int_{-5}^{-1} (x+3)^3\,dx$
\item $\int_{-\pi}^{\pi} x^3\cos(x^2)\,dx$
\item $\int_{-\log 7}^{\log 7}\sinh(2x)\,dx$
\item $\int_{-\log 7}^{\log 7}\cosh(2x)\,dx$
\item $\int_0^{+\infty} x^2\exp(-x)\,dx$
\item $\int_{-\infty}^{+\infty} x^2\exp(-x^2)\,dx$
\end{enumerate}
\end{multicols}
\end{document}

• Quite! Why should one begin the list inside the multicolumn env. and not the other way around? Thanks! – mathbekunkus Mar 6 at 1:20
• @mathbekunkus - I was thinking of two reasons when I made that recommendation. The first is more theoretical, the second more practical. First, I think that from a layout/design perspective, with two nested environments, the more general environment should be the outer one. To me, a multicols environment is more general, i.e, has more potential uses, than an enumerate environment. Second, my suggestion ends up providing ever so slightly more usable space, i.e., is less likely to require a line break, than your initial setup. – Mico Mar 6 at 1:33

It is simpler to do that with tasks package, which works like enumitem. You can force a task to spread over several columns with the optional argument \task(n).

\documentclass[12pt]{article}

\usepackage[margin=2.7cm]{geometry}

\begin{document}

\everymath{\displaystyle}\settasks{label=\arabic*., label-align=right, label-width=1.5em, ref=\arabic*}
\task $\int_0^5 \big(x^5 - \exp(-x)\big)dx$
\task $\int_0^\pi x\sin(x)dx$.
\task $\int_0^{\log 3}x\sinh(2x)dx$.
\task $\int_{-1}^1 x^2\exp(-x)dx$.
\task $\int_{-1}^1 x^3\exp(-x)dx$.
\task $\int_{-19^{75}}^{19^{75}} x^3dx$.
\task $\int_{-1}^2 x^3dx$.
\task $\int_0^2 x^4dx$.
\task $\int_{-2}^2x^4dx$.
\task $\int_{-5}^{-1} (x+3)^3dx$.
\task $\int_{-\pi}^{\pi} x^3\cos(x^2)dx$.
\task $\int_{-\log 7}^{\log 7}\sinh(2x)dx$.
\task $\int_{-\log 7}^{\log 7}\cosh(2x)dx$.
\task $\int_0^{+\infty} x^2\exp(-x)dx$.
\task $\int_{-\infty}^{+\infty} x^2\exp(-x^2)dx$.