7

In the given MWE, the new sd command produces ^ carets higher than the hat carets. Is there a way to adjusted the newcommand at the bottom of the preamble to lower these carets to match? (Alegreya can be downloaded for free from FontSquirrel.)

It might seem silly, but I'm really going after the look of the \newcommand carets more than the hat carets.

%XeLaTeX
\documentclass{article}
\usepackage{mathspec}
\setmainfont[
    Extension = .otf,
    UprightFont = Alegreya-Regular,
    ItalicFont = Alegreya-Italic,
    BoldFont = Alegreya-Bold,
    BoldItalicFont = Alegreya-BoldItalic,
    UprightFeatures = {SmallCapsFont = AlegreyaSC-Regular},
    ItalicFeatures = {SmallCapsFont = AlegreyaSC-Italic},
    BoldFeatures = {SmallCapsFont = AlegreyaSC-Bold},
    BoldItalicFeatures = {SmallCapsFont = AlegreyaSC-BoldItalic},
    Ligatures = TeX]
    {Alegreya}
\setmathsfont(Digits,Latin,Greek)
    [Numbers=OldStyle]{Alegreya}
\newcommand{\sd}[1]{\accent"02C6 #1}

\begin{document}

\sd{1} $\hat{1}$ \sd{2} $\hat{2}$ \sd{3} $\hat{3}$ \sd{4} $\hat{4}$ \sd{5} $\hat{5}$ \sd{6} $\hat{6}$ \sd{7} $\hat{7}$

\end{document}

enter image description here

Oddly, the sd carets were exactly what I wanted when the following was the fontspec:

\setmainfont[
  SmallCapsFont={Alegreya SC},
  ItalicFeatures={SmallCapsFont=AlegreyaSC-Italic},
  BoldFeatures={SmallCapsFont=AlegreyaSC-Bold},
  BoldItalicFeatures={SmallCapsFont=AlegreyaSC-BoldItalic},
  Ligatures=TeX,
]{Alegreya}

For ligature and international character reasons, I had to clarify the fontspec as you saw in the original MWE; can anyone explain why that might be?

The answer may be in How do I lower the \widetilde accent, but to be honest I don't even know where to begin.

Richard
  • 2,084
  • I would not use oldstyle numerals in math formulas; stick with lining-style numerals for formulas. – Mico Oct 27 '15 at 22:36
  • I agree with you, but this is a humanities dissertation, and thus no math formulas :-) – Richard Oct 27 '15 at 22:37
  • So why define a maths font? And some humanities work includes maths. – cfr Oct 27 '15 at 22:41
  • I defined a math font in the MWE to show where I would like the carets to be. – Richard Oct 27 '15 at 22:42
  • What are these accented numbers for exactly, if they are not maths or similar? – cfr Oct 27 '15 at 22:43
  • In music, the caret above a number indicates a scale degree; so in C Major, C is ^1, G is ^5, etc. – Richard Oct 27 '15 at 22:44
  • I can't even compile it. XeTeX can't find the fonts even though they are installed. (XeTeX's ability to find fonts on my machine, at least, varies between minimal and nil.) – cfr Oct 27 '15 at 22:48
  • This is one of the reasons my fontspec is so specific; there are ligature problems on this system that other folks don't seem to have. – Richard Oct 27 '15 at 22:52
  • Is LuaLaTeX an option? If I ditch the mathspec stuff, it seems to place the accents more-or-less where you want them. (I can't compare exactly as I lose the comparison but they are certainly closer to the hats.) LuaTeX almost always works better for me than XeTeX - it is just so much less temperamental (in general). – cfr Oct 27 '15 at 22:54

1 Answers1

5

You can fix the height of the character by using \halign instead of \accent:

\documentclass{article}
\usepackage{mathspec}
\setmainfont[
    Extension = .ttf, % I only have TrueType
    UprightFont = *-Regular,
    ItalicFont = *-Italic,
    BoldFont = *-Bold,
    BoldItalicFont = *-BoldItalic,
    UprightFeatures = {SmallCapsFont = *SC-Regular},
    ItalicFeatures = {SmallCapsFont = *SC-Italic},
    BoldFeatures = {SmallCapsFont = *SC-Bold},
    BoldItalicFeatures = {SmallCapsFont = *SC-BoldItalic},
    Ligatures = TeX
]{Alegreya}
\setmathsfont(Digits,Latin,Greek)[
  Numbers=OldStyle
]{Alegreya-Regular}
\DeclareRobustCommand{\sd}[1]{%
  \leavevmode
  \vbox{\offinterlineskip
    \ialign{%
      ##\cr
      \hidewidth\char"02C6 \hidewidth\cr
      \noalign{\kern-0.95ex}
      #1\cr
    }%
  }%
}

\begin{document}

\sd{1} $\hat{1}$ \sd{2} $\hat{2}$ \sd{3} $\hat{3}$ 
\sd{4} $\hat{4}$ \sd{5} $\hat{5}$ \sd{6} $\hat{6}$ 
\sd{7} $\hat{7}$ \sd{8} $\hat{8}$ \sd{9} $\hat{9}$
\sd{0} $\hat{0}$

\end{document}

enter image description here

egreg
  • 1,121,712
  • You've helped me out several times in the past, and you came through again. I had to adjust to \kern-2ex, but it's perfect! – Richard Oct 27 '15 at 23:00