I am using report class and have been using \framebox[\linewidth]{\rule{0pt}{2cm}} to create an empty box with a certain height. Now, I would like to write in that empty box. By referring to How can I write something in a box with \makeemptybox{1.8in}?, I achieved the following:
\documentclass[a4paper,11pt]{report}
\newcommand{\makenonemptybox}[2]{%
\par\nobreak\vspace{\ht\strutbox}\noindent
\fbox{%
\parbox[c][\dimexpr#1-2\fboxsep][t]{\dimexpr\linewidth-2\fboxsep}{
\hrule width \hsize height 0pt
#2
}%
}%
\par\vspace{\ht\strutbox}
}
\makeatother
\begin{document}
\begin{enumerate}
\item Tell me about yourself.
\begin{enumerate}
\item What is your name?
\makenonemptybox{2cm}{My name is Nadia.}
\item Where are you from?
\makenonemptybox{2cm}{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam a venenatis lacus. Nunc vitae mollis neque. Maecenas vel arcu erat.}
\item How old are you?
\item[] \framebox[\linewidth]{\rule{0pt}{2cm}}
\end{enumerate}
\end{enumerate}
\end{document}
As you can see \makenoemptybox makes a bigger vertical space compared to \framebox (refer to the coloured arrows). How can I make the vertical space made by \makenoemptybox follows that of \framebox?


\makenonemptybox{2cm}{}? – Peter Grill Sep 08 '18 at 07:08\parbox[c][\dimexpr#1-2\fboxsep]in\makenonemptyboxshould have been\parbox[c][#1]to start with, because when\framebox[\linewidth]{\rule{0pt}{2cm}}is used the total height is 2cm +2\fboxsep+2\fboxrule. To do the same with\makenonemptyboxfor the height it thus should be\parbox[c][#1]when#1is2cm. Besides, removing\fboxsepmakes no sense if not removing also\fboxrule, then total height including frame and separation would be2cm. But\framebox[\linewidth]{\rule{0pt}{2cm}}gives2cm+2\fboxsep+2\fboxrule. – Sep 08 '18 at 09:31