ho-tex / soul

LaTeX package "soul" for letterspacing, underlining, striking out and other evil things
LaTeX Project Public License v1.3c
5 stars 1 forks source link

! Package soul Error: Reconstruction failed. #9

Closed XiangyunHuang closed 10 months ago

XiangyunHuang commented 11 months ago

Do you have any plan to support Chinese?

\documentclass{article}
\usepackage{ctex}
\usepackage{soul}
\begin{document}
\st{中文}  % Here are two CJK characters
\end{document}

When I try to compile using XeLaTeX, an error happens as follow:

! Package soul Error: Reconstruction failed.

u-fischer commented 11 months ago

I doubt that it will ever work. The problem is not the Chinese in itself but all the additional code that ctex inserts (boxes and font hooks and more) and which confuses the soul package. Without ctex it more or less works, if one set the font correctly:

\documentclass{article}
%\usepackage[fontset=fandol]{ctex}
\usepackage{soul}
\usepackage{fontspec}
\setmainfont{FandolSong-Regular.otf}
\setmonofont{FandolSong-Regular.otf}
\makeatletter 
\setbox\z@\hbox{\ttfamily\global\let\SOUL@tt\ttfamily}
\setbox\z@\hbox{\SOUL@tt-}
\SOUL@ttwidth\wd\z@
\makeatother
\begin{document}
\st{中文} % Here are two CJK characters
\end{document}

I would suggest to use lualatex and the lua-ul package instead. That is much less fragile:

\documentclass{article}
\usepackage[fontset=fandol]{ctex}
\usepackage[soul]{lua-ul}
\begin{document}
\st{中文}  % Here are two CJK characters
\end{document}

image

mbertucci47 commented 11 months ago

There is also the xeCJKfntef package for xelatex, documented in xeCJK

XiangyunHuang commented 10 months ago

Thank you for letting me know more and deeper about soul.