NOTE: Subsequently, I have posted an analogue question to this one, using the structurally the same code and set-up at the OP "What's so special about a and ".

OK. I have prepared a MWE but it requires quite a lot of set-up.

This question is about the following characters:


I use the particular code that will follow for Chinese text, and as my favorite font allows the two characters above to be used without any fuss, please, if you'd like, install the font HanWangKaiMediumChuIn_wp010-08.ttf (download link here or if not here).

What else do we need? We will need:

OK. If they are all in the same folder as our TeX-file, we are set to go. The TeX-file should look as follows (to be compiled twice with LuaLaTeX):

The TeX-file

% !TEX TS-program = lualatexmk


% Chinese splitter
\bgroup \catcode`!=3 \catcode`?=3
   \long\def\replacestringsB##1#1{\ifx!##1\relax \else\addto\tmpb{#2##1}%
      \expandafter\replacestringsB\fi}% improved version <May 2016> inspired 
   \expandafter\replacestringsA\tmpb?#1!#1% from pysyntax.tex by Petr Krajnik
   \replacestrings {\\}  {&\\}%
   \replacestrings {\endgraf}  {&\endgraf}%
   \replacestrings {★}  {&★}%
   \replacestrings {【}  {&【}%
   \replacestrings {】}  {&】}%
   \replacestrings {(}  {&(}%
   \replacestrings {)}  {&)}%
   \replacestrings {:} {&:}%
   \replacestrings {。}  {&。}%
   \replacestrings {,}  {&,}%
   \replacestrings {「}  {&「}%
   \replacestrings {」}  {&」}%
   \replacestrings {《}  {&《}%
   \replacestrings {》}  {&》}%
   \replacestrings {、}  {&、}%
   \replacestrings {;}  {&;}%
   \replacestrings {~}  {&~}%
%   \replacestrings {~} {&{\string~}}%
   \replacestrings {\textasciitilde}  {&\textasciitilde}%
   \replacestrings {〈}  {&〈}%
   \replacestrings {〉}  {&〉}%
   \replacestrings {·}  {&·}%
   \replacestrings {.}  {&.}%
%   \replacestrings {﹑} {&{\string、}}%
   \replacestrings {﹑} {&、}%
   \replacestrings {\scriptsize}  {&\scriptsize}%
   \replacestrings {\footnotesize}  {&\footnotesize}%
   \replacestrings {\small}  {&\small}%
   \replacestrings {\normalsize}  {&\normalsize}%
   \replacestrings {\large}  {&\large}%
   \replacestrings {\Large}  {&\Large}%
   \replacestrings {\LARGE}  {&\LARGE}%
   \replacestrings {\huge}  {&\huge}%
   \replacestrings {\Huge}  {&\Huge}%
\def\anyX#1{\tooltips[height=10cm]{#1} \space}

% For the Chinese font

% Encoding converter and tooltipper
\directlua{print('The big5 version of 高 is: ' .. big5FromChar('高'))}
% tooltips with LaTeX
% optimized for Adobe Reader (visible on mouse-over)
%     usage: \tooltip[<link colour>]{<link text>}[<tip box colour>]{<tip text>}
%   non-draggable version:
%     usage: \tooltip*[<link colour>]{<link text>}[<tip box colour>]{<tip text>}
% for Evince (visible on click, not draggable)
%   usage: \tooltip**[<link colour>]{<link text>}[<tip box colour>]{<tip text>}
      /Subtype/Link/Border [0 0 0]/A <</S/SetOCGState/State [/Toggle \tpTipOcg]>>
          /E<</S/SetOCGState/State [/ON \tpTipOcg]>>%
          /X<</S/SetOCGState/State [/OFF \tpTipOcg]>>%
            var fd=this.getField('tip.\thetcnt');%
                var click\thetcnt=false;%
                var fdor\thetcnt=fd.rect;var dragging\thetcnt=false;%
          /PC<</S/JavaScript/JS (%
            var fd=this.getField('tip.\thetcnt');%
  %tip box placed at top left page corner
  \begin{tikzpicture}[remember picture,overlay]
    \node [inner sep=0pt, anchor=base] at (current page.north west) {%
          /Subtype/Widget/FT/Btn/T (tip.\thetcnt)%
          /AP<</N \tpPdfLastXform>>%
          /MK<</TP 1/I \tpPdfLastXform/IF<</S/A/FB true/A [0.0 0.0]>>>>%
            /Ff 65537/OC \tpTipOcg%
            /Ff 65536/F 3%
            /AA <<%
              /U <<%
                  var fd=event.target;%
                  var mX=this.mouseX;var mY=this.mouseY;%
                  var drag=function(){%
                    var nX=this.mouseX;var nY=this.mouseY;%
                    var dX=nX-mX;var dY=nY-mY;%
                    var fdr=fd.rect;%
  \tl_map_inline:nn { #3 }

%All of this works fine
\Chinese{疊。。【疊    ,疊;【疊   疊《疊(疊\textasciitilde 疊···疊疊】疊\footnotesize 疊疊\Large 疊;〈疊\endgraf}

%All of this doesn't work ... why?


The questions

Why does


not "work", and why does


not "work"?

  • if I comment out the font and add \show~ straight after begin document \begin{document} \show~ then I get ! Undefined control sequence. l.217 \show~ which means that some package has made this character active and then \let it to something undefined. You could add \catcode\~=12 ` at taht point to make it none active but I don't know what that will break – David Carlisle Oct 4 '17 at 12:47
  • @DavidCarlisle Where should the \catcode\~=12 be added to then? – Vincent Mia Edie Verheyen Oct 4 '17 at 12:55
  • actually in the preamble it is letter so perhaps \catcode`\~=11 with a backtick which got lost by the comment markup above) immediately after \begin{document} but really that is more of a debugging step it shouldn't be needed I suspect but it's hard for me to debug this as I can't read any of it:-) – David Carlisle Oct 4 '17 at 12:58
  • @DavidCarlisle Yes! You are right, it worked when using 12 instead of 11. It solved the problem for . How about the other character ? :) For all, please note that, in the main Tex-file, one can un-comments the strings \replacestrings {~} {&~} and \replacestrings {﹑} {&、} ... I have now done so in the code above as well. – Vincent Mia Edie Verheyen Oct 4 '17 at 13:03
  • OK, so I understand you can do it for both the character as well as for the character at the same time using (everything between the arrows ... the markup isn't formatting well). --> \catcode\﹑=12\catcode\~=12 <-- – Vincent Mia Edie Verheyen Oct 4 '17 at 13:53

As per User David Carlisle's first comment (first comment to this OP), for debugging purposes, one can add \show~ right after \begin{document} to end up with:

\begin{document} \show~

The error output, when compiling this, will then look something as follows (the line, in this case l.220, will refer to the line number of (\begin{document} \show~) above:

! Undefined control sequence. l.220 \show~

A similar error will be returned upon:


David claims that this means the following:

That some package has made this character active and then \let it to something undefined.

Therefor, David suggested to add


immediately after \begin{document} to end up with:

\begin{document} \catcode`\~=12

You will then note that the problem for the character is solved.

You could do the same for the character by changing the line to:

\begin{document} \catcode`\﹑=12

If you want to fix the problems for both of the characters, change the line into:

\begin{document} \catcode`\﹑=12 \catcode`\~=12

I have discovered that the errors are due to \usepackage{luatexja-fontspec}. The fix above will work in some cases, but not in all cases.

I have encountered new circumstances in which this solution doesn't work any more. Therefor I have posted a new OP entitled "\usepackage{luatexja-fontspec} - What's so special about ﹑and ~ (OP2)".

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.