1

Does anyone know how to use the font Alegreya SC in LaTeX?

enter image description here

I am aware of the package Alegreya, but it does not seem to provide the right capitalization. Any ideas?

2 Answers 2

2

Mixing fonts should be done with care.

Looking in Alegreya.sty is not easy, because of the many options. So we can ask LaTeX to do the work for us.

\documentclass{article}
\usepackage{Alegreya}

\begin{document}

{\scshape\xdef\fontparams{\expandafter\string\the\font}}
\texttt{\fontparams}

\end{document}

Don't worry about the mysterious sequence of commands, but just for information

  • \the\font expands to the internal command for the current font
  • we need to “stringify” it so we can print it, but \string must be applied after expanding \the\font, so \expandafter does the trick
  • \xdef full expands the given replacement text and globally defines the macro
  • with \texttt we print it in a reasonable way for reading

The result is

enter image description here

OK, now we have the needed ingredients.

\documentclass{article}

\newcommand{\alegreyasc}{%
  \usefont{\encodingdefault}{Alegreya-LF}{regular}{sc}%
}
\DeclareTextFontCommand{\textalegreyasc}{\alegreyasc}

\begin{document}

Words in \textalegreyasc{Alegreya Small Caps 123}

\end{document}

I define both the switch \alegreyasc and the text command. Choose other names, if you so prefer.

enter image description here

If in the file to get the font parameters you do \usepackage[osf]{Alegreya}, you'll get

enter image description here

With

\newcommand{\alegreyasc}{%
  \usefont{\encodingdefault}{Alegreya-OsF}{regular}{sc}%
}

the example text above would become

enter image description here

1

Simple answer really, just add \textsc{Abc}.

3
  • 3
    \sc is not defined by default in latex, use {\scshape Abc} or \textsc{Abc} Commented Nov 30, 2022 at 14:51
  • Thank you, by any chance do you know how to apply it on a specific sentence? \usepackage{Alegreya} changes the font of the entire document
    – sam wolfe
    Commented Nov 30, 2022 at 14:54
  • just use \fontfamily{...}\selectfont the details of ... depend on which tex engine you are using, see the package Commented Nov 30, 2022 at 15:03

You must log in to answer this question.

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