2

Depending on the letter in the base there is space to the preceded superscript. Letters like T, W, Y use ink in the top left corner, so there is no space, but when using I, D, E, ... (these letters don't have a component in their top left corner) there is space in front of them.

Is there a way to fix this?

\documentclass{article}
\usepackage{tensor}

\begin{document}
$T^b$ %no space

${}^b T$ ${}^b W$ ${}^b Y$ %no space

$I^b$ %no space

${}^b I$ ${}^b D$ ${}^b E$ %spacing between b and I, D or E

$\tensor[^b]I{}$ %doesn't help
\end{document}
2

Here is a solution which is based on (the second half of) this amazing answer by Hendrik Vogt. It works by hacking into amsmath's accent placement mechanism. I do not fully understand it.

I've defined \presup{<superscript>}{<letter>}, which does what you ask, and applied it to all of the letters you mention. I've additionally applied it to the letters "A" and "J" (which I think are the worst offenders) and to \mathcal{A}. Apart from the "T" (which now looks worse), I think these are all improvements.

\documentclass{article}
\usepackage{amsmath}

\makeatletter %% <- make @ usable in command names
\newcommand*\rel@kern[1]{\kern#1\dimexpr\macc@kerna}
\newcommand*\presup[2]{%
  \begingroup
  \def\mathaccent##1##2{%
    {}^{#1}\rel@kern{-0.8}\macc@nucleus
  }%
  \macc@depth\@ne
  \let\math@bgroup\@empty \let\math@egroup\macc@set@skewchar
  \mathsurround\z@ \frozen@everymath{\mathgroup\macc@group\relax}%
  \macc@set@skewchar\relax
  \let\mathaccentV\macc@nested@a
  \macc@nested@a\relax111{#2}%
  \endgroup
}
\makeatother  %% <- revert @

\begin{document}

\begin{tabular}{lccccccccc}
    Bad: & ${}^xA^x$ & ${}^xJ^x$ & ${}^xT^x$ & ${}^xW^x$ & ${}^xY^x$ & ${}^xI^x$ & ${}^xD^x$ & ${}^xE^x$ & ${}^x\mathcal{A}^x$
    \\
    Good: & $\presup{x}{A}^x$ & $\presup{x}{J}^x$ & $\presup{x}{T}^x$ & $\presup{x}{W}^x$ & $\presup{x}{Y}^x$ & $\presup{x}{I}^x$ & $\presup{x}{D}^x$ & $\presup{x}{E}^x$ & $\presup{x}{\mathcal{A}}^x$
\end{tabular}

\end{document}

output

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.