![我有两个文件 -> a.tex 和 b.tex,如何在 a.pdf 后插入 b.pdf?](https://linux22.com/image/288839/%E6%88%91%E6%9C%89%E4%B8%A4%E4%B8%AA%E6%96%87%E4%BB%B6%20-%3E%20a.tex%20%E5%92%8C%20b.tex%EF%BC%8C%E5%A6%82%E4%BD%95%E5%9C%A8%20a.pdf%20%E5%90%8E%E6%8F%92%E5%85%A5%20b.pdf%EF%BC%9F.png)
%********a.tex
\documentclass{book}
\usepackage[final]{pdfpages}
\begin{document}
Hello
\includepdf[pages=-]{b.pdf}
\end{document}
现在b.tex
%%%%%%%%%%
%********b.tex
\documentclass{book}
\begin{document}
World!
\end{document}
%%%%%%%%%%%
答案1
我从来没有使用过这种语法,\includepdf[<option>]{file.pdf}
所以我可能忽略了它的优点。
我指定以下内容是因为您在标题中提到您拥有文件 a.pdf 和 b.pdf 的 tex 源。
只需编辑@Christian 先前回答中的模板,我建议您使用以下命令\include{}
:
\begin{document}
\part{This is the 1st book}
\chapter{The first chapter of the first part}
\include{a}%% INCLUDE filename
\part{This is the 2nd book}
\chapter{The first chapter of the 2nd part}
\include{b1}%% INCLUDE filename
\chapter{The second chapter of the 2nd part}
\include{b2}%% INCLUDE filename
\end{document}
或命令\input{}
:
\begin{document}
\tableofcontents
\part{This is the 1st book}
\chapter{The first chapter of the first part}
\input{a.tex}%% INPUT filename.tex
\part{This is the 2nd book}
\chapter{The first chapter of the 2nd part}
\input{b1.tex}%% INPUT filename.tex
\chapter{The second chapter of the 2nd part}
\input{b2.tex}%% INPUT filename.tex
\end{document}
完成任务。input
和之间的区别include
这里。
答案2
也许,这对 OP 来说是一个‘启动’...
随意更改标题、风格……
\documentclass{book}
\renewcommand{\partname}{Book}
% If chapters should be reset when a new part ('book') starts then
% use this code
\makeatletter
\@addtoreset{chapter}{part}
\makeatother
\begin{document}
\tableofcontents
\part{This is the 1st book}
\chapter{The first chapter of the first part}
\part{This is the 2nd book}
\chapter{The first chapter of the 2nd part}
\chapter{The second chapter of the 2nd part}
\part{Book 3}
\chapter{The first chapter of the 3rd part}
\chapter{The second chapter of the 3rd part}
\part{Book 4}
\end{document}