# \usepackage{luatexja-fontspec} - What's so special about ﹑and ～ (OP2)

In my previous OP entitled "What's so special about ﹑and ～", we have discovered a solution to make that question's MWE compile, by changing

\begin{document}


into

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


However, while I was trying out somebody else's code, I came up with a new MWE (hence a new OP) in which the solution above doesn't work any longer. In the mean-time I have also found out that the culprit is \usepackage{luatexja-fontspec}.

Indeed, the MWE below is a neat separator code, which can separate the text in betwen \maincommand{...} and apply commands to each character of the included text, while applying other commands to the punctuation marks themselves (\punctdef). This works for countless of punctuation marks I have tried. It works with or without loading the package \usepackage{luatexja-fontspec}.

With one exception: it seems one can not have both:

• \usepackage{luatexja-fontspec}

as well as one (or both) of the following:

• \punctdef～{～}
• \punctdef﹑{﹑}

My question is: how to solve this incompatibility between the package luatexja-fontspec and the commands issued for ～ and ﹑?

Please note one can uncomment \usepackage{luatexja-fontspec} in the MWE below to see the problems.

Changing

\begin{document}


into

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


doesn't help in this case.

# MWE

% !TEX TS-program = lualatexmk
\documentclass{scrreprt}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% For luatexja-fontspec
\usepackage{fontspec}
% \usepackage{luatexja-fontspec} % IF YOU UNCOMMENT \usepackage{luatexja-fontspec}, THIS CODE WILL FAIL, UNLESS YOU REPLACE ALL INSTANCES OF ～ AND ALL INSTANCES OF ﹑ BY SOME OTHER PUNCTUATION MARK
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Separator (\maincommand)
\def\chinchar#1{[#1]} % redefine it if you want...
\def\punctdef#1{\expandafter\def\csname p-#1\endcsname}

\def\maincommand#1{\maincommandA#1\relax}
\def\maincommandA#1{\ifx\relax#1\else
\expandafter\ifx\csname p-#1\endcsname\relax \chinchar{#1}%
\else \csname p-#1\endcsname\fi
\expandafter\maincommandA\fi
}
%
\punctdef～{～\kern1em}
\punctdef﹑{﹑\kern1em}
\punctdef,{,\kern1em}
\punctdef:{:\kern1em}
\punctdef;{;\kern13pt}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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

\maincommand{AB～C,,,DE;FG:H}

\end{document}


The ～ character is set with catcode 11 (letter) when \usepackage{luatexja-fontspec} is used. So the \punctdef～ is interpreted as one control sequnce, of course undefined cotnrol sequence. It is clear from the error report:

 ! Undefined control sequence.
l.23 \punctdef～


The solution is simple. Use \punctdef{～}{...} instead \punctdef～{...} in such cases. Moreover, the \catcode settings immediately after \begin{document} is totally irrelevant. Remove it.

Edit I add another information here in order to stop creating of next and next new questions.

The ﹑ character has another problem. When you use it then it is not printed. You can see the message in log file:

Missing character: There is no ﹑ (U+FE51) in font IPAExMincho:jfm=ujis!


But you can use \punctdef to define another way for printing of such character. For example:

\punctdef{﹑}{\leavevmode\lower1ex\hbox{\tt}\kern1em}
`