我有两个文件 -> a.tex 和 b.tex,如何在 a.pdf 后插入 b.pdf?

我有两个文件 -> a.tex 和 b.tex,如何在 a.pdf 后插入 b.pdf?
%********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}

本书及其子书的目录

相关内容