8

This is what I am currently doing with the alignat environment of the amsmath package. But I find the syntax heavy and not very user-friendly. I would like the numbering to be automatic a) ... b) ... c) on each line and that the spacing between the columns is easy to configure.

Is there a package that can automatically align and number a series of calculations with a simple and user-friendly syntax?

screenshot

\documentclass[french,landscape]{article}   
\usepackage[margin=6mm]{geometry}
\usepackage{amsmath}
\usepackage{multicol}
\setlength\columnsep{10mm}
\setlength\columnseprule{.4pt}
\raggedcolumns 

\begin{document}
\pagestyle{empty}

\setlength{\abovedisplayskip}{0pt}
\setlength{\belowdisplayskip}{0pt} 
\begin{multicols*}{2}
Effectuer:
\begin{alignat*}{3}
& a)\ (+7)+(-12)   \quad&&\quad b)\ (-7)+(+12)    \quad&&\quad c)\ (-7)+(-12) \\   
& d)\ (+9)+(-5)    \quad&&\quad e)\ (-4)+(+10)    \quad&&\quad f)\ (-12)+(-10)\\    
& g)\ (+9)+(-9)    \quad&&\quad h)\ (+12)+(-18)   \quad&&\quad i)\ (-20)+(+16)      
 \end{alignat*}
\columnbreak 

 Effectuer:
\begin{alignat*}{3}
& a)\ (+3)+(-18)   \quad&&\quad b)\ (-7)+(+12)    \quad&&\quad c)\ (-7)+(-12) \\   
& d)\ (+7)+(-5)    \quad&&\quad e)\ (-6)+(+13)    \quad&&\quad f)\ (-12)+(-10)\\    
& g)\ (+9)+(-9)    \quad&&\quad h)\ (+12)+(-18)   \quad&&\quad i)\ (-20)+(+16)      
 \end{alignat*}
 \end{multicols*}
\end{document}
15
  • Use enumerate and multicols. Commented May 2, 2021 at 7:35
  • @KimJongUn, multicols will give columns, not rows though. How about tex.stackexchange.com/a/324740/87678 ? Commented May 2, 2021 at 7:36
  • 1
    @DavidPurton: Thank you. I see. Commented May 2, 2021 at 7:38
  • @DavidPurton I feel like task does the job. Can you write a response?
    – AndréC
    Commented May 2, 2021 at 7:39
  • 2
    I can have a go at a comparison later tonight Commented May 2, 2021 at 9:35

3 Answers 3

13
+100

Here's a go at comparing four different packages. I think I like tasks best.

\documentclass{article}

\usepackage{url}
\usepackage{shortlst}
\usepackage{hlist}
\usepackage{tasks}
\usepackage{multienum}

\begin{document}

\section*{A comparison of horizontal list packages}

\subsection*{shortlst}

\texttt{shortlst} has a non-free licence, so you will need to grab it from
CTAN at \url{https://ctan.org/pkg/shortlst}.

Also, it uses the standard \LaTeX{} labels without easy customisation, so you
have to use a hook to redefine them if you want something else.

\AddToHook{env/shortenumerate/begin}{%
  \renewcommand\theenumi{\alph{enumi}}%
  \renewcommand\labelenumi{\emph{\theenumi})}}

The width of items is calculated automatically to maximise the number of items
per line, but you can set the item width manually using
\verb|\shortitemwidth|.

\begin{shortenumerate}
  \item $(+7)+(-12)$
  \item $(-7)+(+12)$
  \item $(-7)+(-12)$
  \item $(+9)+(-5)$
  \item $(-4)+(+10)$
  \item $(-12)+(-10)$
  \item $(+9)+(-9)$
  \item $(+12)+(-18)$
  \item $(-20)+(+16)$
\end{shortenumerate}

\subsection*{hlist}

\texttt{hlist} seems to work pretty well and his a flexible interface to set
the list parameters. The defaults are not very much like the default \LaTeX{}
lists so I had to fiddle with them a bit.

\sethlist{label sep=0.5em, item offset=2.5em, label width=2em, pre label={},
  label={\emph{\alph{hlisti}})}, label align=right}

\begin{hlist}3
  \hitem $(+7)+(-12)$
  \hitem $(-7)+(+12)$
  \hitem $(-7)+(-12)$
  \hitem $(+9)+(-5)$
  \hitem $(-4)+(+10)$
  \hitem $(-12)+(-10)$
  \hitem $(+9)+(-9)$
  \hitem $(+12)+(-18)$
  \hitem $(-20)+(+16)$
\end{hlist}

\subsection*{tasks}

\texttt{tasks} seems to be the most actively maintained package and has a good
interface for modifying list settings. Default settings are reasonably close
to the standard \LaTeX{} lists.

\settasks{label=\emph{\alph*}), label-align=right, label-offset=0.5em,
after-item-skip=-\parsep}

\begin{tasks}(3)
  \task $(+7)+(-12)$
  \task $(-7)+(+12)$
  \task $(-7)+(-12)$
  \task $(+9)+(-5)$
  \task $(-4)+(+10)$
  \task $(-12)+(-10)$
  \task $(+9)+(-9)$
  \task $(+12)+(-18)$
  \task $(-20)+(+16)$
\end{tasks}

\subsection*{multienum}

\texttt{multienum} uses a somewhat different interface, but still seems to
work fairly well.

There's no interface to customise labels and spacing though, so need to
redefine things manually. Except I couldn't find an easy way of modifying the
spacing between rows.

\renewcommand{\regularlisti}{%
  \setcounter{multienumi}{0}%
  \renewcommand{\labelenumi}{%
    \addtocounter{multienumi}{1}\emph{\alph{multienumi}})}}

\begin{multienumerate}
  \setlength{\parskip}{0pt}%
  \setlength{\itemsep}{0pt}%
  \mitemxxx{$(+7)+(-12)$}{$(-7)+(+12)$}{$(-7)+(-12)$}
  \mitemxxx{$(+9)+(-5)$}{$(-4)+(+10)$}{$(-12)+(-10)$}
  \mitemxxx{$(+9)+(-9)$}{$(+12)+(-18)$}{$(-20)+(+16)$}
\end{multienumerate}

\end{document}

output

2
  • How to make the decimal separator appear as a comma but be written with a point? For example write 3.2 + 1.5 but display 3,2 + 1,5 ?
    – AndréC
    Commented May 15, 2021 at 8:07
  • @AndréC you should ask a new question for this. Commented May 15, 2021 at 10:01
16

What about the tasks package?

enter image description here

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

Effectuer:
\begin{tasks}[item-format=\ensuremath](3)
    \task (+7)+(-12)
    \task (-7)+(+12)
    \task (-7)+(-12)
    \task (+9)+(-5)
    \task (-4)+(+10)
    \task (-12)+(-10)
    \task (+9)+(-9)
    \task (+12)+(-18)
    \task (-20)+(+16)
\end{tasks}

\end{document}
6
  • This package is great. But it would be even better if you didn't have to write every item in the math mode. Let it be automatic.
    – AndréC
    Commented May 2, 2021 at 8:20
  • 1
    @AndréC: I just edited my answer to include the item-format=\ensuremath option. If you want all tasks environment in your document to be in math mode automatically, you can use \settasks{item-format = \ensuremath} in the preamble instead.
    – leandriis
    Commented May 2, 2021 at 8:28
  • And if I want to number differently i) ii) or 1) 2) is it possible?
    – AndréC
    Commented May 2, 2021 at 8:42
  • The tasks package offers the label option which is similar to enumitem's label option. For i) ii) use label=\roman*) and for 1) 2) use label=\arabic*).
    – leandriis
    Commented May 2, 2021 at 8:46
  • 2
    It's great. Thanks a lot. This package deserves to be known.
    – AndréC
    Commented May 2, 2021 at 8:49
4

The last resort, maybe!

\documentclass[12pt]{article}
\usepackage[a5paper,margin=1cm,landscape]{geometry}
\usepackage{amsmath}
\usepackage{enumitem}
\usepackage{multicol}
\begin{document}



Effectuer:
\begin{multicols}{3}
\begin{enumerate}[label=\alph*)]
    \item $K+i+m$
    \item $J+o+n+g$
    \item $U+n$
    \item $P+e+a+c+e$
    \item $B+e$
    \item $U+p+o+n$
    \item $M+e$
    \item $\cdots$
    \item $\cdots$
\end{enumerate}
\end{multicols}
 

\end{document}

enter image description here

4
  • My handouts consist of an A4 sheet of paper divided into two columns (A5) on a landscape layout with the multicols environment. Is it possible to use your solution in this case?
    – AndréC
    Commented May 2, 2021 at 7:54
  • @AndréC: I think it is always possible to configure my solution to conform to your requirement. Commented May 2, 2021 at 7:58
  • Can you show this in your answer?
    – AndréC
    Commented May 2, 2021 at 8:00
  • @AndréC: Hahaha... :-) Commented May 2, 2021 at 9:20

You must log in to answer this question.

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