TransWikia.com

Modify numbering style of PDF bookmarks

TeX - LaTeX Asked by Frunobulax on February 24, 2021

I’m using

usepackage[numbered]{bookmark}

to get numbered bookmarks for the chapters of my book and that works as expected. However, I’d like to change the style and have the bookmarks look like "42. Cool Chapter" instead of "42 Cool Chapter", i.e. I want to add a dot after the chapter number (without changing the document itself, of course). I guess this can be done with the styles and/or hooks that the bookmark package offers, but my TeX fu isn’t good enough to extract from the documentation what I have to do. I’d be happy if someone could show me how to do this.

(In case you’re wondering whether it is a wise decision to add dots there: This is what the publisher wants.)

EDIT: The setup for my book is too complicated to show here, but if people insist on having a MWE, I guess I can take it from here:

documentclass{book}
usepackage{hyperref}
usepackage[numbered]{bookmark}
begin{document}
chapter*{Preface}
addcontentsline{toc}{chapter}{Preface}
Some text
chapter{First chapter}
More text
chapter{Second chapter}
Even more text
end{document}

I now have three bookmarks. I want the first one to remain untouched while the second one should be "1. First chapter" and the third one should be "2. Second chapter".

One Answer

documentclass{book}
usepackage{hyperref}
usepackage[numbered]{bookmark}
makeatletter
 renewcommandHy@numberline[1]{#1. }
makeatother
begin{document}
chapter*{Preface}
addcontentsline{toc}{chapter}{Preface}
Some text
chapter{First chapter}
More text
chapter{Second chapter}
Even more text
end{document}

enter image description here

Correct answer by Ulrike Fischer on February 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP