2

I am trying to achieve what is already in Fill in the blank: text wrapping & math mode but with dotted lines. The line should have the length of a \textwidth or \linewidth and it should allow line break. This is my MWE:

\documentclass[a4paper,11pt]{report}
\usepackage{lipsum}
\usepackage{ulem,xcolor}

\newcommand\ulemfill{\bgroup\color{red}\markoverwith{\textcolor{black}{\rule[-.6ex]{2pt}{.5pt}}}\ULon}

\begin{document}

\begin{enumerate}
\item My name is \ulemfill{Nadia \hfill}
\item My hobby is \ulemfill{\lipsum[1] \hfill}
\end{enumerate}

\end{document}
1

You can use the solution suggested in Fill in the blank: text wrapping & math mode by adding a blank underline:

enter image description here

\documentclass{article}

\usepackage{ulem,xcolor}

\makeatletter
\newcommand{\ulemfill}[1]{\ulemfill@{#1\hfill\mbox{}}}
\newcommand{\ulemfill@}{\bgroup\color{red}\markoverwith % change red to white to hide text
  {\textcolor{black}{\rule[-.6ex]{.3ex}{.5pt}\rule[-.6ex]{.3ex}{0pt}}}\ULon}% underline color for ulem
                    % ^ Solid rule             ^ Blank rule

\begin{document}

\ulemfill{%
  Nadia%
}

\ulemfill{%
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam a venenatis lacus. Nunc vitae 
  mollis neque. Maecenas vel arcu erat. In bibendum cursus interdum. Orci varius natoque penatibus 
  et magnis dis parturient montes, nascetur ridiculus mus. Nulla aliquet arcu eget velit mollis 
  ultricies. Phasellus arcu sem, bibendum ut lorem non, interdum dictum mi. Nulla vitae libero 
  congue, ullamcorper odio ac, ultrices magna. Suspendisse bibendum tortor eu risus laoreet, ac 
  consequat arcu commodo. Nullam sagittis nibh semper dui tempus accumsan. Vivamus tempor dapibus 
  ante sit amet vulputate.%
}

\end{document}
  • Thank you! The code works in an enumerate environment too. – Nadia Sep 8 '18 at 5:31
1

How about this?

\documentclass[a4paper,11pt]{report}

\usepackage{ulem,xcolor, linegoal}

\newcommand\udotfill[1]{\hspace{-0.65em} \rlap{\raisebox{-0.6ex}{\makebox[\linegoal]{\dotfill}}} \color{red}#1}

\begin{document}

My name is \udotfill{Aiman}

\end{document} 

enter image description here

  • The code does not work when I put it in an enumerate environment. Everything is written in red and the dots do not span the line. – Nadia Aug 28 '18 at 14:58
  • @Nadia: For the color problem, replace \color{red}#1 with \textcolor{red}{#1}. For the dots span in lists, I'll try to find a solution. – Bernard Aug 29 '18 at 9:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.