# How can Ι align the items in enumerate environment?

I use the enumerate environment and I wanted some items to be in the same line with horizontal numbering. I don't want use the multicol or tasks packages and so I found the following code:

\makeatletter
\newcommand{\initem}{\ifnum\enit@type=\z@\refstepcounter{\@listctr}\fi
\hspace{20pt}\@itemlabel\hspace{\labelsep}}
\makeatother


but items have different width each time while the horizontal space between them is specific because of \hspace command. How can I get the right space each time so that items to be vertically aligned?

\documentclass{article}

\usepackage[textheight=21cm,textwidth=16cm,]{geometry}
\usepackage{enumitem}

\setlength{\parindent}{0pt}
\everymath{\displaystyle}

\makeatletter
\newcommand{\initem}{\ifnum\enit@type=\z@\refstepcounter{\@listctr}\fi
\hspace{20pt}\@itemlabel\hspace{\labelsep}}
\makeatother

\begin{document}

Example 1 -- Two columns \\
\rule{0.5\linewidth}{0.5pt} \\
\hphantom{\rule{0.5\linewidth}{0.5pt}}
\rule{0.5\linewidth}{0.5pt}
\begin{enumerate}
\item   $f(x)=2x^3-3x^2+5x-1$
\initem $f(x)= \frac{x+3}{2x-4}$
\item   $f(x)= \sqrt{3x-12}$
\initem $f(x)= \frac{2}{\sqrt{6-2x}}$
\end{enumerate}

\vspace{1cm}

Example 2 -- Three columns \\
\rule{0.333\linewidth}{0.5pt} \\
\hphantom{\rule{0.333\linewidth}{0.5pt}}
\rule{0.333\linewidth}{0.5pt} \\
\hphantom{\rule{0.333\linewidth}{0.5pt}}
\hphantom{\rule{0.333\linewidth}{0.5pt}}
\rule{0.334\linewidth}{0.5pt}
\begin{enumerate}
\item   $f(x)=2x^3-3x^2+1$
\initem $f(x)= \frac{x+3}{2x-4}$
\initem $f(x)= \sqrt{3x-12}$
\item   $f(x)= \frac{2}{\sqrt{x^2-1}}$
\initem $f(x)= \frac{x}{x+1}$
\initem $f(x)= \sqrt{x+\frac{1}{x}}$
\end{enumerate}

\end{document}


• Why you not like to use tasks package? It is designed for what you like to have ... – Zarko Oct 18 at 12:32

The multicol package is designed for this. You should use it.

Here's how to apply it to your example:

\documentclass{article}

\usepackage[textheight=21cm,textwidth=16cm,]{geometry}
\usepackage{enumitem}
\usepackage{multicol}

\setlength{\parindent}{0pt}
\everymath{\displaystyle}

\makeatletter
\newcommand{\initem}{\ifnum\enit@type=\z@\refstepcounter{\@listctr}\fi
\hspace{20pt}\@itemlabel\hspace{\labelsep}}
\makeatother

\begin{document}

Example 1 -- Two columns \\
\rule{0.5\linewidth}{0.5pt} \\
\hphantom{\rule{0.5\linewidth}{0.5pt}}
\rule{0.5\linewidth}{0.5pt}
\begin{multicols}{2}
\begin{enumerate}
\item   $f(x)=2x^3-3x^2+5x-1$
\item $f(x)= \frac{x+3}{2x-4}$
\item   $f(x)= \sqrt{3x-12}$
\item $f(x)= \frac{2}{\sqrt{6-2x}}$
\end{enumerate}
\end{multicols}

\vspace{1cm}

Example 2 -- Three columns \\
\rule{0.333\linewidth}{0.5pt} \\
\hphantom{\rule{0.333\linewidth}{0.5pt}}
\rule{0.333\linewidth}{0.5pt} \\
\hphantom{\rule{0.333\linewidth}{0.5pt}}
\hphantom{\rule{0.333\linewidth}{0.5pt}}
\rule{0.334\linewidth}{0.5pt}
\begin{multicols}{3}
\begin{enumerate}
\item   $f(x)=2x^3-3x^2+1$
\item $f(x)= \frac{x+3}{2x-4}$
\item $f(x)= \sqrt{3x-12}$
\item   $f(x)= \frac{2}{\sqrt{x^2-1}}$
\item $f(x)= \frac{x}{x+1}$
\item $f(x)= \sqrt{x+\frac{1}{x}}$
\end{enumerate}
\end{multicols}

\end{document}


Original example Here's an example combined with threeparttable's tablenotes to demonstrate its use with a list. It's lifted from my thesis, to illustrate the output; the part of most interest is between \begin{multicols}[2] and \end{multicols}. It works nicely with more conventional \items as well:

\begin{threeparttable}
\caption[High\hyp{}frequency\hyp{}related material parameters.]{\label{tab_Theory_Materials}High\hyp{}frequency\hyp{}related material parameters.  Based on a table in reference \citenumns{Mishra_RF_Amps}, some data from reference \citenumns{Willardson_SiC}.}
\small{
\begin{tabular}{@{}l@{}S@{}S@{}S@{}S@{}S@{}S@{}S@{}S@{}}
\toprule
&\multicolumn{1}{c}{$E_g$\tnote{a}}&\multicolumn{1}{c}{$n_i$\tnote{b}}&\multicolumn{1}{c}{$\epsilon_r$\tnote{c}}&\multicolumn{1}{c}{$\mu_n$\tnote{d}}& \multicolumn{1}{c}{$v_\mathrm{sat}$\tnote{e}}&\multicolumn{1}{c}{$E_\mathrm{br}$\tnote{f}}&\multicolumn{1}{c}{$\mathit{TC}$\tnote{g}}& \multicolumn{1}{c}{$\mathit{JM}$\tnote{h}}\\
&\multicolumn{1}{c}{\small{\si{\eV}}}&\multicolumn{1}{c}{\small{\si{\cm^{-3}}}}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{\small{\si{\cm\per\volt\per\s}}}& \multicolumn{1}{c}{\small{$\times 10^7$\si{\cm\per\s}}}&\multicolumn{1}{c}{\small{\si{\mega\volt\per\cm}}}&\multicolumn{1}{c}{\small{\Wmk}}&\multicolumn{1}{c}{}\\
\midrule\\
Si&1.1&1.5e10&11.8&1350&1.0&0.3&150&1\\
%\sisetup{scientific-notation=true}
GaAs&1.42&1.5e5&13.1&8500&1.0&0.6&43&2.7\\
%\sisetup{scientific-notation=false}
SiC (4H)&3.26&8.2e-9&10&700&2.0&3.0&450\tnote{~i}&20\\
GaN&3.4&1.9e-10&9.0&2000\tnote{~j}&2.5&3.3&130&27.5\\
Diamond&5.4&1.6e-27&5.5&1900&2.7&5.6&2000&50\\
\bottomrule

\end{tabular}}
\begin{tablenotes}
\setlength{\columnsep}{0.8cm}
\setlength{\multicolsep}{0cm}
\begin{multicols}{2}\raggedright
\item[a] Bandgap.
\item[b] \rep{Intrinsic c}{C}arrier density \add{at room temperature}.
\item[c] Relative permittivity.
\item[d] Electron mobility.
\item[e] Saturation velocity.
\item[f] Breakdown field.
\item[g] \Acl{TC} \add{at room temperature. The \acl{TC} reduces with temperature at typical operating temperatures,\supercite{Luo_TC_T} for GaN $\mathit{TC}\propto T^{-1.4}$ is often used, though values vary}.
\item[h] Johnson figure of merit, which compares the power\hyp{}frequency performance of materials, normalised to the value for Si. $JM=\rfrac{E_\mathrm{br}v_\mathrm{sat}}{2\pi}$.
\item[i] In-plane; parallel to the $c$-axis the \acl{TC} is 330~\Wmk.
\item[j] Within the \acs{2DEG}; the bulk value is \SI[scientific-notation=false]{1200}{\cm\per\volt\per\s}.
\end{multicols}
\end{tablenotes}
\end{threeparttable}

• Is your answer intended for this question? – Zarko Oct 18 at 12:40
• @Zarko yes: use multicols around the enumerate, as I use it round my list – Chris H Oct 18 at 12:42
• well, op explicitly say that it not like to use multicol nor task package. Also items contain math expression which should be should be aligned. – Zarko Oct 18 at 12:45
• ... I could cook up a simpler example, but had one that demonstrates the features – Chris H Oct 18 at 12:45
• @Zarko I missed the OP's "I don't want to use a very suitable package". I'll see if I can quickly demonstrate why it's good for the OP's example – Chris H Oct 18 at 12:46

You say that you not like tasks package and till to now doesn't say, why not liked it (I ask for this in my comment). Also the purposes of horizontal rules, which you show, is unclear.

However, for the cases as you show in your question, the tasks package has been developed. With it you can simply align items horisontaly as well verticaly:


\documentclass{article}
\usepackage[textheight=21cm,textwidth=16cm]{geometry}
\usepackage{amsmath}
label = \arabic*.
}

\begin{document}

Example 1 -- Two columns
\task   $f(x) = 2x^3-3x^2+5x-1$
\task   $f(x) = \dfrac{x+3}{2x-4}$
\task   $f(x) = \sqrt{3x-12}$
\task   $f(x) = \dfrac{2}{\sqrt{6-2x}}$

\vspace{1cm}

Example 2 -- Three columns
\task   $f(x) = 2x^3-3x^2+1$
\task   $f(x) = \dfrac{x+3}{2x-4}$
\task   $f(x) = \sqrt{3x-12}$
\task   $f(x) = \dfrac{2}{\sqrt{x^2-1}}$
\task   $f(x) = \dfrac{x}{x+1}$
\task   $f(x) = \sqrt{x+\dfrac{1}{x}}$

\end{document}


Similar result with use of the eninumitem package is very difficult if even impossible to achieve. However, similar result without use of tasks package you can obtain with use of an array:


\documentclass{article}
\usepackage[fleqn]{nccmath}
\usepackage{booktabs}

\begin{document}

Example 1 -- Two columns

$\displaystyle \begin{array}{cc @{\qquad} cc} 1. & f(x) = 2x^3-3x^2+5x-1 & 2.& f(x) = \dfrac{x+3}{2x-4} \\ \addlinespace 3. & f(x) = \sqrt{3x-12} & 4.& f(x) = \dfrac{2}{\sqrt{6-2x}} \end{array}$
\end{document}


• Thank you for your answer! I keep that this is very difficult with the enumitem package. There is no specific reason I don't use the tasks package. My question was how can I align the items in enumerate environment not which package to use for this. – Fotis K Oct 18 at 22:08
• I clearly say, that this is very difficult or even impossible. enumitem has not be designed for such purposes, but tasks has been. So, it is difficult to understand, why you not like to use right tools, and persist with one, which is not and consequently causes to you only problems. – Zarko Oct 18 at 22:26
• I don't disagree with you! I use both of them but I was wondering how I could do it with the enumitem package. Anyway thank you for your time again! – Fotis K Oct 18 at 22:38

My solution

\documentclass[a4paper,12pt]{article}

\usepackage[margin=1in]{geometry}
\usepackage{enumitem}
\usepackage{etoolbox}

\everymath{\displaystyle}
\setlength{\parindent}{0pt}

\renewcommand{\labelenumi}{\large\textbf{\arabic{enumi}{.}}}
\renewcommand{\labelenumii}{\alph{enumii}{)}}

%--------------------------------------------------------------------------
\newlength{\enumlen}
\AtBeginEnvironment{enumerate}{\setlength{\enumlen}{\linewidth}}
\makeatletter
\newcommand{\initem}[2][]{
\ifx&#1&
\ifnum\enit@type=\z@\refstepcounter{\@listctr}\fi
\hfill
\makebox[0.5\enumlen][l]
{\makebox[\labelwidth][r]{\@itemlabel}\hspace{\labelsep}{#2}}
\else
\ifnum\enit@type=\z@\refstepcounter{\@listctr}\fi
\hfill
\makebox[\dimexpr(\enumlen/3)][l]
{\makebox[\labelwidth][r]{\@itemlabel}\hspace{\labelsep}{#1}}%
\ifnum\enit@type=\z@\refstepcounter{\@listctr}\fi
\makebox[\dimexpr(\enumlen/3)][l]
{\makebox[\labelwidth][r]{\@itemlabel}\hspace{\labelsep}{#2}}
\fi
}
\makeatother
%--------------------------------------------------------------------------
\begin{document}
\begin{enumerate}
\item
\rule{0.5\linewidth}{0.5pt}\\
\hphantom{\rule{0.5\linewidth}{0.5pt}}\rule{0.5\linewidth}{0.5pt}
\begin{enumerate}
\item   $f(x)=2x^3-3x^2$
\initem {$f(x)=2x^3-3x^2$}
\item   $f(x)=2x^3-3x^2$
\initem {$f(x)=2x^3-3x^2$}
\item   $f(x)=2x^3-3x^2$
\initem {$f(x)=2x^3-3x^2$}
\end{enumerate}
\item
\rule{0.33333\linewidth}{0.5pt}\\
\hphantom{\rule{0.33333\linewidth}{0.5pt}}\rule{0.33333\linewidth}{0.5pt}\\
\hphantom{\rule{0.66666\linewidth}{0.5pt}}\rule{0.33333\linewidth}{0.5pt}
\begin{enumerate}
\item   $f(x)=2x^3-3x^2$
\initem [$f(x)=2x^3-3x^2$]
{$f(x)=2x^3-3x^2$}
\item   $f(x)=2x^3-3x^2$
\initem [$f(x)=2x^3-3x^2$]
{$f(x)=2x^3-3x^2$}
\item   $f(x)=2x^3-3x^2$
\initem [$f(x)=2x^3-3x^2$]
{$f(x)=2x^3-3x^2$}
\item   $f(x)=2x^3-3x^2$
\initem [$f(x)=2x^3-3x^2$]
{$f(x)=2x^3-3x^2$}
\item
\rule{0.5\linewidth}{0.5pt}\\
\hphantom{\rule{0.5\linewidth}{0.5pt}}\rule{0.5\linewidth}{0.5pt}
\begin{enumerate}
\item   $f(x)=2x^3-3x^2$
\initem {$f(x)=2x^3-3x^2$}
\item   $f(x)=2x^3-3x^2$
\initem {$f(x)=2x^3-3x^2$}
\item   $f(x)=2x^3-3x^2$
\initem {$f(x)=2x^3-3x^2$}
\item   $f(x)=2x^3-3x^2$
\initem {$f(x)=2x^3-3x^2$}
\item   $f(x)=2x^3-3x^2$
\initem {$f(x)=2x^3-3x^2$}
\end{enumerate}
\item
\rule{0.33333\linewidth}{0.5pt}\\
\hphantom{\rule{0.33333\linewidth}{0.5pt}}\rule{0.33333\linewidth}{0.5pt}\\
\hphantom{\rule{0.66666\linewidth}{0.5pt}}\rule{0.33333\linewidth}{0.5pt}
\begin{enumerate}
\item   $f(x)=2x^3-3x^2$
\initem [$f(x)=2x^3-3x^2$]
{$f(x)=2x^3-3x^2$}
\item   $f(x)=2x^3-3x^2$
\initem [$f(x)=2x^3-3x^2$]
{$f(x)=2x^3-3x^2$}
\item   $f(x)=2x^3-3x^2$
\initem [$f(x)=2x^3-3x^2$]
{$f(x)=2x^3-3x^2$}
\end{enumerate}
\end{enumerate}
\end{enumerate}
\end{document}


Here is a far from perfect way to do this without any additionnal package. IMO, the tasks package is a better way to do it.

You could put your equation in a box of a fixed width. By choosing the right value for the width of the box, you could be close to the desired result.

\documentclass{article}

\usepackage[textheight=21cm,textwidth=16cm,]{geometry}
\usepackage{enumitem}

\setlength{\parindent}{0pt}
\everymath{\displaystyle}

\makeatletter
\newcommand{\initem}{\ifnum\enit@type=\z@\refstepcounter{\@listctr}\fi
\@itemlabel\hspace{\labelsep}}
\makeatother

\newlength{\mylength}    % define a length for the width of the box
\newcommand{\mybox}[1]{\makebox[\mylength][l]{#1}}    % define a command to make it easier to change things

\begin{document}

Example 1 -- Two columns \\
\rule{0.5\linewidth}{0.5pt} \\
\hphantom{\rule{0.5\linewidth}{0.5pt}}
\rule{0.5\linewidth}{0.5pt}
\setlength{\mylength}{205pt}    % approximate width needed
\begin{enumerate}
\item  \mybox{$f(x)=2x^3-3x^2+5x-1$}
\initem  \mybox{$f(x)= \frac{x+3}{2x-4}$}
\item    \mybox{$f(x)= \sqrt{3x-12}$}
\initem  \mybox{$f(x)= \frac{2}{\sqrt{6-2x}}$}
\end{enumerate}

\vspace{1cm}

Example 2 -- Three columns \\
\rule{0.333\linewidth}{0.5pt} \\
\hphantom{\rule{0.333\linewidth}{0.5pt}}
\rule{0.333\linewidth}{0.5pt} \\
\hphantom{\rule{0.333\linewidth}{0.5pt}}
\hphantom{\rule{0.333\linewidth}{0.5pt}}
\rule{0.334\linewidth}{0.5pt}
\setlength{\mylength}{135pt}    % approximate width needed
\begin{enumerate}
\item    \mybox{$f(x)=2x^3-3x^2+1$}
\initem  \mybox{$f(x)= \frac{x+3}{2x-4}$}
\initem  \mybox{$f(x)= \sqrt{3x-12}$}
\item    \mybox{$f(x)= \frac{2}{\sqrt{x^2-1}}$}
\initem  \mybox{$f(x)= \frac{x}{x+1}$}
\initem  \mybox{$f(x)= \sqrt{x+\frac{1}{x}}$}
\end{enumerate}

\end{document}


The value 205pt and 135pt have been found by trial and error and are not a perfect fit. Maybe there is a way to improve this by using the calc package.

• Thank you very much! All the answers were useful to me especially with the new command \mybox. – Fotis K Oct 23 at 21:58

A way to do this with the tabularx package. It is a piece of code I found on the internet a few years back (I sadly don't remember where). I used it a lot until I switch to the tasks package.

\documentclass{article}

\usepackage[textheight=21cm,textwidth=16cm,]{geometry}
\usepackage{enumitem}

\setlength{\parindent}{0pt}
\everymath{\displaystyle}

\usepackage{tabularx}

\newcounter{row}
\renewcommand{\therow}{\arabic{row}}
\newenvironment{rowenum}[1]
{\setcounter{row}{0}%
\par\noindent\tabularx{\linewidth}[t]
{*{#1}{>{\stepcounter{row}\makebox[1.8em][r]{\therow.\hspace{0.5em}}}X}}%
}
{\endtabularx}

\begin{document}

Example 1 -- Two columns \\
\rule{0.5\linewidth}{0.5pt} \\
\hphantom{\rule{0.5\linewidth}{0.5pt}}
\rule{0.5\linewidth}{0.5pt}
\begin{rowenum}{2}
$f(x)=2x^3-3x^2+5x-1$   &$f(x)= \frac{x+3}{2x-4}$\\
$f(x)= \sqrt{3x-12}$   &$f(x)= \frac{2}{\sqrt{6-2x}}$
\end{rowenum}

\vspace{1cm}

Example 2 -- Three columns \\
\rule{0.333\linewidth}{0.5pt} \\
\hphantom{\rule{0.333\linewidth}{0.5pt}}
\rule{0.333\linewidth}{0.5pt} \\
\hphantom{\rule{0.333\linewidth}{0.5pt}}
\hphantom{\rule{0.333\linewidth}{0.5pt}}
\rule{0.334\linewidth}{0.5pt}
\begin{rowenum}{3}
$f(x)=2x^3-3x^2+1$   &$f(x)= \frac{x+3}{2x-4}$   &$f(x)= \sqrt{3x-12}$\\
$f(x)= \frac{2}{\sqrt{x^2-1}}$   &$f(x)= \frac{x}{x+1}$   &$f(x)= \sqrt{x+\frac{1}{x}}$
\end{rowenum}

\end{document}


tabularx create a table as large as the textwidth. This table is split into how many cell we need (required argument). Every cell start with a number, using a latex counter.

This is not the perfect solution. I always tought that the line were too close. I had to manually adjust the line spacing to make it easier to read. It was a lot of work.