没有宏时直接用就好了:用soul宏包解决Latex \underline换行问题
但是如果里面有宏则会报错:
\def\testc#{test}
\ul{\testc{}}
Use of \testc doesn't match its definition.
有两种解决方案:
soulregister
这种方案是非侵入式的。
\soulregister\testc7
提前expand
这种方案需要定义一个新的宏。
\makeatletter
\def\myul#1{%
\protected@edef\tempa{#1}%
\ul\tempa%
}
\makeatother
然后用这个新的宏就好了:
\myul{233 \testc{} 2333}
注意这里面\protected@edef
不能换成\edef
,不然碰上\emph
就会炸。
来源:https://tex.stackexchange.com/a/126244/256676
参考:
https://en.wikibooks.org/wiki/TeX/edef
失败的方案
\def\myul#1{
\def\arga{#1}
\ul\arga
}
这种方法遇到嵌套宏就不行了。
来源:https://tex.stackexchange.com/questions/496833/package-soul-underline-problem-with-macro-text