5

I want open only the first button of tree

enter image description here

to create the levels i used this

\pdfbookmark[0]{Start}{start}

To close the others levels i use this

\hypersetup{
  bookmarksopen=false
}

but i get this result:

enter image description here

How open just the first button?

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{imakeidx}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage[pdftex, bookmarksnumbered,  pagebackref, colorlinks=true, citecolor=Blue, linkcolor=DarkBlue!30!Black, urlcolor=Black,bookmarksopen]{hyperref}
\makeindex[columns=3, title=Alphabetical Index, intoc]

\begin{document}

\tableofcontents

\cleardoublepage
\pdfbookmark{Dedicatory}{dedic}
\chapter*{Dedicatory}

   to all my family

\cleardoublepage
\pdfbookmark{Abstract}{abstr}

\chapter*{Abstract}

   hello world


\chapter{chapter}
\section{Introduction}
In this example several keywords\index{keywords} will be
used which are important and deserve to appear in the
Index\index{Index}.
 \subsection{subsection}
Terms like generate\index{generate} and some\index{others}
will also show up. Terms in the index can also be
nested \index{Index!nested}

\clearpage

\section{Second section}
This second section\index{section} may include some special
word, and expand the ones already used\index{keywords!used}.

\printindex
\end{document}
  • Do you have more content at the same level as Start? Can you also just create a minimal document that compiles to your current output? Keep it minimal. – Werner Feb 26 at 16:47
  • Have you seen this: tex.stackexchange.com/a/380706/29873 – DG' Feb 26 at 19:54
  • @Werner i edited my question see please – x-rw Feb 26 at 23:22
4
+50

As I understand your request it was to have only the first level bookmarks open. Using your MWE, you can add bookmarksopenlevel=0 as an option to hyperref. (If you want deeper levels open, you can change 0 to 1 or some other value.)

With this modification of your current MWE:

\usepackage[pdftex, bookmarksnumbered,  pagebackref, colorlinks=true, citecolor=Blue, linkcolor=DarkBlue!30!Black, urlcolor=Black,bookmarksopen,bookmarksopenlevel=0]{hyperref}
%

I get the display shown: enter image description here

If I increase the depth by to 1, as follows

\usepackage[pdftex, bookmarksnumbered,  pagebackref, colorlinks=true, citecolor=Blue, linkcolor=DarkBlue!30!Black, urlcolor=Black,bookmarksopen,bookmarksopenlevel=1]{hyperref}
%

then I get:

enter image description here

  • I get this error: ! LaTeX Error: Option clash for package hyperref. See the LaTeX manual or LaTeX Companion for exp – x-rw Mar 1 at 15:47
  • I don't get this option clash with your MWE. Are you running the same code as your MWE above, plus only the bookmarkopenlevel=0 option as shown? If you have other packages/options that you have added, they may cause this. – John Mar 1 at 16:31
  • 1
    Confirmed that this DOES address the difference on opening first time in SumatraPDF (which remembers last bookmark status thus will change on next run to whatever you last expanded) thus after user interference bookmarks may in some viewers not behave as author expected, however that is to be expected as normal. – user170109 Mar 3 at 18:10

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.