what packages do I need to define this command? \newcommand{\textsca}[1]{{\fontspec{TeX…
- User
what packages do I need to define this command? \newcommand{\textsca}[1]{{\fontspec{TeX Gyre Termes}\textsc{#1}}}
- Assistant
The command you wrote uses \fontspec, which comes from XeLaTeX or LuaLaTeX (not pdfLaTeX). Here’s what you need to make it work:
Compiler:
You must compile with XeLaTeX or LuaLaTeX (because \fontspec is not supported by pdfLaTeX).
Packages: latexCopy code\usepackage{fontspec} % provides \fontspec
This is the only required package for \fontspec.
Font availability:
The font TeX Gyre Termes must be installed on your system.
This font is usually included in TeX distributions (TeX Live, MiKTeX), but if you get an error about missing fonts, you can install the TeX Gyre fonts manually or choose a different font that is available.
So a minimal working example would look like: latexCopy code\documentclass{article} \usepackage{fontspec} % Required for \fontspec
\newcommand{\textsca}[1]{{\fontspec{TeX Gyre Termes}\textsc{#1}}}
\begin{document} Here is \textsca{Small Caps in TeX Gyre Termes}. \end{document}
✅ Summary: You just need \usepackage{fontspec} and to compile with XeLaTeX or LuaLaTeX. No extra packages are required. Do you want me to suggest a pdfLaTeX-compatible alternative (in case you don’t want to use XeLaTeX/LuaLaTeX)?
- User
Package fontspec Error: The font "TeX Gyre Termes SC" cannot be found.
- Assistant
Ah — that error message means \fontspec is trying to load a specific font name (TeX Gyre Termes SC) and your system can’t find it. A couple of important clarifications:
\fontspec{TeX Gyre Termes} loads the regular TeX Gyre Termes font, not the small-caps variant.
When you then use \textsc{...}, LaTeX tries to switch to the small-caps version of that font — which might not exist as a separate font file (some font families ship small caps as a separate font, others provide them as an OpenType feature).
- User
how to use the third option? can you show me an example?
- Assistant
Absolutely! Option 3 is very practical if you want to just pick a font that you know has proper small caps support and use it consistently. Here’s a minimal working example using EB Garamond, which is a freely available font with beautiful small caps: latexCopy code\documentclass{article} \usepackage{fontspec}
% Define a font family with small caps enabled \newfontfamily\myfont[Letters=SmallCaps]{EB Garamond}
% Define a shortcut command \newcommand{\textsca}[1]{{\myfont #1}}
\begin{document}
Normal text here.
\textsca{This is small caps text using EB Garamond.}
More normal text.
\end{document}
How This Works
\newfontfamily\myfont[Letters=SmallCaps]{EB Garamond} Loads EB Garamond as a new font family, with the OpenType small caps feature enabled by default.
\textsca{...} Switches to that font for the argument, so the text inside is automatically rendered in small caps.
Notes:
You must compile with XeLaTeX or LuaLaTeX (not pdfLaTeX).
EB Garamond should be included in TeX Live / MiKTeX by default. If not, you can install it manually or choose another font (like TeX Gyre Pagella, Linux Libertine O, or Latin Modern Roman).
- User
ok, good. how can I change it to bo also bold?
- Assistant
Great question! You can tell fontspec to enable bold small caps by using two options at once:
Letters=SmallCaps → enables small caps
BoldFont=* (or just letting fontspec pick the bold face automatically) → allows bold weight
Then when you wrap text in \textbf{...}, it will stay in bold + small caps.
Here’s the updated example: latexCopy code\documentclass{article} \usepackage{fontspec}
% Define EB Garamond with small caps and allow bold \newfontfamily\myfont[Letters=SmallCaps]{EB Garamond}
% Define a shortcut command \newcommand{\textsca}[1]{{\myfont #1}}
\begin{document}
Normal text here.
\textsca{This is regular small caps.}
\textsca{\textbf{This is bold small caps.}}
\end{document}
How It Works
\newfontfamily automatically loads both the regular and bold faces if they exist.
When you call \textbf{...} inside \textsca, fontspec switches to the bold face and keeps the small caps feature active.