1

I was using soul to underline text. It works until I tried to underline some CJK text.

When I have

\def \mytest {测试test very long text blah blah blah ...}
\ul\mytest

in the document, it complains: Package soul Error: Reconstruction failed.

I also tried \CJKunderline. But it does not auto-wrap for this long text.

2
  • There is ctan.org/pkg/soulutf8, which might help (I didn't test). Do you use pdfLaTeX, LuaLaTeX or XeLaTeX? But as always: Underlining is hard in TeX and soul as well as ulem have restrictions in what their underlining macros can accept as input. It may well be that neither can accept CJK characters without exploding. You already know about Paul Isambert's LuaLaTeX underlining code that should work here (again I didn't test), but of course requires LuaLaTeX (tex.stackexchange.com/q/435962/35864).
    – moewe
    Nov 27, 2018 at 7:21
  • I tried soulutf8, with XeLaTeX. And It does not help. But thank you for your suggestion.
    – jiewuza
    Nov 28, 2018 at 9:53

1 Answer 1

1

Run the document with xelatex or lualatex:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Noto Sans CJK JP}
\usepackage{soul}
\begin{document}
\def \mytest {测试test very long text blah blah blah ...}
\ul\mytest
\end{document}

enter image description here

8
  • I have \usepackage{xeCJK} after \usepackage{fontspec}, and the same complain remains.
    – jiewuza
    Nov 28, 2018 at 9:51
  • I checked the document of xeCJK. It uses fontspec inside. I doubt soul is not compatible with xeCJK.
    – jiewuza
    Nov 28, 2018 at 10:12
  • yes, seems so. It is the way how xeCJK redefines character setting
    – user2478
    Nov 28, 2018 at 10:23
  • Well, I guess I cannot get rid of xeCJK. I use it to set font.
    – jiewuza
    Nov 28, 2018 at 10:48
  • fontsetting can also be done with fontspec. But I am not an CJK expert ...
    – user2478
    Nov 28, 2018 at 11:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .