
잘 작동하는 명령을 사용한 PDF 파일을 포함하고 싶습니다
\includepdf[]{filename}
. 기본적으로 내 전체 문서는 PDF 파일로 구성되어 있으므로 이제 장 제목을 포함하고 싶습니다. 그러나 를 사용하면 \chapter{name}
pdf 파일 앞에 장 제목만 있는 빈 페이지가 제공됩니다. PDF에 제목 이름을 포함할 수 있으므로 제목이 반드시 PDF 위에 올 필요는 없지만 목차에는 장 제목만 표시되기를 원합니다.
답변1
- 옵션을 사용하여
addtotoc
목차 항목을 만듭니다. - 하다~ 아니다, , ... 명령
\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}