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.

9
  • I would not use oldstyle numerals in math formulas; stick with lining-style numerals for formulas.
    – Mico
    Oct 27, 2015 at 22:36
  • I agree with you, but this is a humanities dissertation, and thus no math formulas :-)
    – Richard
    Oct 27, 2015 at 22:37
  • So why define a maths font? And some humanities work includes maths.
    – cfr
    Oct 27, 2015 at 22:41
  • I defined a math font in the MWE to show where I would like the carets to be.
    – Richard
    Oct 27, 2015 at 22:42
  • What are these accented numbers for exactly, if they are not maths or similar?
    – cfr
    Oct 27, 2015 at 22:43

1 Answer 1

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

1
  • 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, 2015 at 23:00

You must log in to answer this question.

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