為自訂環境中的所有文字新增底線(或以其他方式格式化)

為自訂環境中的所有文字新增底線(或以其他方式格式化)

我正在嘗試定義一個自訂環境,其中所有文字都帶有下劃線。我知道該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

您正在尋找soulutf8environ。但是,請再考慮一下底線。

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

在此輸入影像描述

相關內容