3

This question is a follow up of my previous question Hide section in table of contents but show it in pdfbookmark.

When I compile my code in XeLaTeX it comes out perfectly in TeXworks. With only one set of pdfbookmarks. See the right hand part of the picture below.

When I open that file in Preview or Adobe Reader, there is suddenly an extra set of bookmarks which is from the \section{} commands in my code. See the left hand side of the picture.

Preview and TeXworks side by side

When I remove the \section{} commands and play around with \setcounter{section}{0} my \firsttitlemarks\thesubsection header gets messed up. The 1:1-2:4 turns into 1:2-2:4 etc.

Any ideas on how to remove these extra bookmarks without breaking my header's marks?

\documentclass[paper=a5,pagesize=pdftex]{scrbook}
\usepackage[top=2cm,bottom=1.5cm, left=1.5cm, right=1.5cm]{geometry}
\usepackage[pagestyles]{titlesec}
\usepackage{lettrine}
\usepackage{xltxtra}
\usepackage{tocloft}
\usepackage{etoolbox}
\usepackage[toc]{multitoc}
\usepackage{setspace}

\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thesubsection}{\arabic{subsection}}

\newcommand\Text{And every plant of the field before it was in the earth, and every herb of the field before it grew: for the LORD God had not caused it to rain upon the earth, and there was not a man to till the ground.}

\setcounter{tocdepth}{0}

\defaultfontfeatures{Mapping=tex-text}
\setmainfont{Cardo}

% definition of the page style with required headers
\newpagestyle{Biblestyle}{
  \setheadrule{.02pt}
  \sethead[\thepage][\chaptertitle][\firsttitlemarks\thesection:\ifthesubsection{\firsttitlemarks\thesubsection}{1}---\bottitlemarks\thesection:\bottitlemarks\thesubsection]{\firsttitlemarks\thesection:\ifthesubsection{\firsttitlemarks\thesubsection}{1}---\bottitlemarks\thesection:\bottitlemarks\thesubsection}{\chaptertitle}{\thepage}
}

% sets the marks to be used (section and subsection)
\setmarks{section}{subsection}

% sections and subsections formatting
\titleformat{\section}{}{\lettrine{\thesection}}{0em}{}[\vskip-1\baselineskip]
\titleformat{\subsection}[runin]
{\small\bfseries}{\thesubsection}{1em}{}
\titlespacing{\section}{1em}{-1pt}{0pt}
\titlespacing{\subsection}{0pt}{0pt}{1em}

\setlength{\parindent}{0pt}

\newlength\NumLen
\newlength\LinLen
% indents one line of text. Indentation= width of section number + 1em
\newcommand\IndOne{%
  \settowidth\NumLen{\thesection}
  \addtolength\NumLen{1em}
  \setlength\LinLen{\dimexpr\textwidth-\NumLen}%\the\NumLen\the\LinLen
  \parshape 2 \NumLen \LinLen 0pt \textwidth}
% indents two lines of text. Indentation= width of section number + 1em
\newcommand\IndTwo{%
  \settowidth\NumLen{\thesection}
  \addtolength\NumLen{1em}
  \setlength\LinLen{\dimexpr\textwidth-\NumLen}%\the\NumLen\the\LinLen
  \parshape 3 \NumLen \LinLen \NumLen \LinLen 0pt \textwidth}

\usepackage[none]{hyphenat}
\sloppy
\usepackage{hyperref}
\hypersetup{
    bookmarksdepth=1,
    unicode=true,
    colorlinks=true,
    citecolor={black},
    linkcolor={black},
    urlcolor={black},
    pdffitwindow=true,
}

\addtokomafont{disposition}{\rmfamily\mdseries}

\renewcommand{\contentsname}{Table of Contents}
\renewcommand*\cfttoctitlefont{\huge\hfill}
\renewcommand*\cftaftertoctitle{\hfill}
\renewcommand{\cftchapdotsep}{\cftdot}
\renewcommand{\cftpartfont}{\hfill\bfseries}
\renewcommand{\cftchapfont}{\mdseries}
\renewcommand{\cftpartpagefont}{\hfill\footnotesize\bfseries}
\renewcommand{\cftchappagefont}{\mdseries}
\setlength{\cftbeforetoctitleskip}{-4em}
\setlength{\cftaftertoctitleskip}{3em}
\setlength{\cftbeforechapskip}{.3em}
\setlength{\cftbeforepartskip}{.3em}
\setlength{\columnsep}{2pc}
\setlength\columnseprule{.4pt}

\begin{document}
\frontmatter
    % Titlepage
        \pdfbookmark[0]{Titlepage}{title}
    \title{}
    \subject{
        \vspace{3cm}
        \textbf{\Large{THE}\\\vspace{-0.3cm}
        \Huge{HOLY}\\\vspace{0.05cm}
        \Huge{BIBLE}}\\\vspace{0.5cm}
    \author{} \date{}
    }
    \maketitle

\cleardoublepage
\pdfbookmark[0]{\contentsname}{tofcontents}
\begin{spacing}{0.01}
\tableofcontents
\end{spacing}
\cleardoublepage

\mainmatter
\pagestyle{Biblestyle}
\newlength{\myIndent}
\begin{center}
\phantomsection
\addcontentsline{toc}{part}{Old Testament}\noindent
\phantomsection
\addcontentsline{toc}{chapter}{Genesis}\noindent
THE FIRST BOOK OF MOSES, CALLED\\
\vspace{0.15cm}\textbf{\Huge{GENESIS}}\vspace{0.00cm}\\

\end{center}
\renewcommand{\chaptertitle}{Genesis}
\setcounter{section}{0}
\pdfbookmark[1]{1}{01O1}
\section{}\settowidth{\myIndent}
{\IndOne \Text}
\ifdimless{\the\myIndent}
{.99\textwidth}
{\IndOne \Text \stepcounter{subsection} \subsection{} \IndOne \Text}
{\IndTwo \Text \stepcounter{subsection} \subsection{} \Text}
\subsection{} \Text
\subsection{} \Text
\subsection{} \Text
\subsection{} \Text
\subsection{} \Text

\pdfbookmark[1]{2}{01O2}
\section{}\settowidth{\myIndent}
{\IndOne \Text}
\ifdimless{\the\myIndent}
{.99\textwidth}
{\IndOne \Text \stepcounter{subsection} \subsection{} \IndOne \Text}
{\IndTwo \Text \stepcounter{subsection} \subsection{} \Text}
\subsection{} \Text
\subsection{} \Text
\subsection{} \Text
\subsection{} \Text
\subsection{} \Text

\begin{center}
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{Exodus}\noindent
THE SECOND BOOK OF MOSES, CALLED\\
\vspace{0.15cm}\textbf{\Huge{EXODUS}}\vspace{0.00cm}\\
\end{center}
\renewcommand{\chaptertitle}{Exodus}
\setcounter{section}{0}
\pdfbookmark[1]{1}{02O1}
\section{}\settowidth{\myIndent}
{\IndOne \Text}
\ifdimless{\the\myIndent}
{.99\textwidth}
{\IndOne \Text \stepcounter{subsection} \subsection{} \IndOne \Text}
{\IndTwo \Text \stepcounter{subsection} \subsection{} \Text}
\subsection{} \Text
\subsection{} \Text
\subsection{} \Text
\subsection{} \Text
\subsection{} \Text
\end{document}
1
  • 1
    Please try to reduce your code to a minimal working example, emphasis on minimal.
    – frabjous
    Sep 1, 2011 at 13:54

2 Answers 2

4

Use the following code after hyperref:

\makeatletter
\def\toclevel@section{2} 
\makeatother

Normally \toclevel@section has the number 1. The number of the

\tocleve@<structure element>

is used by bookmarksdepth. So the level for every section is changed in the bookmark. Now section is on the same level as subsection.

1
  • Thanks. I've found another solution which I'll post tomorrow as the site won't allow me to answer my own question right now. But your solution is a bit cleaner to implement and seems to work.
    – McGafter
    Sep 1, 2011 at 14:09
1

Adding

\addtocounter{chapter}{1}

to and removing the custom bookmark

\pdfbookmark[1]{1}{02O1}

from every chapter or Bible book name after the first solved it.

\addtocounter{chapter}{1}
\renewcommand{\chaptertitle}{Exodus}
\setcounter{section}{0}
%\pdfbookmark[1]{1}{02O1}

You must log in to answer this question.

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