I'm trying to do the usual "make a worksheet with blank spaces", and I need blanks longer than the text which will eventually fill them (so that students can write in answers by hand). Unfortunately, my command "blank" prints a strange amount of space before evaluating in the text. If I just insert the same command in the body, it evaluates normally.
\documentclass[]{article}
\newlength\mylen
\newlength\fieldlen
\newcommand\blank[1]{%
\settowidth\mylen{#1}
\settowidth\fieldlen{0}
\addtolength\fieldlen{\mylen}
\addtolength\fieldlen{\mylen}
\underline{\makebox[\fieldlen]{}} %comment this line and uncomment next line to hide answers
%\underline{\makebox[\fieldlen]{#1}} %comment this line and uncomment previous line to show answers
}
\begin{document}
Using the macro, I get the following:
We find that $G<$\blank{$G_1$}.
There's an extra space before the underline.
I want it to look like:
We find that $G<$\underline{\makebox[\fieldlen]{}}.
\end{document}