[Tex/LaTex] How to change the PDFBookmark titles (hyperref)


I am looking to change the title which displays in the PDF bookmark tabs to match the format of how I have my chapters listed.

\usepackage[hidelinks]{hyperref} %to add hyperlinks throughout document
\usepackage{titlesec} %reformatting the chapter headings
    {\normalfont\LARGE\bfseries\centering}{CHAPTER \thechapter}{0em}{:\hspace{2mm}}


\chapter{THE END}

What i currently have is:

title format

with the option of creating bookmarks of:

bad bookmarks1
bad bookmarks2

What I want my bookmarks to look like is identical to how the chapter title is formatted:

good bookmark

I have found that I can input \pdfbookmark[0]{THE BEGINNING}{name1}, but I would need to remove the bookmarks created by hyperref (which would not be ideal if I have multiple chapters, sections, subsections, etc., and have to input them all manually using this method.)

Will I have to work with changing \chapter{THE BEGINNING} to \chapter{CHAPTER \thechapter: THE BEGINNING}, then worry about removing the chapter number from 'CHAPTER 1: THE BEGINNING' from the title and ToC?


The best option I found is:
How to remove chapter numbering without removing it from tableofcontents

I can use the code


I use TeXMaker, and I like the structure is provides for opening/organizing subfiles (i.e. using \input{...}). To keep this as organized as possible, I resorted to the following:

  1. Create .tex file titled Chapter.1.THEBEGINNING

  2. This subfile will include \mychapter{1}{CHAPTER \thechapter: THE BEGINNING}

  3. My main document will include \input{Chapter.1.THEBEGINNING}

This works well enough…although still looking for better options.

Best Answer

This example provides a small modification of Werner's solution. Instead of patching the internal \Hy@writebookmark the redefinition of \numberline is done in the bookmark hook addtohook of package bookmark:



\usepackage{titlesec} %reformatting the chapter headings
  {CHAPTER\thechapter: }{0em}{}

      \renewcommand*{\numberline}[1]{CHAPTER #1: }%



\section{A section}

\chapter{THE END}