如何制作双波浪下划线?

如何制作双波浪下划线?

我正在使用波浪下划线来突出显示一些文本,但没有制作双波浪线的功能。我希望下划线可以自动换行。有没有方法可以使用 \dwave(双波浪下划线),如下所示?例如,使用\dwave{I am using the wave underline to highlight some text, but there is no function to make a line break. Each time the text was always underlined in a single line. Is there any methods to use \dwave and have the line break result?}

我想要的效果就像 在此处输入图片描述

答案1

修改的定义uwave

%! TEX program = lualatex
\documentclass{article}
\usepackage{ulem}
\begin{document}


\makeatletter

\iffalse  % the following is the default definition of \uwave for comparison. Commented out.
\protected\def\uwave{%
\leavevmode \bgroup
\ifdim \ULdepth =\maxdimen \ULdepth 3.5\p@ \else \advance \ULdepth 2\p@ \fi
\markoverwith {\lower \ULdepth \hbox {\sixly \char 58}}%
\ULon 
}
\fi

% and this is the definition of dwave.
\protected\def\dwave{%
\leavevmode \bgroup
\markoverwith {%
\lower 3.5\p@ \hb@xt@ \z@{\sixly \char 58\hss}%
\lower 5\p@ \hbox {\sixly \char 58}%
}%
\ULon 
}

\makeatother

\uwave{%
    I am using the wave underline to highlight some text, but there is no function to make a line break. Each time the text was always underlined in a single line. Is there any methods to use \textbackslash dwave and have the line break result?%
}

\dwave{%
    I am using the wave underline to highlight some text, but there is no function to make a line break. Each time the text was always underlined in a single line. Is there any methods to use \textbackslash dwave and have the line break result?%
}

\end{document}

输出图像

(TeXbook/TeX 中按主题对原始命令的文档照常。)否则,您可以粗略地猜测\markoverwith ... \ULon文档中如何使用ulem。阅读代码,您可以发现的原始定义uwave用于确保嵌套多重强调将降低外部定义,但嵌套无论如何都不会正确换行,因此我们需要定义一个自定义命令。


替代解决soulpos方案具有支持分词的优点(但需要一次额外的编译):

%! TEX program = lualatex
\documentclass{article}
\usepackage{soulpos}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\begin{document}


\makeatletter


% this is taken straight from the documentation.
\ulposdef{\uwave}{%
\raisebox{-.75ex}{%
\begin{tikzpicture}%
\clip (0,-1pt) rectangle (\ulwidth,1pt);
\draw[color=black!40,
line width=.7pt,
decorate,
decoration=
{snake,
amplitude=.3pt,
segment length=1mm,}]
(0,0) -- +(\ulwidth+3pt,0);
\end{tikzpicture}}}

% copied.
\ulposdef{\dwave}{%
\raisebox{-.9ex}{%
    \begin{tikzpicture}[mylinestyle/.style={
            color=black,
            decorate,
            decoration={snake, amplitude=.3pt, segment length=1mm}
        }]%
        \clip (0,-1pt) rectangle (\ulwidth,3pt);
        \draw[mylinestyle] (0,0) -- +(\ulwidth+3pt,0);
        \draw[mylinestyle] (0,1.5pt) -- +(\ulwidth+3pt,0);
\end{tikzpicture}}}


\makeatother

\uwave{%
    I am using the wave underline to highlight some text, but there is no function to make a line break. Each time the text was always underlined in a single line. Is there any methods to use \textbackslash dwave and have the line break result?%
}

\dwave{%
    I am using the wave underline to highlight some text, but there is no function to make a line break. Each time the text was always underlined in a single line. Is there any methods to use \textbackslash dwave and have the line break result?%
}

\end{document}

灵魂盒的输出


另一种选择是使用lua-ul- 允许连字符,只需要一次编译,但需要 LuaLaTeX:

%! TEX program = lualatex


\documentclass{article}
\usepackage[a4paper, margin=4.5cm]{geometry}
\usepackage{lua-ul}



\newunderlinetype\beginDoubleUnderWavy[\number\dimexpr1ex]{\cleaders\hbox{%
\setlength\unitlength{.3ex}%
\begin{picture}(4,0)(0,1)
\qbezier(0,0)(1,1)(2,0) \qbezier(2,0)(3,-1)(4,0)  % the original underline
\qbezier(0,-1)(1,0)(2,-1) \qbezier(2,-1)(3,-2)(4,-1)  % the underline below
\end{picture}%
}}
\NewDocumentCommand\doubleUnderWavy{+m}{{\beginDoubleUnderWavy#1}}


\begin{document}
\pagenumbering{gobble}


\doubleUnderWavy{%
    I am using the wave underline to highlight some text, but there is no function to make a line break. Each time the text was always underlined in a single line. Is there any methods to use \textbackslash dwave and have the line break result?%
}
\end{document}

\underWavy只需从文档中复制的定义lua-ul并进行相应修改。

输出图像

相关内容