我想添加用于浏览 pdf 文档的大纲。我正在使用 pdfpages 包的 includepdf 插入 pdf 页面。我该怎么做?
\documentclass[]{article}
\usepackage[]{geometry}
\usepackage[]{pdfpages}
\begin{document}
% add an outline here (LEVEL1, NAME1)
\newgeometry{margin=0}
\includepdfmerge[fitpaper]{test.pdf, 1}
\newgeometry{margin=0}
\includepdfmerge[fitpaper]{test.pdf, 2}
% add an outline here (LEVEL2, NAME2)
\newgeometry{margin=0}
\includepdfmerge[fitpaper]{test.pdf, 3}
\newgeometry{margin=0}
\includepdfmerge[fitpaper]{test.pdf, 4}
% add an outline here (LEVEL3, NAME3)
\newgeometry{margin=0}
\includepdfmerge[fitpaper]{test.pdf, 5}
\newgeometry{margin=0}
\includepdfmerge[fitpaper]{test.pdf, 6}
\begin{document}
答案1
只需使用选项创建标签和章节条目。然后包含addtotoc
,这些章节条目将自动显示为大纲。\includepdf
hyperref
\documentclass{article}
\usepackage{pdfpages}
\usepackage{hyperref}
\begin{document}
\includepdf[
pages=1-6, fitpaper,
addtotoc = {
1, section, 1, NAME1, sec:label1,
3, subsection, 2, NAME2, sec:label2,
5, subsubsection, 3, NAME3, sec:label3 }
]{test.pdf}
\end{document}
答案2
我得到了答案使用 LaTeX 制作 PDF 书签其中提到如何导入、导出和编辑 pdf 文件的书签?
使用bookmark
包并在文档中放入\bookmark[page=,level=]{title}
\documentclass[]{article}
\usepackage[]{geometry}
\usepackage[]{pdfpages}
\usepackage{bookmark}
\begin{document}
% add an outline here (LEVEL1, NAME1)
\newgeometry{margin=0}
\includepdfmerge[fitpaper]{test.pdf, 1}
\newgeometry{margin=0}
\includepdfmerge[fitpaper]{test.pdf, 2}
% add an outline here (LEVEL2, NAME2)
\newgeometry{margin=0}
\includepdfmerge[fitpaper]{test.pdf, 3}
\newgeometry{margin=0}
\includepdfmerge[fitpaper]{test.pdf, 4}
% add an outline here (LEVEL3, NAME3)
\newgeometry{margin=0}
\includepdfmerge[fitpaper]{test.pdf, 5}
\newgeometry{margin=0}
\includepdfmerge[fitpaper]{test.pdf, 6}
\bookmark[page=1,level=0]{NAME1}
\bookmark[page=3,level=1]{NAME2}
\bookmark[page=5,level=2]{NAME3}
\begin{document}