How to align an enumerated list in latex?

Deep picture Deep · Jan 1, 2020 · Viewed 11.9k times · Source

Suppose I want to center align the enumerated list. I did this:

\begin{center}
\begin{enumerate}[label=(\Roman*)]
\item  Equation 1
\item  Equation 2
\item  Equation 3
\item  Equation 4
\end{enumerate}
\end{center}

This is not working nicely. I have also tried without 'enumerate' and just 'center' and labeling manually. It does work but the alignment is not looking perfect.

Also instead for center we can also do:

I. Equation 1 \quad II. Equation 2

III. Equation 3 \quad IV.Equation 4

Answer

Alain Merigot picture Alain Merigot · Jan 1, 2020

You cannot center an item list like that. Enumerate is a formatting environment that will supersedes the center environment.

What can be done is to put the enumerate list in a box (like a minipage), and to center this box.

Standard minipage requires a width, but there is a package (varwidth) that allows to define minipages with an unknown width (more precisely, you give a width parameter, but if width is smaller than that, the actual with is used).

So here is a solution with varwidth.

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


\begin{center}
\begin{varwidth}{\textwidth}
\begin{enumerate}[label=(\Roman*)]
\item  Equation 1
\item  Equation 2
\item  Equation 3
\item  Equation 4
\end{enumerate}
\end{varwidth}
\end{center}
\end{document}

enter image description here

If you want to have several enumerate items per line, your solution is not very robust, as you must adjust the spacing depending on the item length if you want your items to be aligned.

The 'tabto' package provides a way to do the alignment in a flexible way. But the best solution is to use the 'tasks' package that allows to define columned list. This package is not as smart as others to determine the item width and, if required, this must be given explicitely. The parenthesized parameter is the number of columns. As previously, if you want to center globally the environment, you must use varwidth.

\begin{center}
\begin{varwidth}{\textwidth}
\begin{tasks}[label={(\Roman*)},label-width={1cm}](2)
\task  Equation 1
\task  Equation 2
\task  Equation 3
\task  Equation 4
\end{tasks}
\end{varwidth}
\end{center}

enter image description here

For simple lists like yours, a tabular could also be used.