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}
Richard
  • 2,084
  • 2
    \^{1} ?...... – yo' Mar 25 '15 at 21:14
  • I've tried this, but it results in a lone integer. It's a 1 in the Alegreya font (progress of a kind?), but there's no caret above it. – Richard Mar 25 '15 at 21:21
  • 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 '15 at 21:22
  • The Alegreya font has no U+0302 COMBINING CIRCUMFLEX ACCENT – egreg Mar 25 '15 at 21:26
  • 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 '15 at 21:28
  • @Sam That's why I ask for a MWE. I've got no idea what Alegreya is and where to get it from. – yo' Mar 25 '15 at 21:29
  • Manuel, this is perfect, thanks! @yo, sorry, I assumed it was clear enough that Alegreya was a font, thus no need for a MWE. – Richard Mar 25 '15 at 21:32
  • @Sam Yes, that is clear. What is not clear is that how are others supposed to get the font. – yo' Mar 25 '15 at 21:33
  • @Manuel Care to make it an answer? :) – yo' Mar 25 '15 at 21:33
  • @yo' It's not really an answer. It's not available in XeLaTeX and the workaround is \hat{\text{1}} (the î is not really a solution). I think better wait for someones magic to bring a better (or even real) \^1 in. EDIT: like the one that just came in :) – Manuel Mar 25 '15 at 21:35
  • 1
    @Manuel A hat trick ;-) – egreg Mar 25 '15 at 21:57
  • 1
    @yo' Alegreya is included in TeX Live. – egreg Mar 25 '15 at 21:57

1 Answers1

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

egreg
  • 1,121,712
  • 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 '15 at 21:38