I have a collection of multiple choice questions that use the enumerate environment. In some cases, I'd like the align the answers (items) in specific ways. For example, I might want to align numbers at their decimal points like this:

enter image description here enter image description here

I aligned the decimal points in this example using phantoms and llaps, but I'm curious if there's a better/slicker way that doesn't require as much manual tweaking -- something analogous to an align* environment that I could wrap around the enumerate items and just stick ampersands where needed?

Since I have a lot of multiple choice questions I'd like to change, I'm hoping to make this as easy as possible, and it would be great if it didn't break my enumerate environments.

MWE:

\documentclass{article}

\begin{document}

  \begin{enumerate}
    \item What is the meaning of life?
    \begin{enumerate}
      \item $1.618$    
      \item $2.71828$
      \item $3.14159$
      \item $42.00$
      \item $1000.00$
    \end{enumerate}
  \end{enumerate}

  \begin{enumerate}
    \item What is the meaning of life?
    \begin{enumerate}
      \item $\phantom{1000.000}\llap{1.618}$
      \item $\phantom{1000.00000}\llap{2.71828}$
      \item $\phantom{1000.00000}\llap{3.14159}$
      \item $\phantom{1000.00}\llap{42.00}$
      \item $\phantom{1000.00}\llap{1000.00}$
    \end{enumerate}
  \end{enumerate}

\end{document}

You can emulate the labels of an enumerate environment in the first column of a table, with package listliketab and use siunitxto align the numbers in the second column on the decimal dots, with the S column type. You even can cross-reference the items:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{siunitx, listliketab}

    \begin{document}

\storestyleof{enumerate}
\begin{listliketab}
\newcounter{tabenum}\setcounter{tabenum}{0}\renewcommand\thetabenum{(\alph{tabenum})}
\newcommand{\tabitem}{\refstepcounter{tabenum}\thetabenum}
\begin{tabular}{@{}L S[table-format=4.5, table-number-alignment=center]@{}}
  \tabitem & 1.618 \\
   \tabitem\label{row-2} & 2.71828 \\
   \tabitem & 3.14159 \\
   \tabitem & 42.00 \\
   \tabitem & 1000.00
\end{tabular}
\end{listliketab}

We read in row \ref{row-2} an approximate value of Euler’s number $e$. 

\end{document} 

enter image description here

  • 1
    Thanks for editing, @sigur! – Bernard Oct 21 at 15:07
  • thanks! that's helpful and formats this case how i want. i'm ideally hoping to change my existing database less drastically though. and also, there are a lot of other cases when i want to align differently. e.g. i have answers with equations and pos/neg integers that i'd like to align at the first digit. would be great if there's a general way of doing it. – lwad Oct 21 at 15:54
  • Solutions might be very specific, depending on the case at hand. I suggest you edit your question with samples of the cases you meet in practice. – Bernard Oct 21 at 16:00

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.