我正在尝试定义一个自定义环境,其中所有文本都带有下划线。我知道该underline
命令会为其输入加下划线,但我不知道如何让它与我的环境无缝协作:
\documentclass{article}
\newenvironment{myenvironment}{\underline}{}
\begin{document}
Not underlined
\begin{myenvironment}
Only first character is underlined
\end{myenvironment}
\underline{Underlined correctly}
\end{document}
我如何将underline
(或其他命令)应用到环境内的所有文本?
如果重要的话,请使用 xelatex 2015。
答案1
您正在寻找soulutf8
和environ
。但是,请再考虑一下下划线。
\documentclass{article}
\usepackage{fontspec}
\usepackage{soulutf8,environ}
\NewEnviron{myenvironment}{\expandafter\ul\expandafter{\BODY}}
\begin{document}
Not underlined
\begin{myenvironment}
All words are underlined
All words are underlined
All words are underlined
All words are underlined
All words are underlined
\end{myenvironment}
\ul{Underlined correctly}
\end{document}