2

I'd like to create wider accents which are visible. The accepted answer to this question is the ideal solution; it uses the accents package.

My problem appears if I use this solution with the Latin Modern font provided by the package lmodern. If accents are used in super- or subscripts, the accent is placed a lot higher than normal. How does one fix this?

\documentclass{article}

\usepackage{lmodern}

\usepackage{mathtools}
\usepackage[single]{accents}

\DeclareMathSymbol{\widehatsym}{\mathord}{largesymbols}{"62}
\newcommand{\lowerwidehatsym}{\text{\smash{\raisebox{-1.3ex}{\(\widehatsym\)}}}}
\renewcommand{\hat}[1]{\mathchoice
    {\accentset{\displaystyle\lowerwidehatsym}{#1}}
    {\accentset{\textstyle\lowerwidehatsym}{#1}}
    {\accentset{\scriptstyle\lowerwidehatsym}{#1}}
    {\accentset{\scriptscriptstyle\lowerwidehatsym}{#1}}
}

\begin{document}

\(\hat{a}, \exp(a^{\hat{a}})\).

\end{document}

enter image description here

1 Answer 1

5

The package fixcmex has been written just to overcome this problem of lmodern. Use it along with amsmath.

\documentclass{article}

\usepackage{lmodern}
\usepackage{mathtools}% also loads amsmath
\usepackage{fixcmex}

\begin{document}

\(\hat{a}, \exp(a^{\hat{a}})\).

\(\widehat{a}, \exp(a^{\widehat{a}})\).

\end{document}

enter image description here

I'd go with \hat.

I don't see any improvement with your complicated code.

\documentclass{article}

\usepackage{lmodern}
\usepackage{mathtools}% also loads amsmath
\usepackage{fixcmex}
\usepackage[single]{accents}

\DeclareMathSymbol{\widehatsym}{\mathord}{largesymbols}{"62}
\newcommand{\lowerwidehatsym}{\text{\smash{\raisebox{-1.3ex}{\(\widehatsym\)}}}}
\renewcommand{\hat}[1]{\mathchoice
    {\accentset{\displaystyle\lowerwidehatsym}{#1}}
    {\accentset{\textstyle\lowerwidehatsym}{#1}}
    {\accentset{\scriptstyle\lowerwidehatsym}{#1}}
    {\accentset{\scriptscriptstyle\lowerwidehatsym}{#1}}
}

\begin{document}

\(\hat{a}, \exp(a^{\hat{a}})\).

\end{document}

enter image description here

2
  • Thx for the advertisement. The main reason I do this complicated code is to make \hat horizontally non-stretchable. Compare \widehat{M} with \widehat{A}.
    – Gargantuar
    Commented May 17 at 12:54
  • @Gargantuar I'd stay with \hat anyway.
    – egreg
    Commented May 17 at 12:58

You must log in to answer this question.

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