8

First of all sorry for my bad English. I am designing a book and I have problems with the bookmark when I compile the file.tex in file.pdf. The chapters appear twice. In my code I don't want to list the chapters, but I want them to appear in the tableofcontents so I had to use \addcontentsline{toc}{chapter}{chapter name} to add them to the index, but this causes re-add the chapters in the bookmark

Additionally I'm using the package bookmark to link the chapters in the page that I desire. What can I do to display the chapters in the tableofcontents and in the bookmark of file.pdf once?

This is my code:

\documentclass{book} 
...  
\usepackage{bookmark}

\begin{document}

\chapter*{Presentación}   % Presentation of the book
\bookmark[page=2,level=0]{Presentación}  

\tableofcontents

\chapter*{Aspectos téncicos} % From here they appear in the index 
\bookmark[page=4,level=0]{Aspectos téncicos}
\addcontentsline{toc}{chapter}{Aspectos téncicos}

\end{document}
  • 1
    I'm new to this, modify the code. Do not know if it still is too much? – lbautista May 13 '13 at 17:51
4

You don't need to append bookmark instructions for all chapters, nor \addcontentsline:

\documentclass[12pt,letterpaper,openright]{book} 
\usepackage[utf8]{inputenc} 
\usepackage[spanish,es-tabla]{babel}

\usepackage{bookmark}

\usepackage{titlesec} 
\usepackage{titletoc} 

\titleformat{\chapter}[display]{\Huge\bfseries}{\chaptertitlename\ \thechapter}{0pt}{}
\titleformat{\section}{\Large\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}{\large\bfseries}{\thesubsection}{1em}{}
\titleformat{\subsubsection}{\normalsize\bfseries}{\thesubsubsection}{1em}{}
\titlespacing*{\chapter}{0pt}{-60pt}{10pt}[-60pt]
\titlespacing*{\section}{0pt}{28pt plus 1pt minus 2pt}{14pt plus 2pt}
\titlespacing*{\subsection}{0pt}{14pt plus 1pt minus 2pt}{14pt plus 2pt}
\titlespacing*{\subsubsection}{0pt}{14pt plus 1pt minus 2pt}{14pt plus 2pt}

% Change \frontmatter and \mainmatter not to reset the numbering
\makeatletter
\renewcommand\frontmatter{%
  \cleardoublepage
  \@mainmatterfalse
  \pagestyle{empty}% no printed page numbers
}
\renewcommand\mainmatter{%
  \cleardoublepage
  \@mainmattertrue
  \pagestyle{headings}% change to suit
}
\makeatother

\begin{document}
\frontmatter

\bookmark[page=\thepage,level=0]{Portada} 
%\input{./portada.tex}   % Bookcover
{\Huge COVER}\clearpage %%%% <--- I don't have your file

%%% This doesn't go in the TOC, so a \bookmark is necessary   
\chapter*{Presentación}   % Presentation of the book
\bookmark[page=\thepage,level=0]{Presentación}  

\tableofcontents

\mainmatter

\chapter{Aspectos técnicos}   %First chapter from here I wish to appear in the tableofcontents

\end{document}

I modified the \frontmatter and \mainmatter commands in order not to reset the numbering. Using \pagenumbering{gobble} doesn't work when hyperref is involved, but it's sufficient to kill the normal page style and reset it at \mainmatter.

(I have also omitted the inessential packages, fill them as you prefer.)

  • Thanks @egreg . When compiling, does not show twice the chapters in the bookmark, but I put chapter* because I don't wish to show me the numbers and the word "chapter" in the chapters. How do I get these conditions? – lbautista May 13 '13 at 20:11
  • @lbautista I don't see why you don't want the chapter number; however you can get rid of it by simply acting on the \titleformat and \titlespacing commands relative to \chapter. For instance, \titleformat{\chapter}[display]{\Huge\bfseries}{}{0pt}{} – egreg May 13 '13 at 20:19
  • I understand, but I wanted to avoid having to modify the \titleformat and \titlespacing because I'm new at this; why choose to put chapter*. I will try and tell him. Thanks – lbautista May 13 '13 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.