
次のようにして、プロジェクト内のすべてのセクションにブックマークを追加します。
\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 をコンパイルします。