在 mdframed 中包装下划线

在 mdframed 中包装下划线

我正在尝试在框内填充空白段落。我一直使用 mdframed 并取得了巨大成功,但下划线空白不会在框内换行。我是 Latex 的新手;我尝试使用 mdframed 文档并尝试为什么带下划线的文本到达行尾后不会换行?带下划线的空白换行(就我目前的能力而言,后者相当复杂)。谢谢你的帮助!

\documentclass{article}

\usepackage{mdframed}

\newcommand{\hard}[1]    {\unskip\underline{\hspace{#1}}\ignorespaces}

\begin{document}

\begin{mdframed}
The population in a study refers to the \hard{2in} \\or \hard{2.5in}.  A sample is a (typically small) \hard{2in} from whom or about which data are gathered to learn about \hard{2in}.  If the sample is selected carefully, so it is \hard{1.5in} of (\hard{2in}) the population, you can learn \hard{2in}. The number of observational units studied in a sample is the \hard{1in}.
\end{mdframed}

\end{document}

答案1

Christian Hupfer 回答了我的问题,但我无法将其标记为已回答。我最终选择了 tcolorbox 包,说实话,它为我输入的笔记提供了很好的对比。

我还尝试了 tcolorbox 文档中的证明,删除了 \unskip 和 \ignorespaces,该包运行良好。我非常感谢您的帮助。

\documentclass{article}

\usepackage{tcolorbox}

\newcommand{\hard}[1]    {\underline{\hspace{#1}}}

\begin{document}

\begin{tcolorbox}[halign=left]
The population in a study refers to the \hard{2in} \\or \hard{2.5in}.  A sample is a (typically small) \hard{2in} from whom or about which data are gathered to learn about \hard{2in}.  If the sample is selected carefully, so it is \hard{1.5in} of (\hard{2in}) the population, you can learn \hard{2in}. The number of observational units studied in a sample is the \hard{1in}.
\end{tcolorbox}

\end{document}

相关内容