# How to fix or change small caps bookmark?

One of the cool feactures of the hyperref package is the ability to make fancy pdf bookmarks. However, for some reason it does not work correctly for smallcaps (see aSmallCapsTitle in the screenshot), maybe the GUI font does not have smallcaps. Thus, does any one know how to fix that? Or if there is no fix, provide an alternative title for the bookmark.

Screenshot:

Minimal document:

\documentclass{article}
\usepackage{hyperref}
\usepackage[T1]{fontenc}

\begin{document}
\section{Introduction}
Content
\section{\textsc{aSmallCapsTitle}}
Content
\section{Conclusion}
Content
\end{document}

• as far as I know you can not use fonts at all in pdf bookmarks, it is just plain text. – David Carlisle Jun 30 '15 at 19:59
• hyperref should be the last package here, but that's not the problem here. The best you can get is bold and/or italic bookmarks with \usepackage[bold=true,italic=true}{bookmark}, for example. small caps as bookmark font isn't possible, as far as I know. This is a pdf feature. – user31729 Jun 30 '15 at 20:06

The Unicode standard defines some characters "LATIN LETTER SMALL CAPITAL". However, they are mostly semantically used for phonetics and should not be used as a font property. See Wikipedia/Small Caps/Unicode.

The bookmarks should be clear readable strings, also the possible font properties bold and italic should only be used sparingly.

Nevertheless, some simulation for \textsc is implementable for the bookmarks. The following example defines \bkmsc, which is used instead of \textsc in the bookmarks. It converts supported lowercase letters to the "small caps" letters, exceptions are q and y, their small caps variant is not availabel in Unicode. Other character tokens and spaces are passed through. The argument must be an expanded plain text string. For simplicity, the argument is \detokenized. Macros, special characters should be used outside.

Example:

\documentclass{article}
\usepackage[pdfencoding=auto]{hyperref}
\usepackage[T1]{fontenc}
\usepackage{bookmark}

\makeatletter
\newcommand*{\defLatinLetterSmallCapital}[2]{%
\@namedef{LLSC#1}{\unichar{"#2}}%
}
\defLatinLetterSmallCapital{a}{1D00}
\defLatinLetterSmallCapital{b}{0299}
\defLatinLetterSmallCapital{c}{1D04}
\defLatinLetterSmallCapital{d}{1D05}
\defLatinLetterSmallCapital{e}{1D07}
\defLatinLetterSmallCapital{f}{A730}
\defLatinLetterSmallCapital{g}{0262}
\defLatinLetterSmallCapital{h}{029F}
\defLatinLetterSmallCapital{i}{026A}
\defLatinLetterSmallCapital{j}{1D0A}
\defLatinLetterSmallCapital{k}{1D0B}
\defLatinLetterSmallCapital{l}{029F}
\defLatinLetterSmallCapital{m}{1D0D}
\defLatinLetterSmallCapital{n}{0274}
\defLatinLetterSmallCapital{o}{1D0F}
\defLatinLetterSmallCapital{p}{1D18}
\defLatinLetterSmallCapital{r}{0280}
\defLatinLetterSmallCapital{s}{A731}
\defLatinLetterSmallCapital{t}{1D1B}
\defLatinLetterSmallCapital{u}{1D1C}
\defLatinLetterSmallCapital{v}{1D20}
\defLatinLetterSmallCapital{w}{1D21}
\defLatinLetterSmallCapital{y}{028F}
\defLatinLetterSmallCapital{z}{1D22}

\defLatinLetterSmallCapital{bbar}{1D03}
\defLatinLetterSmallCapital{eth}{1D06}
\defLatinLetterSmallCapital{eturn}{2C7B}
\defLatinLetterSmallCapital{ghook}{029B}
\defLatinLetterSmallCapital{lstroke}{1D0C}
\defLatinLetterSmallCapital{mturn}{A7FA}
\defLatinLetterSmallCapital{nrev}{1D0E}
\defLatinLetterSmallCapital{oe}{0276}
\defLatinLetterSmallCapital{oopen}{1D10}
\defLatinLetterSmallCapital{ou}{1D15}
\defLatinLetterSmallCapital{rinv}{0281}
\defLatinLetterSmallCapital{rrev}{1D19}
\defLatinLetterSmallCapital{rrleg}{AB46}
\defLatinLetterSmallCapital{rturn}{1D1A}
\defLatinLetterSmallCapital{rum}{A776}
\defLatinLetterSmallCapital{ezh}{1D23}

\newcommand*{\bkmsc}[1]{%
\expandafter\BTS@ScanSpace\detokenize{#1} \@nil
}
\def\BTS@ScanSpace#1 #2\@nil{%
\BTS@ScanLetters#1\relax
\if\relax#2\relax
\expandafter\@gobble
\else
\expandafter\@firstofone
\fi
{%
\BTS@ScanSpace#2\@nil
}%
}
\def\BTS@ScanLetters#1{%
\ifx#1\relax
\expandafter\@gobble
\else
\expandafter\@firstofone
\fi
{%
\@ifundefined{LLSC#1}{#1}{\@nameuse{LLSC#1}}%
\BTS@ScanLetters
}%
}
\pdfstringdefDisableCommands{\let\textsc\bkmsc}
\makeatother

\begin{document}
\section{Introduction}
Content
\section{\textsc{aSmallCapsTitle}}
Content
\section{Conclusion}
Content
\section{\textsc{abcd efgh ijkl mnro p!rs tuvw !z}}
Content
\section{\texorpdfstring{Dummy}{%
\LLSCbbar\LLSCeth\LLSCeturn\LLSCghook\space
\LLSClstroke\LLSCmturn\LLSCnrev\LLSCoe\space
\LLSCoopen\LLSCou\LLSCrinv\LLSCrrev\space
\LLSCrrleg\LLSCrturn\LLSCrum\LLSCezh
}}
Content
\end{document}


The result is not too convincing:

• Kind of font mix-up with glyphs drawn with different line widths.
• Not all characters might be supported, here U+AB46 and U+A776 are missing.
• Gaps: the exclamation mark shows, where "Q" and "Y" are missing.
• Wrong semantics.

The bookmarks are called outline in PDF language specification.

From the PDF Reference 1.7 manual (pages 586/587) states

The value of the outline item dictionary’s F entry (PDF 1.4) is an unsigned 32-bit integer containing flags specifying style characteristics for displaying the item. Bit positions within the flag word are numbered from 1 (low-order) to 32 (high-order). Table 8.5 shows the meanings of the flags; all undefined flag bits are reserved and must be set to 0.

There are only two such flags (documented), bold and italic, having the values 2 and 1 respectively. Other font styles are not possible.

Using the bookmark package those flags can be (de)activated using

\usepackage[bold=true,italic=true]{bookmark}

(or set them to false otherwise).

Small caps fonts are not supported.

Edit A replacement way --> small caps in document, some other style for the bookmarks

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{hyperref}
\usepackage[bold=bold,italic=true]{bookmark}

\begin{document}
\section{Introduction}
Content
\section{\texorpdfstring{\textsc{aSmallCapsTitle}}{The non Small Caps title}}
Content
\section{Conclusion}
Content
\end{document}

• Ok, but is there any way to change the content of the small caps for an alternative one? – Marcos Roriz Junior Jun 30 '15 at 20:34
• @MarcosRorizJunior: Yes and no... You can use \texorpdfstring{tex version}{pdf version} to provide the small caps for the document body and some other style (well, bold and italic at most) for the pdf bookmarks. Regarding bookmarks it's often a good idea to apply \texorpdfstring – user31729 Jun 30 '15 at 20:41