Quantcast
Channel: How to set bold small-caps in a table header? - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 3

Answer by Heiko Oberdiek for How to set bold small-caps in a table header?

$
0
0

Minimized MWE, because this is not related to a table header, but to the bold font used there:

\documentclass{article}\makeatletter\newcommand{\ion}[2]{#1$\;$\textsc{\rmfamily\@roman{#2}}\relax}\makeatother\begin{document}  \ion{He}{4}  \textbf{\ion{He}{4}}\end{document}

You get the wrong appearance:

Result with wrong font

and a warning:

LaTeX Font Warning: Font shape `OT1/cmr/bx/sc' undefined(Font)              using `OT1/cmr/bx/n' instead on input line 9.

That means, a bold version with small caps is not available and the regular (normal) bold font is used. The Computer Modern fonts as its successors the Latin Modern fonts miss a bold variant for small caps.A font with a bold variant is TG Termes a Times Roman clone from TeX Gyre font project:

\usepackage{tgtermes}

Result TG Termes

A poor man's solution would be to fake the small caps for the bold font by using uppercase letters and scaling them down to the size of the small caps lowercase letters. At least this avoids changing the entire font family.

\documentclass{article}\usepackage{graphicx}\makeatletter\newcommand{\ion}[2]{%  #1$\;$%  % Test for bold font by inspecting \f@series, it can be "b" or "bx"  \if b\expandafter\@car\f@series\relax\@nil    \begingroup % keep changes to scratch box register 0 local      \sbox0{\rmfamily\mdseries\textsc{v}}%      \resizebox{!}{\ht0}{\rmfamily\@Roman{#2}}%    \endgroup  \else    \textsc{\rmfamily\@roman{#2}}%  \fi}\makeatother\begin{document}  \ion{He}{4}  \textbf{\ion{He}{4}}\end{document}

Result faked small caps

And now a robust version with hyperref support. Then \ion can also be used inside captions and section titles:

\documentclass{article}\usepackage{graphicx}\usepackage{hyperref}\usepackage{bookmark}\makeatletter\newcommand{\ion}{}% Check, that \ion is not yet defined\DeclareRobustCommand*{\ion}[2]{%  #1$\;$%  % Test for bold font by inspecting \f@series, it can be "b" or "bx"  \if b\expandafter\@car\f@series\relax\@nil    \begingroup % keep changes to scratch box register 0 local      \sbox0{\rmfamily\mdseries\textsc{v}}%      \resizebox{!}{\ht0}{\rmfamily\@Roman{#2}}%    \endgroup  \else    \textsc{\rmfamily\@roman{#2}}%  \fi}\makeatother% hyperref support\pdfstringdefDisableCommands{%  \renewcommand*{\ion}[2]{%    #1 %    \@Roman{#2}% LaTeX's version via \@slowromancap is expandable  }%}\begin{document}  \tableofcontents  \section{\ion{He}{4}}  \ion{He}{4}  \textbf{\ion{He}{4}}\end{document}

Result robust/hyperref


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>