I was implementing the code found in this Q/A How to put a long piece of text in a box? to create a command for a paragraph text inside a framed box. However the box goes too far into the margin causing an Overfull \hbox warning. Running the code from the accepted answer gives the same problem. My expectation was that by providing \textwidthas an argument would have the box be the proper width, but it does not (probably because of padding within the boxes?). How do I go about getting this box to be the proper width?
\documentclass[draft]{article}
\newcommand{\answer}[1]{
\noindent\fbox{%
\parbox{\linewidth}{%
#1 \hfill
}
}%
}
\begin{document}
\answer{test}
\end{document}
I know the alternative of using tcolorbox, but I'm still interested in fixing this without using it.
\fboxhas the width of its contents plus 2\fboxsepplus 2\fboxrule. Try\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}. – Phelype Oleinik Aug 29 '19 at 19:07}%. – Sigur Aug 29 '19 at 19:08