When trying to use underlined blank spaces for a questionary inside a book, I'm getting the underline out of document margings. Does anyone knows how to make underline command respect the document margins?
Code:
\documentclass[11pt]{elegantbook}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\usepackage{soul}
% Underlined spaces command
\newcommand{\uline}[1]{\underline{\hspace{#1}}}
\title{Document Title}
\subtitle{Subtitle}
\begin{document}
\maketitle
\frontmatter
\mainmatter
\chapter*{Introduction}
\Large
\begin{enumerate}
\item Test text test text test text test text. Test text test text test text test text test text. Test text test text test text test text. Test text test text test text test text test text.
\item Test text \uline{4cm} test \uline{4cm} test text test text test text test text.
% The following line is the one that is not respecting margins
\item Test \uline{4cm} test text test text test text test text \uline{5cm} test text test text test text.
\end{enumerate}
\end{document}
Output:

\uline{2cm}or\linebreak\uline{5cm}– Fran Feb 25 '20 at 07:25\hspaceor any other type of box. Think that latex boxes are like characters, unbreakables. But some like\ul{~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~}is easy to write, highly breakable ... and even look more like the final output. – Fran Feb 25 '20 at 08:36\ul{~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~}option, easy to write and text doesn't get too hurt with the\linebreak– obedmr Feb 25 '20 at 16:23