8

I have dots at the end of section, subsection, etc. titles using the secdot package. And I'd like to insert a dot at the end of each section number in the PDF bookmarks too (I'm using hyperref).

Here is a screenshot what I'd like to achieve (see section 5 in the bookmarks on the left ), and a minimal working example (included packages and parts of the preamble which may cause problems, clashes):

MWE

\documentclass[12pt]{article}

\usepackage[a4paper, hscale=0.85, vscale=0.85]{geometry}
\usepackage[T1]{fontenc}
\usepackage{url}
\usepackage{hyperref}
\usepackage{xcolor}
\usepackage[dotinlabels]{titletoc}
\usepackage{secdot}

\hypersetup{bookmarks=true,%
    bookmarksnumbered=true,%
    pdfencoding=unicode,%
    colorlinks=true,%
    pdfborder={0 0 0},%
    linkcolor=red,%
    menucolor=green,%
    citecolor=blue,%
    urlcolor=blue,%
    filecolor=blue}

\sectiondot{section}
\sectiondot{subsection}
\sectiondot{subsubsection}
\sectiondot{paragraph}
\sectiondot{subparagraph}

% changing the style of \paragraph and \subparagraph titles, so
% text after \paragraph and \subparagraph are broken into new lines
\makeatletter
    \renewcommand\paragraph{%
        \@startsection{paragraph}{4}{0mm}%
            {-\baselineskip}%
            {.3\baselineskip}%
            {\normalfont\normalsize\bfseries}}
    \renewcommand\subparagraph{%
        \@startsection{subparagraph}{5}{0mm}%
            {-\baselineskip}%
            {.3\baselineskip}%
            {\normalfont\normalsize\bfseries}}
\makeatother

\setcounter{secnumdepth}{5}


\begin{document}

\section{section}

section

\subsection{subsection}

subsection

\subsubsection{subsubsection}

subsubsection

\paragraph{paragraph}

paragraph

\subparagraph{subparagraph}

subparagraph

\end{document}

I've started to look into hyperref's code, but I couldn't find the part that I have to modify/patch/renew.

1 Answer 1

11

hyperref stores this formatting in \Hy@numberline. So, the following redefinition adds a . after every sectional number unit:

\makeatletter
\renewcommand{\Hy@numberline}[1]{#1. }
\makeatother

Add it somewhere in your preamble after loading hyperref.

enter image description here

1
  • Is it possible to only add a . if it is a lone number like 5 and not if it has a subsection like 5.1?
    – leonheess
    Dec 19, 2019 at 15:36

You must log in to answer this question.

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