# How to use fontspec and also have small bold caps with LuaLaTeX?

I was told by the Latex gurus that I should use \usepackage{fontspec} when using lualatex.

But now my small bold caps do not work: they come out only bold, but not caps, even though I added \usepackage[T1]{fontenc} which is needed to get this to work

\textbf{\textsc{bold small caps}}


But it no longer work because \usepackage{fontspec} is there.

Removing \usepackage{fontspec} and keeping \usepackage[T1]{fontenc} made it work (i.e. bold and also small caps)

Removing \usepackage[T1]{fontenc} and keeping \usepackage{fontspec} does not work: It becomes only bold, but not caps.

The question is, for lualatex only (I only use lualatex, not pdflatex), and if one is supposed to include \usepackage{fontspec}, how can one get small caps and bold? Does one really need \usepackage{fontspec} or can one get away with only \usepackage[T1]{fontenc} (too many packages, too much font confusion with Latex).

MWE

\documentclass[11pt]{article}

\ifdefined\HCode
\usepackage[utf8]{luainputenc}
\usepackage[T1]{fontenc} %watch out, Makes tex4ht \verb not accept  different fonts. bug
\else
\usepackage{fontspec}%for lualatex case
\usepackage[T1]{fontenc}%needed for small cap bold
\fi

\begin{document}

\textbf{\textsc{bold small caps}}
\end{document}


and

lualatex foo.tex

This is LuaTeX, Version 0.95.0 (TeX Live 2016)
restricted system commands enabled.
(./foo.tex
LaTeX2e <2016/03/31> patch level 2
....
(/usr/local/texlive/2016/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))

LaTeX Font Warning: Font shape T1/lmr/bx/sc' undefined
(Font)              using T1/lmr/bx/n' instead on input line 13.

[1{/usr/local/texlive/2016/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./foo.aux)

LaTeX Font Warning: Some font shapes were not available, defaults substituted.

)
...
/texmf-dist/fonts/type1/public/lm/lmr10.pfb>
Output written on foo.pdf (1 page, 39002 bytes).
Transcript written on foo.log.


TL 2016

• don't use fontenc with luatex Jul 28 '16 at 18:11
• @DavidCarlisle Thanks, I knew that, and I did not have it there, but then how to get bold small caps to work then? I read it is needed for small caps bold to work with lualatex. That is my question. Jul 28 '16 at 18:14
• You need to choose a font family that has bold small caps (most, including latin modern, do not) see tex.stackexchange.com/questions/27411/small-caps-and-bold-face Jul 28 '16 at 18:20
• @DavidCarlisle I did read the linked question. Actually it is there an answer which says to use fontenc. I tried the other suggestions {\bfseries {\scshape bold small caps}} and can't get any to give me bold and small caps with lualatex without fontenc. My question is how to get small caps and bold with lualatex without using fontenc. Thanks, Jul 28 '16 at 18:27

It is completely wrong to say that you need a particular font encoding to get small caps.

the issue is that CM Unicode includes bold small caps, but the (otherwise recommended) latin modern does not.

So you want cm unicode not latin modern (which is the default with fontspec)

\documentclass[11pt]{article}

\usepackage[tuenc]{fontspec}%for lualatex case

\setmainfont{CMU Serif}

\begin{document}

not bold or caps

\textsc{small caps}

\textbf{\textsc{bold small caps}}

\textbf{bold}

\end{document}

• Thanks. When I include \setmainfont{CMU Serif} it work. But it does not compile under latest miktex on windows. It compiles under TL 2016 on Linux. Error on windows is: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ! fontspec error: "font-not-found" ! The font "CMU Serif" cannot be found. ! See the fontspec documentation for further information. !............................................... l.10 \setmainfont{CMU Serif} ? I will look to see if this mean I need to do something special on windows to get this to work. Jul 28 '16 at 18:56
• @Nasser ctan says miktex has cm-unicode you presumably just need to install the relevant miktex package see the right hand panel at ctan.org/tex-archive/fonts/cm-unicode?lang=en Jul 28 '16 at 18:58
• I also found out that \setmainfont{CMU Serif} does not work with tex4ht on TL 2016. /usr/local/texlive/2016/texmf-dist/tex/latex/base/t1enc.def)) ! Undefined control sequence. l.30 \setmainfont {CMU Serif} is it possible to get a solution with the use of this command? tex4ht is kind'a complicated, as I use \usepackage[utf8]{luainputenc} for it and not \usepackage[tuenc]{fontspec}. Any way, it is not a big problem if it does not work, I'll just bypass this bold+caps when in tex4ht mode. I can have separate question on this, to keep this question simple. Jul 28 '16 at 19:45
• @Nasser ???? of course \setmainfont doesn't work the way you set up tex4ht as you don't load fontspec, but the whole point is that you are using cm unicode already in your T1 encoding setup that's why bold small caps worked, I just showed how to also use cm unicode in the luatex/pdf setup Jul 28 '16 at 20:22