メインの LaTeX ドキュメントと、以前 に含めていた外部 PDF がありますpdfpages
(見た目も素晴らしいです!)。しかし、外部 内のセクションとサブセクションを参照するための TOC エントリを挿入したいと考えています.pdf
。次のようにしています:
\newcounter{page-backup}
\setcounter{page-backup}{\value{page}}
% begin to fake-numerate
\setcounter{page}{106}
% increment chapter counter and reset section and subsection
\addtocounter{chapter}{1}
\setcounter{section}{1}
\setcounter{subsection}{1}
% add chapter
\addcontentsline{toc}{chapter}{\numberline{\thechapter} CHAPTER}
% add section
\addcontentsline{toc}{section}{\numberline{\thesection} Section}
% add more...
\setcounter{page}{125}
\addcontentsline{toc}{section}{\numberline{\thesection} Section}
% add some stuff
\addtocounter{tottables}{42}
\addtocounter{totfigures}{3}
% restore main page numeration
\setcounter{page}{\value{page-backup}}
しかし、TOC では、すべてのエントリが 106 ページ (偽の列挙の最初のページ) に表示されます。挿入された TOC エントリのページ番号を手動で変更するにはどうすればよいでしょうか? 方法はあることは知っていますが、\addtocontents
非常に手作業です。すべてのエントリを手動でフォーマットする必要があります...
答え1
これは質問に対する部分的な答えに過ぎません
同様の状況で、私は次のようにして、個々のセクションを分離して含めました。
...
\tableofcontents
... initial part (with no tricks)
\addcontentsline{toc}{section}{...ext sec title 1}
\includepdf[pages={1-20}]{external.pdf}
\addcontentsline{toc}{section}{...ext sec title 2}
\includepdf[pages={21-30}]{external.pdf}
... for all the external pdf units
...continuation (no tricks)
この方法では、LaTeX が作業を実行します (偽のページングは必要ありません)。
外部 PDF に番号を付けないようにし、includepdf 命令に次のコードを追加します。
\includepdf[pages=...,pagecommand={\thispagestyle{fancy}}]{...}
(適応が必要) 外部 PDF にページ番号を追加します。
(提案: 新しいコマンドを作成してください\externalPDFunit{type}{pages}{title}{file}
)