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:
- ﹑
and
- ~
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:
- an image called C57C.png (I suggest to use this image)
- a file called map.txt (you can download it here ... this is used for character encoding conversion)
- a file called big5.lua (you can download it here)
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
\documentclass{scrreprt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Chinese splitter
\long\def\addto#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}
\bgroup \catcode`!=3 \catcode`?=3
\gdef\replacestrings#1#2{\long\def\replacestringsA##1#1{\def\tmpb{##1}\replacestringsB}%
\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
\long\def\replacestringsA##1?{\def\tmpb{##1}}\expandafter\replacestringsA\tmpb
}
\egroup
%
\def\Chinese#1{\def\tmpb{#1}%
\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}%
\expandafter\anyA\tmpb&{}%
}
\def\anyA#1{\anyX{#1}#2\ifx&\else\expandafter\anyB\fi}
\def\anyB{\futurelet\next\anyC}
\def\anyC{\expandafter\ifx\space\next\space\fi\anyA}
%
\def\anyX#1{\tooltips[height=10cm]{#1} \space}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% For the Chinese font
\usepackage{fontspec}
\usepackage{luatexja-fontspec}
\setmainjfont{HanWangKaiMediumChuIn_wp010-08}
\ltjsetparameter{kanjiskip=1em}
\ltjsetparameter{xkanjiskip=1em}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Encoding converter and tooltipper
\tracinglostchars=2
\directlua{require('big5.lua')}
\directlua{print('The big5 version of 高 is: ' .. big5FromChar('高'))}
\newcommand{\bigfive}[1]{\directlua{tex.sprint(big5FromChar('#1'))}}
%
% 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>}
%
%
\usepackage{pdfbase}[2017/03/16]
\usepackage{xparse,ocgbase}
\usepackage{xcolor,calc}
\usepackage{tikz}
\usetikzlibrary{calc}
%
\ExplSyntaxOn
\let\tpPdfLink\pbs_pdflink:nn
\let\tpPdfAnnot\pbs_pdfannot:nnnn\let\tpPdfLastAnn\pbs_pdflastann:
\let\tpAppendToFields\pbs_appendtofields:n
\def\tpPdfXform{\pbs_pdfxform:nnnnn{1}{1}{}{}}
\let\tpPdfLastXform\pbs_pdflastxform:
\ExplSyntaxOff
%
\makeatletter
\NewDocumentCommand{\tooltip}{ssO{black}mO{black}m}{{%
\leavevmode%
\IfBooleanT{#1}{%
\ocgbase@new@ocg{tipOCG.\thetcnt}{%
/Print<</PrintState/OFF>>/Export<</ExportState/OFF>>%
}{false}%
\xdef\tpTipOcg{\ocgbase@last@ocg}%
}%
\tpPdfLink{%
\IfBooleanTF{#2}{%
/Subtype/Link/Border [0 0 0]/A <</S/SetOCGState/State [/Toggle \tpTipOcg]>>
}{%
/Subtype/Screen%
\IfBooleanTF{#1}{%
/AA<<%
/E<</S/SetOCGState/State [/ON \tpTipOcg]>>%
/X<</S/SetOCGState/State [/OFF \tpTipOcg]>>%
>>%
}{
/AA<<%
/E<</S/JavaScript/JS(%
var fd=this.getField('tip.\thetcnt');%
\IfBooleanF{#1}{%
if(typeof(click\thetcnt)=='undefined'){%
var click\thetcnt=false;%
var fdor\thetcnt=fd.rect;var dragging\thetcnt=false;%
}%
}%
if(fd.display==display.hidden){%
fd.delay=true;fd.display=display.visible;fd.delay=false;%
}%
this.dirty=false;%
)>>%
/X<</S/JavaScript/JS(%
if(!click\thetcnt&&!dragging\thetcnt){fd.display=display.hidden;}%
if(!dragging\thetcnt){click\thetcnt=false;}%
this.dirty=false;%
)>>%
/U<</S/JavaScript/JS(click\thetcnt=true;this.dirty=false;)>>%
/PC<</S/JavaScript/JS (%
var fd=this.getField('tip.\thetcnt');%
try{fd.rect=fdor\thetcnt;}catch(e){}%
fd.display=display.hidden;this.dirty=false;%
)>>%
/PO<</S/JavaScript/JS(this.dirty=false;)>>%
>>%
}
}%
}{{\color{#3}#4}}%
\sbox\tiptext{\fcolorbox{black}{#5}{#6}}%
\edef\twd{\the\wd\tiptext}%
\edef\tht{\the\ht\tiptext}%
\edef\tdp{\the\dp\tiptext}%
\tpPdfXform{\tiptext}%
%tip box placed at top left page corner
\begin{tikzpicture}[remember picture,overlay]
\node [inner sep=0pt, anchor=base] at (current page.north west) {%
\raisebox{-1.5cm-\tht}[0pt][0pt]{%
\tpPdfAnnot{\twd}{\tht}{\tdp}{%
/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]>>>>%
\IfBooleanTF{#1}{%
/Ff 65537/OC \tpTipOcg%
}{%
/Ff 65536/F 3%
/AA <<%
/U <<%
/S/JavaScript/JS(%
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;%
fdr[0]+=dX;fdr[1]+=dY;fdr[2]+=dX;fdr[3]+=dY;%
fd.rect=fdr;mX=nX;mY=nY;%
};%
if(!dragging\thetcnt){%
dragging\thetcnt=true;Int=app.setInterval("drag()",1);%
}%
else{app.clearInterval(Int);dragging\thetcnt=false;}%
this.dirty=false;%
)%
>>%
>>%
}%
}%
\tpAppendToFields{\tpPdfLastAnn}%
}%
};
\end{tikzpicture}
\stepcounter{tcnt}%
}}
\makeatother
\newsavebox\tiptext\newcounter{tcnt}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\ExplSyntaxOn
\NewDocumentCommand{\tooltips}{sO{}m+O{}}
{
\tl_map_inline:nn { #3 }
{
\IfBooleanTF{#1}{\tooltip*}{\tooltip*}{##1}{\includegraphics[#2]{\bigfive{##1}}}#4
}
}
\ExplSyntaxOff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%
%All of this works fine
\Chinese{疊}
\Chinese{疊。。【疊 ,疊;【疊 疊《疊(疊\textasciitilde 疊···疊疊】疊\footnotesize 疊疊\Large 疊;〈疊\endgraf}
﹑
~
﹑~﹑
~﹑~
%
%%%%%%%%%
%%%%%%%%%
%All of this doesn't work ... why?
%
%\Chinese{疊~疊}
%
%
%\Chinese{疊﹑疊}
%
%%%%%%%%%
\end{document}
The questions
Why does
\Chinese{疊~疊}
not "work", and why does
\Chinese{疊~疊}
not "work"?
\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\letit 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 04 '17 at 12:47\catcode\~=12be added to then? – O0123 Oct 04 '17 at 12:55\catcode\\~=11with 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 04 '17 at 12:58~. 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. – O0123 Oct 04 '17 at 13:03﹑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 <-- – O0123 Oct 04 '17 at 13:53\usepackage{luatexja-fontspec}. – O0123 Oct 13 '17 at 03:33