1

I use the Kepler font in my document. It's a very good font for math but it has an issue typesetting the \hat and \widehat commands: the \hat command produces a very small hat and \widehat produces a hat that is too wide.

Is there a way to adjust the \hat and \widehat size?

Here's my MWE. The attached image displays the output.

\documentclass[12pt,reqno]{amsart}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{kpfonts} \usepackage{textcomp} \usepackage{amsmath,amsthm,amsxtra} \usepackage{amssymb} \usepackage{bm}

\begin{document} Kepler fonts

$\sigma, \hat{\sigma}, \widehat{\sigma}$

$\varepsilon, \hat{\varepsilon}, \widehat{\varepsilon}$

$a, \hat{a}, \widehat{a}$ \end{document}

kpfonts hats

mickep
  • 8,685
Lambert
  • 87
  • 1
  • 3
  • 1
    Sorry, there is no image. Just run the MWE to see the results – Lambert Apr 23 '22 at 00:22
  • 1
    Why are you including stix2 before kpfonts? More to the point, why are you including amssymb after? That seems like it would, at best, have no effect, and at worst mess things up. – Davislor Apr 23 '22 at 01:13
  • Stix2 is commented out – Lambert Apr 23 '22 at 04:38
  • I cleaned up the code a bit and added a picture. Please check that I did not do a mistake. – mickep Apr 23 '22 at 04:55
  • This seems like a font issue to me. The hat doesn't look to narrow, it just is in the wrong place. You could try contacting the package maintainer to see if they will fix it. – schtandard Apr 23 '22 at 07:18

2 Answers2

1

Just slightly modifying my answer at Really wide hat symbol, \reallywidehat will adjust to the width of the argument.

\documentclass[12pt,reqno]{amsart}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{kpfonts} \usepackage{amsmath,amsthm,amsxtra} \usepackage{bm}

\usepackage{scalerel,stackengine} \stackMath \newcommand\reallywidehat[1]{% \savestack{\tmpbox}{\stretchto{% \scaleto{% \scalerel*[\widthof{\ensuremath{#1}}]{\kern.1pt\mathchar"0362\kern.1pt}% {\rule{0ex}{\textheight}}%WIDTH-LIMITED CIRCUMFLEX }{\textheight}% }{2.4ex}}% \stackon[-8.5pt]{#1}{\tmpbox}% }

\begin{document} Kepler fonts

$\sigma, \hat{\sigma}, \widehat{\sigma}, \reallywidehat{\sigma}, \reallywidehat{\sigma\sigma\sigma}$

$\varepsilon, \hat{\varepsilon}, \widehat{\varepsilon}, \reallywidehat{\varepsilon}, \reallywidehat{\varepsilon\varepsilon\varepsilon}$

$a, \hat{a}, \widehat{a}, \reallywidehat{a}, \reallywidehat{aaa}$ \end{document}

enter image description here

  • 1
    Great solution! While you’re editing the MWE, you might remove textcomp (now part of the kernel) and amssymb (which kpfonts loads automatically). Although both are harmless, just unnecessary on a recent distro.. – Davislor Apr 23 '22 at 14:43
  • To Everybody: These are really great solutions and comments! I greatly appreciate your taking the time to reply. – Lambert Apr 23 '22 at 21:26
0

If you can use LuaLaTeX or XeLaTeX, you can use the OTF version of the Kepler fonts, which you might prefer here.

\documentclass[12pt,reqno]{amsart}

\usepackage{kpfonts-otf} \usepackage{amsthm}

\begin{document} Kepler fonts

$\sigma, \hat{\sigma}, \widehat{\sigma}$

$\varepsilon, \hat{\varepsilon}, \widehat{\varepsilon}$

$a, \hat{a}, \widehat{abcd}$ \end{document}

Kepler Fonts sample

If you need to replace symbols from a different OpenType font, there is a standard syntax for that in unicode-math, e.g.:

\setmathfont{STIX Two Math}[Scale = MatchLowercase, range={\hat, \widehat}]

It is possible to get only one accent from a math symbol package in legacy 8-bit LaTeX. Every 8-bit package is different, though. There is no standard way to do it.

Davislor
  • 44,045