解决Latex soul ul参数中有宏时报错的问题
  fFNahfJvxgqO 2023年11月02日 42 0


没有宏时直接用就好了:用soul宏包解决Latex \underline换行问题

但是如果里面有宏则会报错:

\def\testc#{test}
\ul{\testc{}}
Use of \testc doesn't match its definition.

有两种解决方案:

soulregister

这种方案是非侵入式的。

\soulregister\testc7

来源:https://tex.stackexchange.com/questions/139463/how-to-make-hl-highlighting-to-automatically-place-incompatible-commands-in/139500#139500

提前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://tex.stackexchange.com/questions/244694/writing-to-aux-you-cant-use-a-prefix-with-the-character

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


【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
fFNahfJvxgqO