1

Context

I currently have a single document with the class srcbook. I have partitioned it into various subfiles for easier handling. This document is fine by itself.... however, I want to include the entire document (title page, TOC, etc) in another document as a self contained section.

If that doesn't make sense, consider how LaTeX has various commands for structuring your document: chapter, section, subsection, subsubsection, etc, etc. That document then has a table of contents based on that structure. However, it is sometimes beneficial to have / remind people what is in the current structure. Along those lines the package minitoc allows one to have a TOC for their chapters.

Using subfiles one can build up their document from various small documents containing these structured elements.

What I would like to do is essentially equivalent to making book its own structure element. Thus one would end up with a meta document containing several books, each with their own title page, TOC, chapters, etc.

Thus one would have a title page for the document made of books as well.

One might ask, "why not simple take each element and demote it in the structure hierarchy? e.g. book --> chapter, chapter --> section, etc. Well, then I would need a TOC for sections, sections would need a chapter-esque header formatting, etc. Whereas the problem I am asking, is simply leaving the current structure in take, but allowing them to be pooled together as if there is a higher structure? e.g.

-meta-document

---book 1

-----chapter 1

-------section 1

---------subsection 1

-------section 2

---------subsection 1

---------subsection 2

---book 2

-----chapter 1

-------section 1

---------subsection 1

-------section 2

---------subsection 1

---------subsection 2


My original phrasing of this question was as follows:

This is, what I hope to be, a fairly straight forward and simple question. When using subfiles can one pool multiple documents with a book class? Or, at the very least, separate title pages and accordingly separate TOC?

  • You can also do that simply by using \include and \input. The only thing subfiles adds is the possibility to also LaTeX the individual parts separately. If you don't need that, I think just using \input and \include is easier. – Piet van Oostrum Dec 6 '16 at 13:59
  • @PietvanOostrum I am unfamiliar with those commands... – SumNeuron Dec 6 '16 at 14:13
  • Please read some elementary LaTeX documentation then. But to give a short answer: \input{filename} adds the contents of filename as if it was typed there in the document. \include{filename} does the same, but also starts a new page before the included text. It does a bit more, but basically that's it. – Piet van Oostrum Dec 6 '16 at 14:29
  • @PietvanOostrum so how would that allow me to have two book class documents or at least two titles and corresponding TOCs? – SumNeuron Dec 6 '16 at 16:07
  • OK, I think I might have misunderstood your question. Can you formulate your question in such a way that it is understandable? Maybe with an example? – Piet van Oostrum Dec 6 '16 at 16:16
2

You could try the following with the combine package:

Get a copy a combine.cls in your working directory (where your combined book document will be), and make the following change in the copy:

After the line:

\DeclareOption{book}{\def\c@lclass{book}}

insert

\DeclareOption{scrbook}{\def\c@lclass{scrbook}}

Then use a document like this to combine the books:

\documentclass[11pt,scrbook,titlepage]{combine}

\usepackage{xxxxx}% <==== put all the \usepackages you need here.
                  % Add other definitions from the preambles
                  % also here (the book preambles will not be used).

\author{I Myself}
\title{Combined Book}
\begin{document}
\maketitle
\newpage
\begin{papers}
  \import{book1}
  \import{book2}
\end{papers}
\end{document}
  • would this render a title page for the meta document, with a TOC just for the books, and then also provide the separate title page, TOCs, etc for the books? – SumNeuron Dec 7 '16 at 10:47
  • Yes, I get a title page for the combined document, then title pages and TOCs for each of the books. By default these are not a separate page each (which means you get the title, the TOC and the first chapter on the same page(s) for each book, but this can be cured by putting extra \newpage commands in the original books. The combine class is not designed to work with the koma classes, so scrbook may complain of some changes that combine makes. Whether these destroy your book's formatting I don't know. I would say, just try it. – Piet van Oostrum Dec 7 '16 at 10:56
  • What if you do not have a local copy of combine. Can those definitions go before document class? – SumNeuron Dec 7 '16 at 15:14
  • No, that is impossible. But why can you not make a copy of combine.cls? – Piet van Oostrum Dec 7 '16 at 16:10
  • It is an online editor.... – SumNeuron Dec 7 '16 at 16:12
2

Only as an addendum to Piet's answer:

Instead of patching class combine you can use KOMA-Script package scrlfile to replace loading class book by loading class scrbook.

MWE for this suggestion:

\begin{filecontents*}{book1.tex}
\documentclass{scrbook}

\usepackage{mwe}

\title{First Book}

\begin{document}
\maketitle
\blinddocument
\end{document}
\end{filecontents*}
\begin{filecontents*}{book2.tex}
\documentclass{scrbook}

\usepackage{mwe}

\title{Second Book}
\maketitle

\begin{document}
\blinddocument
\end{document}
\end{filecontents*}

\RequirePackage{scrlfile}
\ReplaceClass{book}{scrbook}% load scrbook instead of book
\documentclass[11pt,book,titlepage]{combine}

\usepackage{mwe}% <==== put all the \usepackages you need here.
                  % Add other definitions from the preambles
                  % also here (the book preambles will not be used).

\author{I Myself}
\title{Combined Book}
\begin{document}
\maketitle
\cleardoubleoddpage
\begin{papers}
  \import{book1}
  \import{book2}
\end{papers}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.