Graphics, Figures & TablesSmall font glitch in redefining caption label

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Small font glitch in redefining caption label

Post by Cham »

In the book and scrbook classes, I redefined the caption's label using this command in the preamble :

Code: Select all

\renewcommand*{\figureformat}{\sffamily\bfseries\figurename~\thefigure}
It's working great, except that I get a new warning in the console (I hate these!) :
LaTeX Font Warning: Font shape `T1/cmss/bx/sc' undefined
(Font) using `T1/cmss/bx/n' instead on input line 15.
So is there a better way in changing the caption's label style, so we don't get these pesky warnings each time there's a figure in the code ? Here's a MWE to mess with :

Code: Select all

\RequirePackage[l2tabu,orthodox]{nag}
\documentclass[11pt,twoside,letterpaper,headsepline,footsepline,cleardoublepage=plain,]{scrbook}
\renewcommand*{\figureformat}{\sffamily\bfseries\figurename~\thefigure}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage[total={6.25in,10in},left=1.25in,top=0.5in,includehead,includefoot]{geometry}
 
\begin{document}
 
	\begin{figure}
		\centering
		\includegraphics[height=4cm]{example-image-a}
		\caption{Some caption text.}
	\end{figure}
 
\end{document}
EDIT : Notice that the font substitution appears to be a problem with the command \usepackage[french]{babel}. If I remove it, I don't get any warning.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10330
Joined: Mon Mar 10, 2008 9:44 pm

Small font glitch in redefining caption label

Post by Stefan Kottwitz »

The French style changes the figure label to small caps shape. Since there's no bold small caps in the default font, it's ignored and a warning is issued. You can see the figure labels changing when you temporarily switch to a font that provides bold small caps, such as:

\usepackage{kpfonts}

Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Small font glitch in redefining caption label

Post by Cham »

So you suggest that I simply ignore these pesky font substitution messages ?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10330
Joined: Mon Mar 10, 2008 9:44 pm

Small font glitch in redefining caption label

Post by Stefan Kottwitz »

You can switch off that behavior:

Code: Select all

\usepackage[french]{babel}
\frenchbsetup{SmallCapsFigTabCaptions=false}
Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Small font glitch in redefining caption label

Post by Cham »

I fixed the font issue (I don't know exactly how) by adding options to the subfig package :

Code: Select all

\usepackage{subfig}
\captionsetup{figurename=Figure,margin=1in,format=hang,font=small,format=plain,labelfont={bf,up,sf},textfont={up}}
\captionsetup[subfigure]{margin=0cm,font=small,format=plain,labelfont={bf,up},textfont={up}}
\captionsetup[table]{name=Table,labelfont={bf,up}}
Post Reply