I'm writing a math test in the exam class, and I want to make framed boxes for the students to write their answer in. I've tried this solution, but the box exceeds the right page margin by 6.79999pts. What's going wrong here?
MWE:
\documentclass[12pt, a4paper]{exam}
\RequirePackage{amssymb, amsfonts, amsmath, latexsym, verbatim, xspace, setspace}
\usepackage[margin=1in,showframe]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{fouriernc}
\usepackage{calc}
\usepackage{tikz,tikzpagenodes}
\usetikzlibrary{calc}
\newlength{\whatsleft}
\newcommand{\measureremainder}[1]{%
\begin{tikzpicture}[overlay,remember picture]
% Measure distance to right text border
\path let \p0 = (0,0), \p1 = (current page text area.east) in
[/utils/exec={\pgfmathsetlength#1{\x1-\x0}\global#1=#1}];
\end{tikzpicture}%
}
\onehalfspacing
\begin{document}
\begin{questions}
\addpoints
\question[8] \emph{Regn ut:}
\begin{parts}
\part[2] $6-(-4) = $ \measureremainder{\whatsleft}\fbox{\begin{minipage}{\whatsleft}\vspace{2em}\hfill\end{minipage}}
\end{parts}
\end{questions}
\end{document}
Resulting in
