I am trying to define my own document class with some lead-in style heading text and pdf bookmarks.
Here is my class file myclass.cls:
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{myclass}
\LoadClass[12pt,oneside,a4paper]{article}
\makeatletter
% disable section numbering
\setcounter{secnumdepth}{-2}
% define lead-in section
\renewcommand\section{
@startsection{section}{1}{\z@}{-1ex}{-1.5ex}{\bfseries\MakeUppercase}%
}
\RequirePackage{hyperref}
\hypersetup{bookmarksdepth=4}
\makeatother
And here is my document source mydoc.tex:
\documentclass{myclass}
\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}
\section{First Section}
\blindtext[5]
\section{Second Section}
\blindtext[5]
\section{Third Section}
\blindtext[5]
\end{document}
If I compile this with pdflatex I get the following warnings:
pdfTeX warning (dest): name{section*.
3} has been referenced but does not exist, replaced by a fixed one
pdfTeX warning (dest): name{section*.2} has been referenced but does not exist,
replaced by a fixed one
pdfTeX warning (dest): name{section*.1} has been referenced but does not exist,
replaced by a fixed one
And pdf bookmarks do not go to their respective heading with clicked in the pdfviewer.
If the renewcommand below the comment % define lead-in section is removed. The bookmarks work fine (but then I won't have the heading style I was looking for. I'd strongly prefer to keep the automatic section labelling/bookmarking if possible. Any ideas on how this can be achieved?
sectioncommand. ThepdfstringdefDisableCommandsin the linked question is not enough since that only acts on thesectiontitle argument instead of the output ofstartsection. The linked accepted answer fixes this by redefining\Sectionformatto upper case the section heading instead of usingstartsectionfor upper caseing the section heading. – Frank Wilson Jan 30 '21 at 18:23