3

Am using LuaHBTeX and want to write Vinkel in the caption using bold small caps, but the command \sc{\textbf{Vinkel}} won't do it.

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}
  \includegraphics[width=\linewidth]{boat.jpg}
  \caption{\sc{\textbf{Vinkel}}A boat.}
  \label{fig:boat1}
\end{figure}
Figure \ref{fig:boat1} shows a boat.
\end{document}
10
  • Welcome to TeX.SE.
    – Mico
    Commented Jun 16 at 13:40
  • 3
    the command is \textsc not \sc. But beside this: you need \usepackage[T1]{fontenc}, cmr in OT1 doesn't have a bold small caps. Commented Jun 16 at 13:41
  • 2
    @Mico so slow ;-) Commented Jun 16 at 13:55
  • 1
    @Mico no it is not a old versus new problem. OT1 fonts could have bold small caps too, and T1 fonts can miss them. In this case it is simply so that the OT1-cmr don't have it, but the T1-ec font do. But if you e.g. add \usepackage{lmodern} you would loose them again. Or if you used \usepackage{tgtermes} it would work with both encodings. (But generally naturally T1-encoding is recommended as it supports more glyphs). Commented Jun 16 at 14:16
  • 1
    You asked, "But why don't you just have T1 as default?" Keeping Ot1 as the default is done purely for backward compatibility reasons. There are still lots of decades-old LaTeX documents out there, which might have to be rewritten if T1 were made the default before they could be (re)compiled. IMNSHO, this guaranteed backward compatibility is actually a rather attractive feature.
    – Mico
    Commented Jun 16 at 20:04

2 Answers 2

4

Assuming you employ pdfLaTeX to compile your document, you need to add the instruction \usepackage[T1]{fontenc} in the preamble.

Do also note that \sc is obsolete; it's a switch, not a command that takes an explicit argument. Depending on what you're trying to achieve, you should write either

\caption{\scshape\textbf{Vinkel} A boat.}

or

\caption{\textsc{\textbf{Vinkel}} A boat.}

Given your write-up, I assume it's the latter that you want.


Addendum to address the OP's follow-up request: The following preamble code should serve you regardless of whether you use LuaLaTeX or pdfLaTeX to compile your document.

enter image description here

\documentclass{article}
\usepackage{graphicx} % not needed for this simplified example.

\usepackage{iftex}
\iftutex % LuaTeX or XeTeX is in use
\usepackage{unicode-math} % 'unicode-math' loads 'fontspec' automatically
  %% copied from @Davislor's answer at https://tex.stackexchange.com/a/568209
  %% text font:
  \setmainfont{Latin Modern Roman}[%
    SmallCapsFont = Latin Modern Roman Caps,
    UprightFeatures = {SmallCapsFeatures = {}}, % Suppress warnings.
    BoldFeatures = {SmallCapsFont = {CMU Serif Bold}},
    ItalicFeatures = {SmallCapsFont = {CMU Serif Roman Slanted}},
    BoldItalicFeatures = {SmallCapsFont = {CMU Serif Bold Slanted}},
    SmallCapsFeatures={Letters=SmallCaps}]

  %% math font:
  \setmathfont{Latin Modern Math}[%
    % See the user guide of the 'unicode-math' package
    % for information about available options.
   ]  
\else % pdfTeX is in use
  \usepackage[T1]{fontenc}
  % Load additional font packages as needed if you don't 
  % want the default fonts (Computer Modern text and math).
\fi

\begin{document}
\textsc{\textbf{Vinkel}} A boat.
\end{document}
1
3

The first problem is that you used the obsolete \sc command, when you apparently meant \textsc to change only the word Vinkel (or possibly \scshape to change everything in the environment, although the braces afterward imply something else). The second problem is that the default font doesn’t have a bold small-caps style. Thus, you get the following warning message on the console:

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

The font TU/lmr/bx/sc is Unicode encoding/Latin Modern/bold extended/small-caps, which doesn’t exist, so LuaTeX substitutes Latin Modern Bold. Load a font that does have bold small caps, such as New Computer Modern:

\documentclass{article}
\usepackage{graphicx}
\usepackage[default]{fontsetup} % Loads New Computer Modern Book.

\begin{document}
\begin{figure}
  %\includegraphics[width=\linewidth]{boat.jpg}
  \caption{\textsc{\textbf{Vinkel}} A boat.}
  \label{fig:boat1}
\end{figure}
Figure \ref{fig:boat1} shows a boat.
\end{document}

New Computer Modern Book sample

0

You must log in to answer this question.

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