3

When typesetting math accents, I have the impression that LaTeX does sometimes a better job than plain. My question is, what does LaTeX differently and whether there is an easy fix also for plain.

The issues I know about are:

  1. Plain does not move the accents to the right for some fonts (e.g. the script fonts). Is this a problem of the package that loads the fonts? (Btw. usually \cal is fine, while \script is wrong.)
  2. When combining two accents, plain moves the first one to the right, but not the second one.

As a demonstration, compare the following two results. I use the kp-fonts as they have quite large shift for math accents (a bit too large for my taste I have to say).

plain code:

\input kp-fonts

$\tilde x, \bar x, \bar{\tilde x}, \tilde{\bar x}, \tilde{\script C}$

\bye

LaTeX code:

\documentclass{article}
\usepackage{amsmath}
\usepackage{kpfonts}
\begin{document}

$\tilde x, \bar x, \bar{\tilde x}, \tilde{\bar x}, \tilde{\mathscr{C}}$

\end{document}

Results:

Result for plainTeX code vs. Result for LaTeX code

1
  • The difference between plain TeX \script C and LaTeX \mathscr C is: plainTeX uses rsfs10 with skewchar unset but LaTeX uses jkpsyd.tfm with skewchar 0. I can write an answer (if you want) how to correct plain TeX code, but only concerned to the \tilde{\script C}. The double accents are another story and you have found the plain TeX solution at OPmac trick page.
    – wipet
    Apr 14, 2020 at 14:49

1 Answer 1

1

I managed to come up with some kind of a solution for the second problem. Modifying the trick from http://petr.olsak.net/opmac-tricks-e.html#colaccent one can define

\newmuskip\tmpmudim 
\newdimen\tmpdim

\def\accents#1#2#3{
  {\ifnum\skewchar\textfont1<0 \tmpmudim=0mu \else \calculatemukern {#3}{\char\skewchar\textfont1}\fi 
   \mkern2\tmpmudim #1{\mkern-2\tmpmudim{#2#3}}} 
} 
\def\calculatemukern #1#2{\setbox0=\hbox{\the\textfont1 #1#2}\setbox1=\hbox{\the\textfont1 #1\null#2}% 
  \tmpdim=\wd0 \advance\tmpdim by-\wd1 
  \tmpmudim=\expandafter\ignorept\the\tmpdim mu \tmpmudim=288\tmpmudim 
  \tmpdim=16em \divide\tmpmudim by\expandafter\ignorefracpart\the\tmpdim\relax 
} 
\def\ignorefracpart#1.#2\relax{#1} 
{\lccode`\?=`\p \lccode`\!=`\t  \lowercase{\gdef\ignorept#1?!{#1}}}

Then it is enough to write

$\accents\bar\tilde x, \accents\tilde\bar x$

to get the right result.

But it would be nice if it worked somehow automatically.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .