填空:红色虚线文字

填空:红色虚线文字

我正在努力实现已经实现的目标填空:文本换行和数学模式但使用虚线。该线的长度应为\textwidth或,\linewidth并且应允许换行。这是我的 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

您可以使用建议的解决方案填空:文本换行和数学模式添加空白下划线:

在此处输入图片描述

\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}

答案2

这个怎么样?

\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} 

在此处输入图片描述

相关内容