Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I wonder how I can align the part questions in the exam class.

MWE:

\documentclass[12pt, norsk,a4paper]{exam}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage{fouriernc}
\usepackage{siunitx}
\usepackage{multicol}
\begin{document} 

\newcommand\tegnboks{~\fbox{\phantom{$=$}}~}

\begin{questions}
% Basic question
\addpoints
\question[4] Sett inn riktig symbol: $<$, $>$ eller $=$
\begin{multicols}{2}
    \begin{parts}
        \part[1] \num{2,6}\tegnboks\num{2,43}
        \part[1] \num{4,16}\tegnboks\num{3,86}
        \part[1] \num{8,45}\tegnboks\num{8,732}
        \part[1] \num{5.7}\tegnboks\num{5.699}
    \end{parts}
\end{multicols}
\end{questions}
\end{document}

With the example above the result is

enter image description here

which doesn't look good. How can I align the parts around the \tegnboks command while keeping (a), (b), ... left aligned?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

I put the argument to the left of the \tegnboks into a box (default width same as 0.00), using \snum. You can pass an optional string argument to \snum to resize the width of the box (to the string width). I also right-aligned the matter to the left of the \tegnbokx, which can easily be redefined to a different alignment, if you prefer.

\documentclass[12pt, norsk,a4paper]{exam}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage{fouriernc}
\usepackage{siunitx}
\usepackage{multicol}
\usepackage{calc}
\newcommand\snum[2][0.00]{\makebox[\widthof{#1}][r]{\num{#2}}}
\begin{document} 

\newcommand\tegnboks{~\fbox{\phantom{$=$}}~}

\begin{questions}
% Basic question
\addpoints
\question[4] Sett inn riktig symbol: $<$, $>$ eller $=$
\begin{multicols}{2}
    \begin{parts}
        \part[1] \snum{2,6}\tegnboks\num{2,43}
        \part[1] \snum{4,16}\tegnboks\num{3,86}
        \part[1] \snum{8,45}\tegnboks\num{8,732}
        \part[1] \snum{5.7}\tegnboks\num{5.699}
    \end{parts}
\end{multicols}
\end{questions}
\end{document}

enter image description here

share|improve this answer

If you know the longest or desired part of equations, you can make an appropriate box (the second part is modified twice). Here left-hand part is left aligned.

\documentclass[12pt, norsk,a4paper]{exam}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage{fouriernc}
\usepackage{siunitx}
\usepackage{multicol}
\begin{document} 

\newcommand\tegnboks{~\fbox{\phantom{$=$}}~}

\newlength\dlug
\settowidth{\dlug}{4.16}
\def\MB#1{\makebox[\dlug][l]{#1}}

\begin{questions}
% Basic question
\addpoints
\question[4] Sett inn riktig symbol: $<$, $>$ eller $=$
\begin{multicols}{2}
    \begin{parts}
        \part[1] \num{2,6}\tegnboks\num{2,43}
        \part[1] \num{4,16}\tegnboks\num{3,86}
        \part[1] \num{8,45}\tegnboks\num{8,732}
        \part[1] \num{5.7}\tegnboks\num{5.699}
    \end{parts}
\end{multicols}

\begin{multicols}{2}
 \begin{parts}
        \part[1] \MB{\num{2,6}}\tegnboks\num{2,43}
        \part[1] \MB{\num{4,16}}\tegnboks\num{3,86}
\settowidth{\dlug}{4.16123}
        \part[1] \MB{\num{8,45}}\tegnboks\num{8,732}
        \part[1] \MB{\num{5.7}}\tegnboks\num{5.699}
    \end{parts}
\end{multicols}
\end{questions}
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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