# Using enumerate, align and table

I'm trying to write these exercises, aligned with the "=" sign, in two columns. This is what I have:

\documentclass[12pt,norsk,a4paper,twoside]{article}
\usepackage{amsmath}
\usepackage[lmargin=25mm,rmargin=25mm,tmargin=25mm,bmargin=25mm]{geometry}
\usepackage{multicol}
\usepackage{enumerate}
\begin{document}
\begin{multicols}{2}
\begin{enumerate}
\item 16 mg = \underline{\hspace{1.4cm}} $\mu$g (mikrogram)
\item 50 mg = \underline{\hspace{1.4cm}} $\mu$g (mikrogram)
\item 5 mg  = \underline{\hspace{1.4cm}} $\mu$g (mikrogram)
\item 0,1 mg  = \underline{\hspace{1.4cm}} $\mu$g (mikrogram)
\item 22,5 mg = \underline{\hspace{1.4cm}} $\mu$g (mikrogram)
\item 0,005 mg = \underline{\hspace{1.4cm}} $\mu$g (mikrogram)
\end{enumerate}
\end{multicols}
\end{document}


How can I align each line by the "=" sign? It doesn't work to use align combined with enumerate.

Cheers

• Welcome to TeX.SX! When I compile your snippet I get a different output. Could you please complete your snipped with the \documentclass and the required \usepackages to compile it, please? Don't forget to compile the example before to make sure it works :) – Phelype Oleinik Jul 3 '18 at 12:00
• Sorry, I'm quite new to LaTex and this is my first post, does it work now? – Sofia Jul 3 '18 at 12:03
• @No problem, we're all here to learn :) Except for the missing \begin{document} and \end{document} it works. Next time make sure that the code sample you post compiles, so that people can just copy/paste it ;) – Phelype Oleinik Jul 3 '18 at 12:09
• You're welcome :) But sorry, I don't know the answer. I tried adding an \hfill to the left of the = (\item 16 mg \hfill = \underline{\hspace{1.4cm}} $\mu$g (mikrogram)), but it added too much space... – Phelype Oleinik Jul 3 '18 at 12:28

Here is a suggestion that uses a tabular:

\documentclass[12pt,norsk,a4paper,twoside]{article}
\usepackage{amsmath}
\usepackage[lmargin=25mm,rmargin=25mm,tmargin=25mm,bmargin=25mm]{geometry}
\usepackage{array}

\begin{document}

\renewcommand{\arraystretch}{1.5}
\setlength{\tabcolsep}{3pt}
\noindent
\begin{tabular*}{\textwidth}{lr<{~mg~=~\underline{\hspace{1.4cm}} $\mu$g (mikrogram)\hspace{1.75cm}}lr<{~mg~=~\underline{\hspace{1.4cm}} $\mu$g (mikrogram)}}
1. & 16  & 4. & 0,1\\
2. & 50  & 5. & 22,5 \\
3. & 5   & 6. & 0,005\\
\end{tabular*}

\end{document}


As observed in the comments, the above example only works as expected if one has an even number of entries. With an odd number of entries, mg = ____ µg (mikrogram) will also be printed if there there is no entry in the corresponding cell.

To overcome this, one can use an enumerate relying approach as explained in the answers to this question: Custom alignment of text in itemized environment or use the following modified version of David Carlisle's answer about balancing a longtable in a multicols environment:

\documentclass[11pt, a4paper]{article}

\usepackage[lmargin=25mm,rmargin=25mm,tmargin=25mm,bmargin=25mm]{geometry}
\usepackage{longtable}
\usepackage{multicol}
\usepackage{array}

\newsavebox\ltmcbox
\newcounter{entryno}
\setcounter{entryno}{1}

\begin{document}
\begin{multicols}{2}
\setbox\ltmcbox\vbox{
\makeatletter\col@number\@ne
\begin{longtable}{>{\the\value{entryno}.\addtocounter{entryno}{1}\enspace}r<{~mg~=~\underline{\hspace{1.4cm}} $\mu$g (mikrogram)}}
16\\
50\\
5\\
\end{longtable}
\unskip
\unpenalty
\unpenalty}
\unvbox\ltmcbox
\end{multicols}
\end{document}

• You're welcome. If you prefer an enumerate based solution, you might be interested in the following: Custom alignment of text in itemized environment – leandriis Jul 3 '18 at 13:09
• In the case where the second column in the last row doesn't have an exercise, for example only 1) 2) 3) This code still writes out mg = ____ µg, while I write 2. & 1,7 & & \\ . Is there any way around this? – Sofia Jul 3 '18 at 13:56
• @Sofia: This is due to the way that text is generated. With the table in my anwer, it is inserted after the contents of every row regardless of if the cell is empty or filled. If you have an odd number of exercises, you might be better off using one of the solutions in the question I linked in my previous comment. – leandriis Jul 3 '18 at 14:05

A combination of tasks and eqparbox, plus the recommended siunitx for units.

\documentclass[12pt,norsk,a4paper,twoside]{article}
\usepackage[
lmargin=25mm,
rmargin=25mm,
tmargin=25mm,
bmargin=25mm,
heightrounded,
]{geometry}

\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{amsmath}
\usepackage{siunitx}
\usepackage{textgreek}

\usepackage{eqparbox}

\sisetup{
output-decimal-marker={,},
math-micro=\textup{\textmu},
text-micro=\textmu,
}

\begin{document}


Remember to \stepcounter{taskc} in order to update the necessary label for \eqmakebox.