# Adding default \skew to math accents

Out of corporate design reasons I should use Helvetica for my documents. I could simply ignore this, as most people do ;-) But out of fun I just combined ideas taken from sfmath and beamer to make exercise sheets containing acceptable-looking math formulas with the tgheros font. The only trouble is, as usual, the positioning of math accents. As far as I understand sansmathaccent works for Computer Modern, so it's not a solution here.

By repeated trial-and-error I've found that e.g. \skew2 is good with almost all letters for the \bar, so my idea was to use

\makeatletter
\let\mnf@bar\bar
\renewcommand{\bar}[1]{\ifcat#1\relax\expandafter\@gobbletwo\fi\skew2\mnf@bar{#1}}
\makeatother


and similar replacements for the other math accents. The \ifcat construct checks if the argument is a control sequence, in which case the \skew is \@gobbled away.

My question is whether such a construct may collide with packages redefining the math accents (like amsmath, although it did work when I tried it out) or if there is some safer way to achieve the same result.

• \ifcat\relax#1 is a lot safer than \ifcat#1\relax (the former is true if you go \bar{ab} or false for \bar{\hbox{zz}} – David Carlisle Sep 24 '15 at 13:25
• Uhm, that's surely true for \bar{ab}, but if I use \ifcat\relax#1 and #1 is \hbox{something}, the comparison strips the \hbox but leaves the {something}, which is then printed twice. I guess this answers my question as in: don' t do that! :-) – campa Sep 24 '15 at 13:45

I give here the solution I've ended up using.

First, it is definitely a bad idea to redefine the standard accents, or at the very least it is a bad idea to hide the original definition in some \@... macro. I haven't made up my mid yet but I will either copy the original definition with some meaningful name, or more likely use a new name for the new versions.

Second, the definition I proposed above

\newcommand{\mybar}[1]{\ifcat#1\relax\expandafter\@gobbletwo\fi\skew2\bar{#1}}


works as long as the argument is a single token like a or \phi, and even with \mathbf{a}, but it fails for e.g. \bm{a}. So in the end I changed the definition of \mybar into

\newcommand{\mybar}[1]{\ifcat a#1\else\expandafter\@gobbletwo\fi\skew2\bar{#1}}


Of course if the argument is a multi-token string starting with a letter (although I never used something like that) this won't work; hence I'm again at my point #1: do not redefine the standard math accents.