1

I found that this MWE, compiled with pdflatex provide what I need:

\documentclass[a4paper]{article}   
\usepackage[T1]{fontenc}   
\begin{document}
\begin{center}
{\bfseries\scshape Bold Small Caps}
\end{center}
\end{document} 

I also pointed out that the combination \scshape and \bfseres works only with \usepackage[T1]{fontenc} option. Now I would like to get the same result using XeLaTeX but of course I cannot use fontenc package. I do not know how to do with fontspec

thank you

MaPo
  • 1,163

2 Answers2

6

Luatex (or rather the luaotfload Lua module) has its own font searching code which is naturally kpathsearch-aware and will find system fonts and fonts in texlive both by filename and by the internal font name such as CMU Serif.

xetex uses the system font cache (fc-cache on linux and cygwin, and I think comes with a local copy of fc-cache on windows) it can find system and texlive fonts by filename but can only find fonts by font name if they are known to the system (eg via fc-cache).

You could load CMU Serif by filename

\setmainfont{cmunrm.otf}

For some fonts that is no problem and a convenient way to load fonts but the disadvantage of loading by filename is that fontspec can then not automatically infer variants such as bold and small caps, these can be specified individually to fontspec but for a large collection like CMU that is a pain.

Easier is to make the fonts available to the system, so xetex can load them by name. For example on my windows/cygwin setup I can just drag copies to c:/windows/fonts, on a Mac you could install the fonts in /Library/Fonts.

Or on systems using fc-cache you can tell fc-cache to look in the texlive directories. If you save a file that looks like

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <dir>/usr/local/texlive/2016/texmf-dist/fonts/opentype</dir>
</fontconfig>

as

/etc/fonts/conf.d/09-texlive.conf

then run

sudo fc-cache -fsv

xetex will find the fonts.

The config file is a version of the file supplied in texlive as

/fonts/conf/texlive-fontconfig.conf

but restricted to opentype (the original had two extra lines for truetype and type1)

After all those preliminaries

\documentclass[a4paper]{article}   
\usepackage{fontspec} 
\setmainfont{CMU Serif}
%\setmainfont{cmunrm.otf}
\begin{document}
\begin{center}


{\bfseries Bold }

{\scshape Small Caps}

{\bfseries\scshape Bold Small Caps}
\end{center}
\end{document} 

produces

enter image description here

(Thanks to egreg for help with some of the details here)

David Carlisle
  • 757,742
  • FontConfig is not used on Mac, though. There you will need to make the fonts available to the system the usual Mac way (whatever it is, my Mac knowledge is very limited). – خالد حسني Dec 15 '16 at 05:48
  • @KhaledHosny thanks I update the wording a bit. – David Carlisle Dec 15 '16 at 09:11
  • Thank you so much. This works! I had some problem because of MathJax installed some fonts that interfere with the standard ones and so fc-cache was confused. So I removed MJ and the installed it again after fc-chace. Otherwise I guess I should have done some manual workaround... – MaPo Dec 15 '16 at 14:24
  • @DavidCarlisle The solution code doesn't work for me, even though I have CMU Serif installed. I get the error Font shape 'TU/CMUSerif(0)/b/sc' undefined using 'TU/CMUSerif(0)/b/n' instead on input line 13. However it works fine when I use \usepackage[T1]{fontenc}. – simple jack Mar 14 '21 at 05:13
  • @simplejack your coments here https://tex.stackexchange.com/questions/587223/how-to-get-cmu-small-caps-as-a-separate-font#comment1475415_587223 imply th efont is not installed? – David Carlisle Mar 14 '21 at 11:09
  • @DavidCarlisle Font Book says it is installed so I'm not sure. – simple jack Mar 15 '21 at 14:46
0

Try this!!!!

\documentclass[10pt]{article}    
\usepackage{libertine}    
%\usepackage{mathpazo}    
%\usepackage{newtxtext}    
%\usepackage{charter}    
%\usepackage{kpfonts}    
%\usepackage{fourier}    
%\usepackage[garamond]{mathdesign}    
%\usepackage{pxfonts}    
\begin{document}    
\bfseries\scshape Rhubarb Rhubarb    
\end{document}

enter image description here

Torbjørn T.
  • 206,688
Saravanan
  • 1,475