[Tex/LaTex] underline (empty space) until end of line (manual “fill in the blank” to end of line), within enumerated environment

#enumeratefilllinespacingunderline

I keep encountering situations where I would like to quickly include a few "fill-in-the-blank" style underlined horizontal spaces (usually within an enumerated environment) but each time I come to search the tex.SE, all I find in searches are more specific or advanced applications. Even when I use the "questions that may already have your answer" and "similar questions" I don't find anything that addresses this specific case.

It seems to me I should be able to make this happen relatively easily, without necessarily loading a new package (if that's what's best, then that's what's best, but I'm trying to learn how to build up expressions myself, instead of always relying on existing packages), but I can't seem to make it happen.

Until now, I have not posted the question, because I've assumed I'm just not using the right language, but this is the 4th or 5th time that I've done this, so I figure I can't be the only one not finding the result.


Basically, I just want something that behaves like

\newcommand{\myBlank}{\underline{\qquad\qquad\qquad\qquad}.}

or

\newcommand{\myBlank}{\underline{\hspace{5cm}}.}

except, instead of a constant length, have it expand to the remaining space on the current line (i.e. until the end of line).

I tried using glue (which I only recently discovered, and know very little about), but that didn't seem to work, either:

\newlength{\myBlankSp}  
      \setlength{\myBlankSp}{10cm plus 10cm minus 15cm}

\def\myBlank{\underline{\hspace{\myBlankSp}}}

Any simple solutions? Again, both interested in understanding how to create it, but also ensuring that a simple answer (ideally not just calling a package) is actual findable on the SE, as it seems both useful and as though it's the type of issue that can teach you something important about the way LaTeX works.

Best Answer

You are looking for \hrulefill. EDITED to show in an enumerate environment.

\documentclass{article}
\begin{document}
\begin{enumerate}
\item blah \hrulefill.

\item blah blah \hrulefill.

\item blah blah blah \hrulefill. (10pt)
\end{enumerate}
\end{document}

enter image description here

The OP asks for a deeper line. No problem, by setting the parameters for \hrule (which is part of the definition of the \hrulefill).

\documentclass{article}
\usepackage[nopar]{lipsum}
\makeatletter
\newcommand\arulefill{%
  \leaders\hrule\@width0pt\@height-6pt\@depth6.5pt\hfill\kern\z@}
\makeatother
\begin{document}
\begin{enumerate}
\item blah \arulefill.

\item blah blah \arulefill.

\item \lipsum[3] \arulefill. (10pt)
\end{enumerate}
\end{document}

enter image description here


EDITED to include definition provided in comments

The macro uses the concept of leaders (the things that allow a string of dots in a table of contents, for example). In this case, though, it uses an \hrule rather than a dot fill. The actual definition of \hrulefill is \leaders\hrule\hfill\kern\z@

Related Question