“formatchar”宏分隔格式化的字母

“formatchar”宏分隔格式化的字母

关于 \FormatChar 宏,建议在 强调阿拉伯文本字符

使用时,格式化的字符会被分离,如下所示,有没有办法修复它,而同一篇文章中的 \formatchars 宏工作正常。


\documentclass[a4paper,12pt,twoside]{book}

\usepackage [bidi=basic,layout=lists.tabular]{babel}
\babelprovide[import=ar,mapdigits,main]{arabic}

\babelfont{rm}{Amiri}

\usepackage{tikz}
\usepackage{ulem}


\def\connecti{i}
\def\connectr{r}
\def\connectl{l}
\def\connectb{b}

\makeatletter
\def\FormatChar#1#2#3#4{%
\let\joineri\@firstofone
\let\joinerii\@firstofone
\def\formatcs{#1}
\def\temp{#3}%
\if\temp\connectb%
\else
 \if\temp\connectr%
 \let\joinerii\@gobble%
 \else
   \if\temp\connectl%
   \let\joineri\@gobble%
   \else    
      \if\temp\connecti%
      \let\joineri\@gobble\let\joinerii\@gobble%
      \else
      \@latex@error
      {\temp is not available for contextual forms}
      \fi%
   \fi%
 \fi%   
\fi%
\xFormatChar{#2}#4}
\def\xFormatChar#1#2{\ifnum#1=1 \joineri{^^^^200d}
\formatcs{\joineri{^^^^200d}#2\joinerii{^^^^200d}}
\joinerii{^^^^200d}\expandafter\@gobbletwo
    \else#2\fi\xFormatChar{\numexpr#1-1\relax}}
\makeatother
    
\tikzset{charboxstyle/.style={draw=red,inner sep=0pt,fill=yellow}}
    
\newcommand{\charbox}[1]{%
\tikz[baseline=(x.base)]\node(x)[charboxstyle]{#1};%
}



\begin{document}

%\FormatChar{#1}{#2}{#3}{#4} 
% #1: Command
% #2: Position of char (number)
% #3: Contextual forms r , l , b , i
% #4: Word
    
\Huge

\FormatChar{\uline}{1}{l}
{جنوب}
%
\FormatChar{\textcolor{blue}}{2}{b}
{جنوب}
%
\FormatChar{\textcolor{red}}{3}{r}
{جنوب}
%
\FormatChar{\charbox}{4}{i}
{جنوب}
%
\tikzset{charboxstyle/.append style={dashed,draw=blue,fill=green,text=orange}}
%
\FormatChar{\charbox}{1}{l}
{جنوب}

\end{document}


在此处输入图片描述

相关内容