
\includepdf[]{filename}
私は、問題なく動作するコマンド を使用した PDF ファイルを含めたいと思います 。基本的に、ドキュメント全体が PDF ファイルで構成されているため、章のタイトルを含めたいと思います。ただし、 のみを使用する\chapter{name}
と、PDF ファイルの前に章のタイトルのみを含む空のページが表示されます。タイトルは必ずしも PDF の上にある必要はありません。PDF にタイトル名を含めることができるためですが、章のタイトルを目次に表示したいだけです。
答え1
- オプションを使用し
addtotoc
て TOC のエントリを作成します。 - するない、、 ... コマンド
\includepdf
でフィードを試みます。これは失敗します。\chapter
\section
- オプションを使用して
picturecommand*
、含まれている PDF の最初のページに何かを書きます。( 、... を使用すると、少なくともセクション タイトルのように見える場合があります\thesection
)
次に例を示します。
\documentclass[a4paper]{article}
\usepackage{pdfpages}
\usepackage{hyperref}
\newcommand\mytitle{}
\newcommand\doctitle[1]{\def\mytitle{#1}}
\begin{document}
\tableofcontents
\doctitle{Title AAA}
\includepdf[
pages=-,
addtotoc={1, section, 1, \mytitle, sec:file-1},
picturecommand*={\put(100,700){\LARGE\thesection\ \mytitle}}
]{file-1.pdf}
\doctitle{Title BBB}
\includepdf[
pages=-,
addtotoc={1, section, 1, \mytitle, sec:file-2},
picturecommand*={\put(100,700){\LARGE\thesection\ \mytitle}}
]{file-2.pdf}
\end{document}
答え2
これにより、古いフッターとヘッダーが削除され、新しいものに置き換えられます。共通のページ レイアウトが想定されます。
\documentclass{book}
\usepackage{pdfpages}
\makeatletter
\newcommand{\mychapter}[1]% #1 = short title (TOC and header only}
{\thispagestyle{plain}%
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
\addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#1}%
\else
\addcontentsline{toc}{chapter}{#1}%
\fi
\else
\addcontentsline{toc}{chapter}{#1}%
\fi
\chaptermark{#1}%
\addtocontents{lof}{\protect\addvspace{10\p@}}%
\addtocontents{lot}{\protect\addvspace{10\p@}}%
}
\makeatother
\edef\toptrim{\the\dimexpr 1in+\topmargin+\headheight+\headsep}
\edef\bottomtrim{\the\dimexpr \paperheight-\toptrim-\textheight}
\begin{document}
\tableofcontents
\cleardoublepage% [openright] doesn't show headers
\includepdf[pages={1},pagecommand={\mychapter{Title}},clip=true,trim=0 {\bottomtrim} 0 {\toptrim}]{test6}% one page only!
\includepdf[pages={2},pagecommand={},clip=true,trim=0 {\bottomtrim} 0 {\toptrim}]{test6}
\end{document}
test6は以下を使用して作成されました
\documentclass{book}
\usepackage{lipsum}
\begin{document}
\chapter{Title}
\lipsum[1-4]
\end{document}