
我透過以下方式將書籤新增至專案中的所有部分:
\section{Introduction}
\hypertarget{intro}{}
Some text.
我稍後會在 URL 連結中使用這些書籤https://example.com/my-document.pdf#intro
。
每次我創建引用某個部分的 URL 時,我都需要返回到我的 LaTeX 專案並查找書籤名稱稱,因為我有太多書籤名。我想要一個我所有書籤的清單(最好與它們標記的部分名稱並列)。
我知道可以使用以下命令生成所有書籤的列表pdf訊息在命令列上。然而,除了我需要的書籤之外,我還獲得了 LaTeX 添加的各種其他書籤,這些書籤與我無關:
1 [ XYZ 57 785 null ] "Doc-Start"
1 [ XYZ 56 823 null ] "page.1"
2 [ XYZ 57 711 null ] "section.1"
3 [ XYZ 57 751 null ] "intro"
5 [ XYZ 57 666 null ] "lstlisting.-1"
5 [ XYZ 104 668 null ] "lstnumber.-1.1"
6 [ XYZ 57 785 null ] "subsection.1.1"
那麼是否可以產生我創建的書籤清單\hypertarget
?我會對任何一個感到滿意:命令列解決方案或 LaTeX 巨集。
答案1
我嘗試修補自己並想出了一些骯髒的但工作解決方案感謝這個線程和這個線程。我希望我能想出一個更好的方案,但需要更多的經驗。仍然希望有人能提供更優雅的解決方案。
我的骯髒的解決方案:
\documentclass{article}
% Corrects issues with compatibility of XeLaTeX
% and hyperref to create bookmarks
\special{dvipdfmx:config C 0x0010}
\usepackage{hyperref}
\usepackage{newfloat}% for listof
\usepackage{comment}
%\begin{comment}
% temp code for list of bookmarks
\DeclareFloatingEnvironment[fileext=bkmrk]{bookmark}
\makeatletter
\newcommand*{\currentname}{\@currentlabelname}
\renewcommand*{\hypertarget}[2]{
\addcontentsline{bkmrk}{bookmark}{\currentname \qquad | \qquad #1}%
}
\makeatother
\AtBeginDocument{\listofbookmarks}
% end of temp code
%\end{comment}
\begin{document}
\newpage
\section{First Section}
\hypertarget{first}{}
\newpage
\section{Second Section}
\hypertarget{second}{}
\newpage
\section{Third Section}
\hypertarget{third}{}
\end{document}
它給了我這個:
在編譯最終 PDF 之前,我會執行以下操作:
- 取消註解書籤清單的程式碼
- 編譯PDF以產生書籤列表
- 將書籤複製到Excel中(此步驟需要大量文字編輯)
- 註解掉書籤清單的程式碼
然後我編譯 PDF 以供發布。