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}
#1by\string. Please, read my previous code carefully. – wipet Oct 13 '17 at 05:37\stringprefix as mentioned in my code here?? https://tex.stackexchange.com/questions/395793/ – wipet Oct 13 '17 at 08:18\stringwas present yet. – O0123 Oct 13 '17 at 08:41