2

I'm using the Alegreya font in XeLaTeX and I'm wondering if I can put a hat over numbers outside of math mode. I ask because Alegreya doesn't have math functionality, so the integers default to CM font, which ends up looking pretty amateur in the context; euler also doesn't help. Is there a way to do this outside of math mode, thus keeping Alegreya's numbers?

Or, of course, is there some other work around to put a hat above Alegreya's numbers?

Font mismatch with Linux Libertine and siunitx package might be helpful but I'm not sure how yet...

MWE:

%XeLaTeX
\documentclass{article}
\usepackage[osf]{Alegreya}
\begin{document}
I want $\hat{1}$ where the 1 is in the Alegreya font. \^{1} seems to only work for l\^{e}tters.
\end{document}
12
  • 2
    \^{1} ?......
    – yo'
    Mar 25, 2015 at 21:14
  • 1
    Not that I would be able to truly debug it beyond trial and error, but could you make a short and simple MWE containing \^{1}? Because if I just make a very simple document and compile it with XeLaTeX, it works: \documentclass{article} \begin{document} A\^{1}A \end{document}
    – yo'
    Mar 25, 2015 at 21:22
  • 1
    Since we are in XeLaTeX, I would expect \^{1} to call a real 1 with a hat (which might not be available in Alegreya. Is that it? In any case, two fast alternatives (with mathtools package for \text) $\hat{\text{1}}$ \^i î. In any case, it does work in pdfLaTeX, since the font is available, what's the need for XeLaTeX?
    – Manuel
    Mar 25, 2015 at 21:28
  • 1
    @Manuel A hat trick ;-)
    – egreg
    Mar 25, 2015 at 21:57
  • 1
    @yo' Alegreya is included in TeX Live.
    – egreg
    Mar 25, 2015 at 21:57

1 Answer 1

6

The Alegreya font seem not to have U+0302 COMBINING CIRCUMFLEX ACCENT, so only precomposed character with the circumflex over them are available.

However, it has U+02C6 MODIFIER LETTER CIRCUMFLEX ACCENT that can be used as substitute.

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Alegreya}

\newcommand{\fhat}[1]{\accent"02C6 #1}

\begin{document}
\^a \fhat{1} \fhat{2} \fhat{3}
\end{document}

enter image description here

1
  • Thanks @egreg, this is even better; now I can input something in front of it $\flat$\fhat{3} as well, which I couldn't quite do with Manuel's solution.
    – Richard
    Mar 25, 2015 at 21:38

You must log in to answer this question.

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