4

I like how there is a gap between the subscript and the superscript when I write ${w_i}^T$. However, if I try to put a hat on the vector, like $\hat{w}_i^T$, this space goes away. Any ideas?

I tried putting in an extra set of braces, as suggested for a similar question here, but it didn't work.

  • $\hat{w}_i^{\,T}$ or $\hat{w}_i^{~T}$ would be two really bad solutions. But they kinda work. – Pablo May 20 '14 at 21:02
  • @Mico Very nice! – Eric Auld May 20 '14 at 21:05
4

You could write $\hat{w}_i{}^T$ -- note the extra pair of curly braces immediately before ^T.

The following example shows both ${w_i}^T$ and $\hat{w}_i{}^T$.

enter image description here

\documentclass{article}
\begin{document}
$w_i{}^T$

$\hat{w}_i{}^T$
\end{document}
4

It's a known problem, which is due to a very low level feature of TeX. The solution is to add a pair of braces:

\documentclass{article}
\begin{document}
${w_i}^T\ne{\hat{w}_i}^T$ % this has no gap

${w_i}^T\ne{{}\hat{w}_i}^T$ % this has the gap
\end{document}

However, I wouldn't leave the gap, but the document is yours.

enter image description here

You could define a macro for it:

\newcommand{\transpose}[1]{{{}#1}^T}

Full example

\documentclass{article}
\newcommand{\transpose}[1]{{{}#1}^T}

\begin{document}

$\transpose{w_i}\ne\transpose{\hat{w}_i}$

\end{document}

The small raising of the T is somewhat unavoidable (and it's the reason for the low level feature).

  • The minor raising of the T would seem to be avoidable if the pair of braces is added after rather than before \hat{w}_i, i.e., if one writes \hat{w}_i{}^T. – Mico May 20 '14 at 21:55
  • Putting an empty brace pair inside a group with the accented letter causes the height of the whole group (hat and all) to be taken into account. This doesn't make much difference for w or any lowercase letter without ascender, but can make the superscript seem too high for taller symbols. Mico's answer works well for normal sized letters (upper or lowercase). But for any taller symbol, a \vphantom helps: \hat{X}_i{\vphantom{X}}^T – Dan May 20 '14 at 21:55
  • @Mico That's incorrect, because the height of the symbol is not taken into account. The only “correct” way is not having a gap at all. ;-) – egreg May 20 '14 at 22:28
  • I wasn't so much thinking about correct or incorrect vertical adjustments as about the claim that the extra raising was unavoidable. I concur that the gap should be avoided to begin with. – Mico May 20 '14 at 22:46
0

If you want a smaller gap, you can add \; before T. Here is an example of both — incidentally, you should use \ widehat` here. Compare:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage{heuristica}
\usepackage[overload]{empheq}
\usepackage{mathtools}
\usepackage[inline, shortlabels]{enumitem}

\begin{document}![enter image description here][1]

\[ \widehat{w}_i{}^T\quad \widehat{w}_i^{\;T} \]

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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