1

I am trying to avoid character clashing when the italic characters surrounded by brackets [eg., (f)]

with the help of the link, I am getting correct output when the characters f surrounded by brackets (); At the same time I am getting the spaced characters when the character f followed by another alphabets eg., df.

  1. How to avoid the extra space when character followed by other alphabets through macros?

  2. How to add extra space between italic Greek characters and the super script characters (to avoid character clash) i.e., $\zeta^\prime$ and $\psi^*$

enter image description here

MWE:

for MWE purpose I used CMR font, actually I am using, other font (Minion), when using CMR font there is no character clash

\documentclass{book}

\makeatletter

\AtBeginDocument{% \Umathcharnumdef\math@f\Umathcodenumf \mathcodef=\string"8000} \begingroup\lccode~=f \lowercase{\endgroup \def~{% \mkern3mu\math@f \ifnum\mathgroup=\m@ne \expandafter@firstofone \else \expandafter@gobble \fi {@ifnextchar_{\relax}{\mkern3mu}}% } \Umathcharnumdef\math@j\Umathcodenumj \mathcodej=\string"8000} \begingroup\lccode~=j \lowercase{\endgroup \def~{% \mkern2mu\math@j \ifnum\mathgroup=\m@ne \expandafter@firstofone \else \expandafter@gobble \fi {@ifnextchar_{\relax}{}}% }

\Umathcharnumdef\math@p\Umathcodenump \mathcodep=\string"8000} \begingroup\lccode~=p \lowercase{\endgroup \def~{% \mkern2mu\math@p \ifnum\mathgroup=\m@ne \expandafter@firstofone \else \expandafter@gobble \fi {@ifnextchar_{\relax}{}}% }

\Umathcharnumdef\math@d\Umathcodenumd \mathcoded=\string"8000} \begingroup\lccode~=d \lowercase{\endgroup \def~{% \math@d \ifnum\mathgroup=\m@ne \expandafter@firstofone \else \expandafter@gobble \fi {@ifnextchar_{\relax}{\mkern1mu}}% }

\Umathcharnumdef\math@g\Umathcodenumg \mathcodeg=\string"8000} \begingroup\lccode~=g \lowercase{\endgroup \def~{% \mkern1mu\math@g \ifnum\mathgroup=\m@ne \expandafter@firstofone \else \expandafter@gobble \fi {@ifnextchar_{\relax}{}}% }

\Umathcharnumdef\math@l\Umathcodenuml \mathcodel=\string"8000} \begingroup\lccode~=l \lowercase{\endgroup \def~{% \math@l \ifnum\mathgroup=\m@ne \expandafter@firstofone \else \expandafter@gobble \fi {@ifnextchar_{\relax}{\mkern1mu}}% }

%%%%%%%%%%%UPPER CASE%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \Umathcharnumdef\math@V\Umathcodenum\V \mathcode\V=\string"8000} \begingroup\uccode~=\V \uppercase{\endgroup \def~{% \math@V \ifnum\mathgroup=\m@ne \expandafter@firstofone \else \expandafter@gobble \fi {@ifnextchar_{\relax}{\mkern2mu}}% }

\Umathcharnumdef\math@N\Umathcodenum\N \mathcode\N=\string"8000} \begingroup\uccode~=\N \uppercase{\endgroup \def~{% \math@N \ifnum\mathgroup=\m@ne \expandafter@firstofone \else \expandafter@gobble \fi {@ifnextchar_{\relax}{\mkern1mu}}% }

\Umathcharnumdef\math@X\Umathcodenum\X \mathcode\X=\string"8000} \begingroup\uccode~=\X \uppercase{\endgroup \def~{% \math@X \ifnum\mathgroup=\m@ne \expandafter@firstofone \else \expandafter@gobble \fi {@ifnextchar_{\relax}{\mkern2mu}}% }

\Umathcharnumdef\math@Y\Umathcodenum\Y \mathcode\Y=\string"8000} \begingroup\uccode~=\Y \uppercase{\endgroup \def~{% \math@Y \ifnum\mathgroup=\m@ne \expandafter@firstofone \else \expandafter@gobble \fi {@ifnextchar_{\relax}{\mkern2mu}}% }

\Umathcharnumdef\math@T\Umathcodenum\T \mathcode\T=\string"8000} \begingroup\uccode~=\T \uppercase{\endgroup \def~{% \math@T \ifnum\mathgroup=\m@ne \expandafter@firstofone \else \expandafter@gobble \fi {@ifnextchar_{\relax}{\mkern1mu}}% }

\Umathcharnumdef\math@J\Umathcodenum\J \mathcode\J=\string"8000} \begingroup\uccode~=\J \uppercase{\endgroup \def~{% \mkern1mu\math@J \ifnum\mathgroup=\m@ne \expandafter@firstofone \else \expandafter@gobble \fi {@ifnextchar_{\relax}{\mkern1mu}}% }

\Umathcharnumdef\math@K\Umathcodenum\K \mathcode\K=\string"8000} \begingroup\uccode~=\K \uppercase{\endgroup \def~{% \math@K \ifnum\mathgroup=\m@ne \expandafter@firstofone \else \expandafter@gobble \fi {@ifnextchar_{\relax}{\mkern1mu}}% }

\Umathcharnumdef\math@U\Umathcodenum\U \mathcode\U=\string"8000} \begingroup\uccode~=\U \uppercase{\endgroup \def~{% \math@U \ifnum\mathgroup=\m@ne \expandafter@firstofone \else \expandafter@gobble \fi {@ifnextchar_{\relax}{\mkern1mu}}% }

\Umathcharnumdef\math@W\Umathcodenum\W \mathcode\W=\string"8000} \begingroup\uccode~=\W \uppercase{\endgroup \def~{% \math@W \ifnum\mathgroup=\m@ne \expandafter@firstofone \else \expandafter@gobble \fi {@ifnextchar_{\relax}{\mkern2mu}}% }

} \makeatother

\begin{document}

$(f)$ $(p)$

$df$

$\inf$

$\exp$

$\zeta^\prime$ and $\psi^*$

\end{document}

RCV
  • 2,030
  • 3
    I think the question would be better/more clear with a few images showing the problems and what those partial fixes do. As of now, everyone has to copy the code, compile, and guess. – mickep Dec 07 '22 at 16:17
  • I can add that we have during the last year worked quite hard to get things like this right in ConTeXt lmtx. Your example in latin modern looks like this. Left: without fixes, right: with fixes. – mickep Dec 07 '22 at 18:10
  • @mickep, i have added the image in the questions, I am using xelatex – RCV Dec 08 '22 at 05:00
  • It looks like you are using upright f and p in the image. Is that on purpose? – mickep Dec 08 '22 at 07:36
  • @mikep, sorry, i have misplaced upright character instead of italic version, it should be italic f and p only – RCV Dec 08 '22 at 10:29
  • Have you tried LuaTeX? – Henri Menke Dec 15 '22 at 19:03
  • @HenriMenke, No, i didnt, i dont have the knowledge in Luascript, can you please hep me to find the solution in LuaTeX – RCV Dec 16 '22 at 07:34
  • @TeX_learner You don't have to write any Lua code at first. Just try to compile your document with LuaLaTeX. If you're not using XeTeX-specific packages that should work out-of-the-box. If the characters still collide, try then to add \mathitalicsmode=1 (or =2) in the preamble and see whether that fixes it. – Henri Menke Dec 18 '22 at 19:29

0 Answers0