TransWikia.com

Math fills entire column with multicol and enumitem

TeX - LaTeX Asked on April 29, 2021

With the following code:

documentclass[12pt]{article}

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

begin{document}
    
begin{enumerate}[itemindent=parindent]
    setlengthcolumnsep{4em}
    begin{multicols}{3}
        everymath{displaystyle}
        item $int_0^5 big(x^5 - exp(-x)big)dx$.hfill
        item $int_0^pi xsin(x)dx$.
        item $int_0^{log 3}xsinh(2x)dx$.
        item $int_{-1}^1 x^2exp(-x)dx$.
        item $int_{-1}^1 x^3exp(-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^3cos(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^2exp(-x)dx$.
        item $int_{-infty}^{+infty} x^2exp(-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.

With the indent option

Without the indent option

2 Answers

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.

enter image description here

documentclass[12pt]{article}
usepackage[margin=2.7cm]{geometry}
usepackage{multicol,enumitem}
setlengthcolumnsep{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 xsin(x),dx$
   item $int_0^{log 3}xsinh(2x),dx$
   item $int_{-1}^1 x^2exp(-x),dx$
   item $int_{-1}^1 x^3exp(-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^3cos(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^2exp(-x),dx$
   item $int_{-infty}^{+infty} x^2exp(-x^2),dx$
end{enumerate}
end{multicols}
end{document}

Correct answer by Mico on April 29, 2021

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}
usepackage{tasks}

begin{document}

        everymath{displaystyle}settasks{label=arabic*., label-align=right, label-width=1.5em, ref=arabic*}
    begin{tasks}(3)
        task $int_0^5 big(x^5 - exp(-x)big)dx$
        task $int_0^pi xsin(x)dx$.
        task $int_0^{log 3}xsinh(2x)dx$.
        task $int_{-1}^1 x^2exp(-x)dx$.
        task $int_{-1}^1 x^3exp(-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^3cos(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^2exp(-x)dx$.
        task $int_{-infty}^{+infty} x^2exp(-x^2)dx$.
    end{tasks}

end{document} 

enter image description here

Answered by Bernard on April 29, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP