5

I am trying to use such code:

$$ \boldsymbol{f}\left(\prescript{S}{E}{\hat{\boldsymbol{q}}},\prescript{E}{}{\hat{\boldsymbol{d}}}, \prescript{S}{}{\hat{\boldsymbol{s}}}\right) $$

But the result looks like this:

enter image description here

as you can see the height of the letters in pre-supscript differs with height of the main letter. Any idea how to align these?

Dalbenn
  • 51
  • We need a mini document that we can compile this command with relevant packages or macro definitions. – percusse Aug 28 '16 at 10:45
  • 1
    Welcome to TeX.SX!! Rather than posting code fragments it is better to give a full minimal working example. Currently we have to guess what packages etc you are using and this makes it really hard to help you. A MWE should start with a \documentclass command, have a minimal preamble and then \begin{document}...\end{document}. The code should compile and be as small as possible to demonstrate your problem. This makes it much easier for people to help you --- and much more likely that they will! –  Aug 28 '16 at 10:59
  • 1
    Side note: Don't use $$....$$ -- that's deprecated. Use \[...\] –  Aug 28 '16 at 11:16
  • 1
    you might try adding an empty group {} at the beginning of the "hatted" argument if that letter is tall. – barbara beeton Aug 28 '16 at 12:45
  • That was a fast response! Sorry about not providing all necessary information and thanks for the help. Using the empty group {} as @barbarabeeton suggested solved the problem :) – Dalbenn Aug 28 '16 at 12:54
  • 1
    Incidentally, using \left here gives the wrong spacing, either use a specifically size bracket, such as \bigl( or precede the \left with \mathopen{} or use a mathtools paired delimiter, see http://tex.stackexchange.com/q/2607/15925 – Andrew Swann Aug 28 '16 at 14:49

2 Answers2

5

In normal math mode, subscripts and superscripts are placed ignoring math accents and the same should be with \prescript; unfortunately, mathtools doesn't exclude math accents from consideration when deciding the dimensions of the phantom to which the “prescripts” are attached to.

\documentclass{article}
\usepackage{mathtools,bm,xpatch}

\makeatletter
\def\remove@math@accents{%
  \let\hat\@firstofone
  % add the accents you need to cope with
}
\MHInternalSyntaxOn
\xpatchcmd{\MT_prescript_inner:}{{#3}}{{\remove@math@accents#3}}{}{}
\MHInternalSyntaxOff
\makeatother

\begin{document}

\[
\bm{f}(
  \prescript{S}{E}{\hat{\bm{q}}},
  \prescript{E}{}{\hat{\bm{d}}},
  \prescript{S}{}{\hat{\bm{s}}}
)
\]

\end{document}

enter image description here

egreg
  • 1,121,712
0

Using empty group as suggested in the comments solved it, so the final code is:

\[ \boldsymbol{f}\left(\prescript{S}{E}{\hat{\boldsymbol{q}}},\prescript{E}{}{}\hat{\boldsymbol{d}}, \prescript{S}{}{\hat{\boldsymbol{s}}}\right) \]

Thanks everyone.

Dalbenn
  • 51