I am new to LaTeX so I am thankful for any help:
Whenever you type normal text in LaTeX it automatically breaks onto the next line if the end of the line is reached. However if you use a box (such as \raisebox) towards the end of the line it forces the box into the same line, even if the end of the line is reached. (As far as I know this results in an "Overfull \hbox" warning.)
\documentclass{article}
\begin{document}
This is some text that automatically goes in the next line if the end of the line is reached.
\raisebox{0.1ex}{This is some text that does not automatically go in the next line if the end of the line is reached. This even goes above the edge of the paper.}
\end{document}
Is there a way to automatically break the box at the end of the line and continue with the box in the next line? If not is the at least a way to automatically put the whole box onto the next line?
Background: I am a teacher and I am trying to create "fill in the blanks"-tasks for my students. I do this by typing normal text and then I use the following command:
\newlength{\diebox}
\newcommand{\blank}[1]{
\settowidth{\diebox}{#1}
\ifprintanswers
\raisebox{0.1ex}{\parbox{2.3\diebox}{\textbf{#1}}}
\else
\raisebox{-0.5ex}{\parbox{2.3\diebox}{\hrulefill}}
\fi}
(\ifprintanswers comes from the exam package)
I use the factor "2.3" so my students have more space to write there answers.
This does work as intended, except at the end of the line where my answers / the hrulefill doesn't break onto the next line.

sloppyparenvironment or\sloppymacro, there remains a problem in your MWE that the box content itself spans more than a single\linewidth. In such a case, nothing can be automatically done...rather you would have to manually break the box into two. – Steven B. Segletes Sep 16 '20 at 15:54