Is there any solution for highlighting texts or sentences in Chinese, Japanese, and Korean? I know none, at the moment.
But this will be changed, if someone would like to help me with CJK in LaTeX.
Problems:
If CJK text is highlighted by
soul
or other codes based on it, the highlight doesn't work at all.eg: Cool Text Highlighting in LaTeX
I tried:
\documentclass[nofonts]{ctexbook} \setCJKmainfont{SimSun} \usepackage{soul} \usepackage{tikz} \usetikzlibrary{calc} \usetikzlibrary{decorations.pathmorphing} \makeatletter \newcommand{\defhighlighter}[3][]{% \tikzset{every highlighter/.style={color=#2, fill opacity=#3, #1}}% } \defhighlighter{yellow}{.5} \newcommand{\highlight@DoHighlight}{ \fill [ decoration = {random steps, amplitude=1pt, segment length=15pt} , outer sep = -15pt, inner sep = 0pt, decorate , every highlighter, this highlighter ] ($(begin highlight)+(0,8pt)$) rectangle ($(end highlight)+(0,-3pt)$) ; } \newcommand{\highlight@BeginHighlight}{ \coordinate (begin highlight) at (0,0) ; } \newcommand{\highlight@EndHighlight}{ \coordinate (end highlight) at (0,0) ; } \newdimen\highlight@previous \newdimen\highlight@current \DeclareRobustCommand*\highlight[1][]{% \tikzset{this highlighter/.style={#1}}% \SOUL@setup % \def\SOUL@preamble{% \begin{tikzpicture}[overlay, remember picture] \highlight@BeginHighlight \highlight@EndHighlight \end{tikzpicture}% }% % \def\SOUL@postamble{% \begin{tikzpicture}[overlay, remember picture] \highlight@EndHighlight \highlight@DoHighlight \end{tikzpicture}% }% % \def\SOUL@everyhyphen{% \discretionary{% \SOUL@setkern\SOUL@hyphkern \SOUL@sethyphenchar \tikz[overlay, remember picture] \highlight@EndHighlight ;% }{% }{% \SOUL@setkern\SOUL@charkern }% }% % \def\SOUL@everyexhyphen##1{% \SOUL@setkern\SOUL@hyphkern \hbox{##1}% \discretionary{% \tikz[overlay, remember picture] \highlight@EndHighlight ;% }{% }{% \SOUL@setkern\SOUL@charkern }% }% % \def\SOUL@everysyllable{% \begin{tikzpicture}[overlay, remember picture] \path let \p0 = (begin highlight), \p1 = (0,0) in \pgfextra \global\highlight@previous=\y0 \global\highlight@current =\y1 \endpgfextra (0,0) ; \ifdim\highlight@current < \highlight@previous \highlight@DoHighlight \highlight@BeginHighlight \fi \end{tikzpicture}% \the\SOUL@syllable \tikz[overlay, remember picture] \highlight@EndHighlight ;% }% \SOUL@ } \makeatother \begin{document} 本条所说的三日期间与第98条规定的三日期间在计算上采同样的规则(请参考第98条的释义部分),期间的开始均不是以扣押命令的发出为标准,而是以扣押的生效为准。\highlight[red]{对邮件的扣押,以邮政服务机构收到扣押命令,邮件开始处于被截留的状态,视为扣押的生效(Pfeiffer S471 Rn4)},期间由此开始。期间的开始计算同样适用第42条的规定。 但与第98条不同的是,第98条的三日期间只是向法官提出追认照准的申请的期间,而本条则是收到法官追认照准的期间。邮政服务机构如果在三日内没收到法官的追认,检察官的扣押命令失效,毋需再向检察官交出邮件。但邮件如果已经被交出的,则暂时不被返还,仍可保留在检察官处。如果在三日期满后法官又追认照准的,视为法官作出了新的扣押命令(Meyer-Goßner S325 Rn7)。 \highlight[red]{如果法官在三日内不予照准的呢?如果在三日内没有追认,在三日后也没有作出追认的?如果法官在三日后作出不予照准的呢?六种情况} \end{document}
TeX reported:
Package soul Error: Reconstruction failed. See the soul package documentation for explanation.
If I ignore these errors and compile the TeX file, the highlighted texts became black squares.
If CJK text is highlighted by some code based on soul, the highlight works, but the text can not be broken across lines, and they are all in one line beyond the edge of pages.
eg:
\documentclass[nofonts]{ctexbook} \setCJKmainfont{SimSun} \usepackage{soul} \usepackage{tikz} \newcommand*{\yellowhl}[1]{% \tikz[baseline]\node[rectangle, fill=yellow, rounded corners, inner sep=0.3mm,anchor=base]{#1};% } \begin{document} 本条所说的三日期间与第98条规定的三日期间在计算上采同样的规则(请参考第98条的释义部分),期间的开始均不是以扣押命令的发出为标准,而是以扣押的生效为准。\yellowhl{对邮件的扣押,以邮政服务机构收到扣押命令,邮件开始处于被截留的状态,视为扣押的生效(Pfeiffer S471 Rn4)},期间由此开始。期间的开始计算同样适用第42条的规定。 但与第98条不同的是,第98条的三日期间只是向法官提出追认照准的申请的期间,而本条则是收到法官追认照准的期间。邮政服务机构如果在三日内没收到法官的追认,检察官的扣押命令失效,毋需再向检察官交出邮件。但邮件如果已经被交出的,则暂时不被返还,仍可保留在检察官处。如果在三日期满后法官又追认照准的,视为法官作出了新的扣押命令(Meyer-Goßner S325 Rn7)。 \yellowhl{如果法官在三日内不予照准的呢?如果在三日内没有追认,在三日后也没有作出追认的?如果法官在三日后作出不予照准的呢?六种情况} \end{document}
Crying for help: does anyone know how to solve it?