控制完形填空文本的行

控制完形填空文本的行

@Martin Scharrer 向我建议了以下制作完形填空文本的绝妙解决方案:https://tex.stackexchange.com/a/16004/4011

\documentclass{article}
\usepackage[normalem]{ulem}

\makeatletter
\def\UL@putbox{\ifx\UL@start\@empty \else % not inner
  \vrule\@width\z@ \LA@penalty\@M
  {\UL@skip\wd\UL@box \UL@leaders \kern-\UL@skip}%
    \phantom{\box\UL@box}%
  \fi}
\makeatother

\begin{document}

Some text \uline{some text to complete some  text to complete
some  text to complete some  text to complete some  text to complete some    text
to complete some  text to complete} some more text.

\end{document}

现在我对这种方法有一些后续问题:

  1. 我该如何调整以便能够选择 ulem 包\dotuline\dashuline和提供的所有“下划线样式” ?\uwave\uuline
  2. 如何调整幻像文本和下划线之间的垂直间距?
  3. \uline是否有可能同时获得一个正常工作的版本?(例如称之为\Uline\Uuline等等)。

答案1

  1. 只需使用它们即可。

  2. \setlength{\ULdepth}{...}

  3. \ifulphantom下面的示例为包的宏添加了可设置启用或禁用幻像版本的开关ulem

完整示例:

\documentclass{article}
\usepackage[normalem]{ulem}

\makeatletter
\@ifdefinable\UL@putbox@original{%
  \let\UL@putbox@original\UL@putbox
  \def\UL@putbox@phantom{%
    \ifx\UL@start\@empty
    \else % not inner
      \vrule\@width\z@
      \LA@penalty\@M
      {\UL@skip\wd\UL@box \UL@leaders \kern-\UL@skip}%
      \phantom{\box\UL@box}%
    \fi
  }%
  \newif\ifulphantom
  \renewcommand*{\UL@putbox}{%
    \ifulphantom
      \expandafter\UL@putbox@phantom
    \else
      \expandafter\UL@putbox@original
    \fi
  }%
}
\makeatother

\usepackage{parskip}

\begin{document}

\ulphantomtrue

\begingroup
  \setlength{\ULdepth}{0pt}

  Some text \uline{some text to complete some  text to complete
  some  text to complete some  text to complete some  text to complete some
  text to complete some  text to complete} some more text.

  \setlength{\ULdepth}{1ex}

  Some text \uline{some text to complete some  text to complete
  some  text to complete some  text to complete some  text to complete some
  text to complete some  text to complete} some more text.
\endgroup

Some text \uuline{some text to complete some  text to complete
some  text to complete some  text to complete some  text to complete some
text to complete some  text to complete} some more text.

Some text \uwave{some text to complete some  text to complete
some  text to complete some  text to complete some  text to complete some
text to complete some  text to complete} some more text.

\ulphantomfalse

\begingroup
  \setlength{\ULdepth}{0pt}

  Some text \uline{some text to complete some  text to complete
  some  text to complete some  text to complete some  text to complete some
  text to complete some  text to complete} some more text.

  \setlength{\ULdepth}{1ex}

  Some text \uline{some text to complete some  text to complete
  some  text to complete some  text to complete some  text to complete some
  text to complete some  text to complete} some more text.
\endgroup

Some text \uuline{some text to complete some  text to complete
some  text to complete some  text to complete some  text to complete some
text to complete some  text to complete} some more text.

Some text \uwave{some text to complete some  text to complete
some  text to complete some  text to complete some  text to complete some
text to complete some  text to complete} some more text.

\end{document}

结果

答案2

我写了一个包裹名为“完形填空”专门用于创建完形填空文本。您必须使用 LuaLaTeX 或 LuaTeX。

\documentclass{article}
\usepackage[show]{cloze}

\begin{document}
Some text \cloze{some text to complete some text to complete some text
to complete some text to complete some text to complete some text to
complete some  text to complete} some more text.
\end{document}

完形填空秀

将全局选项更改为\usepackage[hide]{cloze}或使用\clozehide来隐藏完形填空文本。

完形填空

相关内容