如何保持某些书签展开/打开,而某些书签保持关闭?

如何保持某些书签展开/打开,而某些书签保持关闭?

(打开pdflatex)我习惯\usepackage[open,openlevel=1]{bookmark}默认将书签保持展开状态。但我需要默认将一些书签保持关闭状态(即收缩状态)。我手动添加书签,如下所示:

\documentclass[pdftex]{book}
\usepackage[a4paper,landscape,margin=3cm]{geometry}
\usepackage[open,openlevel=1]{bookmark}

\begin{document}
This is Part 1
\addcontentsline{toc}{part}{Part 1}\\
This is Chapter 1 of Part 1
\addcontentsline{toc}{chapter}{Chapter 1}
This is Chapter 2 of Part 1
\addcontentsline{toc}{chapter}{Chapter 2}
\clearpage
This is Part 2
\addcontentsline{toc}{part}{Part 2}\\
This is Chapter 1 of Part 2
\addcontentsline{toc}{chapter}{Chapter 1}
\clearpage
This is Chapter 2 of Part 2
\addcontentsline{toc}{chapter}{Chapter 2}
\clearpage
This is Part 3
\addcontentsline{toc}{part}{Part 3}\\
This is Chapter 1 of Part 3
\addcontentsline{toc}{chapter}{Chapter 1}
\clearpage
This is Chapter 2 of Part 3
\addcontentsline{toc}{chapter}{Chapter 2}
\clearpage
\end{document}

现在我想默认保留Part 2并扩展,同时默认收缩。Part 3Part 1

我搜索过但没有找到任何建议。

答案1

事实上,在某种程度上,可以保持书签关闭开幕式文档,但在用户点击相关级别或在 PDF 查看器应用程序中重新加载已打开的文档后,当然不再如此。

\bookmarksetup{open=false}在顶层(即部分)发出的书签将保持关闭,直到\bookmarksetup{open=true, openlevel=X}发生其他情况。

-1通常用于部分-级别、0等等chapters

以下代码默认隐藏第 1 部分和第 4 部分的书签以及第 2 部分的章节,而打开第 3 部分的章节。

它至少可以与 一起使用okular,但仅限于打开文档时——简单的重新加载不会恢复到原始设置。

但是它不能与 一起使用evince。我手头没有其他 PDF 查看器可供测试。

\documentclass[pdftex]{book}
\usepackage[a4paper,landscape,margin=3cm]{geometry}
%\usepackage[bookmarksopen,bookmarksopenlevel=5]{hyperref}
\usepackage[open,openlevel=1]{bookmark}

\begin{document}
This is Part 1
\bookmarksetupnext{open=false}
\addcontentsline{toc}{part}{Part 1}
This is Chapter 1 of Part 1
\addcontentsline{toc}{chapter}{Chapter 1}
This is Chapter 2 of Part 1
\addcontentsline{toc}{chapter}{Chapter 2}
\clearpage
\bookmarksetup{open=true,openlevel=0}% Only open down to chapter
This is Part 2
\addcontentsline{toc}{part}{Part 2}
This is Chapter 1 of Part 2
\addcontentsline{toc}{chapter}{Chapter 1}
And a section...
\addcontentsline{toc}{section}{Section 1 of chapter 1 of part 2}
\clearpage
This is Chapter 2 of Part 2
\addcontentsline{toc}{chapter}{Chapter 2}
\clearpage

This is Part 3
\bookmarksetup{open=true, openlevel=1}% Open down to section level (i.e. 1)
\addcontentsline{toc}{part}{Part 3}
This is Chapter 1 of Part 3
\addcontentsline{toc}{chapter}{Chapter 1}
\clearpage
This is Chapter 2 of Part 3
\addcontentsline{toc}{chapter}{Chapter 2}
And another section
\addcontentsline{toc}{section}{Section 1 of chapter 2 of part 3}
\clearpage
% Hide again in bookmarks
\bookmarksetup{open=false}
This is Part 4
\addcontentsline{toc}{part}{Part 4}
This is Chapter 1 of Part 4
\addcontentsline{toc}{chapter}{Chapter 1}
\clearpage
This is Chapter 2 of Part 4
\addcontentsline{toc}{chapter}{Chapter 2}
\clearpage

\end{document}

书签结果

相关内容