# How to underline CJK with soul?

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.

• 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 '18 at 7:21
• I tried soulutf8, with XeLaTeX. And It does not help. But thank you for your suggestion. – jiewuza Nov 28 '18 at 9:53

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}


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