手写文本字段

手写文本字段

我正在准备一本小练习册。我使用灰色空下划线,如下所示这个答案为手写文本留出空白字段。我正在使用\documentclass[a4paper,11pt]{book}

\documentclass[a4paper,11pt]{book}
\usepackage[francais]{babel}
\usepackage{geometry}
\usepackage{xcolor}
\geometry{paperwidth=21cm,paperheight=29.7cm, body={18cm,25.7cm}, top=2.5cm, left=1.5cm}

\begin{document}
{

\frontmatter
\tableofcontents
\cleardoublepage

\mainmatter


\chapter{Hi}
Mathematics is the study of numbers, quantity, space, structure, and change. Mathematics \color{gray}\underline{\hspace{5cm}}\color{black} is used throughout the world as an essential tool in many fields, including natural science, engineering, medicine, and the social sciences. Applied mathematics, the branch of mathematics concerned with application of mathematical knowledge to other fields, inspires and makes use of new mathematical discoveries and sometimes leads to the development of entirely new mathematical disciplines, such as statistics and game theory. Mathematicians also engage in pure mathematics, or mathematics for its own sake, without having any application in mind. There is no clear line separating pure and applied mathematics, and practical applications for what began as pure mathematics are often discove

\end{document}

我得到以下输出

在此处输入图片描述

如您所见,下划线超出了边距,并且其后的单词“is”未显示。我怎样才能让 latex 将这些字段视为普通文本,例如,在\color{gray}\underline{\hspace{5cm}}\color{black}latex 中应将其视为\color{gray}\underline{\hspace{1.5cm}}\color{black} \\ \color{gray}\underline{\hspace{3.5cm}}\color{black}或类似内容?

答案1

也许你可以尝试一下这个dashundergaps包。请参阅文档

\documentclass[a4paper,11pt]{book}
\usepackage[francais]{babel}
\usepackage{geometry}
\usepackage{xcolor}
\usepackage{dashundergaps}
\geometry{paperwidth=21cm,paperheight=29.7cm, body={18cm,25.7cm}, top=2.5cm, left=1.5cm}

\dashundergapssetup{
    ,teacher-mode = true
    ,gap-numbers = false
    %,gap-number-format  = \,\textsuperscript{\normalfont(\thegapnumber)}
    ,gap-font           = \itshape
    ,teacher-gap-format = underline
    ,gap-widen
    ,gap-extend-percent=20
}

\begin{document}
    {

        \frontmatter
        \tableofcontents
        \cleardoublepage

        \mainmatter


        \chapter{Hi}
        Mathematics is the study of numbers, quantity, space, structure, and change. Mathematics \gap{Empty box in student mode} is used throughout the world as an essential tool in many fields, including natural science, engineering, medicine, and the social sciences. Applied mathematics, the branch of mathematics concerned with application of mathematical knowledge to other fields, inspires and makes use of new mathematical discoveries and sometimes leads to the development of entirely new mathematical disciplines, such as statistics and game theory. Mathematicians also engage in pure mathematics, or mathematics for its own sake, without having any application in mind. There is no clear line separating pure and applied mathematics, and practical applications for what began as pure mathematics are often discove

\end{document}

答案2

@egreg 的回答https://tex.stackexchange.com/a/22199/36296可以应用于你的例子:

\documentclass[a4paper,11pt]{book}

\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{geometry}
\usepackage{xcolor}

\geometry{paperwidth=21cm,paperheight=29.7cm, body={18cm,25.7cm}, top=2.5cm, left=1.5cm}

\newcommand{\piece}{\hskip1sp\kern-1sp\hbox to .5cm{\hrulefill}}
\newcommand{\nbpiece}{\hbox to .5cm{\hrulefill}}

\makeatletter
\newcommand{\build}[2]{\leavevmode
  \count@=\z@ \toks@={}%
  \loop\ifnum\count@<\numexpr#1\relax
    \toks@=\expandafter{\the\toks@#2}%
    \advance\count@\@ne
  \repeat
  \the\toks@}
\makeatletter

\newcommand{\blank}[2][1]{%
  \build{#1}{\nbpiece}\build{2*(#2-#1)}{\piece}\build{#1}{\nbpiece}}

\begin{document}

Mathematics is the study of numbers, quantity, space, structure, and change. Mathematics {\color{lightgray}\blank{5}} is used throughout the world as an essential tool in many fields, including natural science, engineering, medicine, and the social sciences. Applied mathematics, the branch of mathematics concerned with application of mathematical knowledge to other fields, inspires and makes use of new mathematical discoveries and sometimes leads to the development of entirely new mathematical disciplines, such as statistics and game theory. Mathematicians also engage in pure mathematics, or mathematics for its own sake, without having any application in mind. There is no clear line separating pure and applied mathematics, and practical applications for what began as pure mathematics are often discove

\end{document}

在此处输入图片描述

相关内容