Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I use combine class to bundle some LaTeX files together.

The main file is essentially like this:

\documentclass{combine}
\begin{document}

\begin{papers}
\import{file1}
\import{file2}
\end{papers}

\end{document}

A typical included file takes less than a page of text, but in the end every file is on a single page, as combine seems to be putting a page break after every file. How would I avoid these page breaks?

share|improve this question
add comment

5 Answers

p.9 of the combine package documentation explicitly states

In order to ensure that all material in an imported document is typeset, there is an inbuilt \clearpage command within the imported document's \end{document}. Thus, any material after an \import command will start on a new page.

share|improve this answer
add comment

\import, like the standard latex \include requires each imported document to start on a new page. But if your documents are so small, you probably can just use \input instead and input the documents (which would need then just to be the document body without the preamble). If you need to process the documents individually as well as together there are various things you can do, hard to say without seeing an example but for instance if each small document was doc1.tex, doc2.tex etx and doc.tex` looked like

\documentclass{article}
\usepackage{a,b,c}
\begin{document}
\input{doc1-body}
\end{document}

where doc1-body,tex is

stuff...

Then your combined document can be

\documentclass{article}
\usepackage{a,b,c}
\begin{document}
\input{doc1-body}
\input{doc2-body}
\input{doc3-body}
\input{doc4-body}
\end{document}

Or possibly with section headings in between each document, or whatever you need....

share|improve this answer
add comment

The following "hack" seems to work ... except that it apparently adds the class name of the imported document at the beginning.

\documentclass{combine}

\makeatletter
\renewcommand{\c@laenddocument}{% 
\@enddocumenthook \@checkend{document}% 
%\clearpage
\begingroup \if@filesw
\immediate\closeout\@mainaux \immediate\closeout\@partaux \let\@setckpt\@gobbletwo \let\@newl@bel\@testdef \@tempswafalse
\makeatletter \input\c@lmainauxfile %% change here \fi
\c@lenddoca
\@refundefined \endgroup \deadcycles\z@\@@end}

\renewcommand{\c@lbenddocument}{% 
\@enddocumenthook 
\@checkend{document}% 
%\clearpage
\begingroup \if@filesw
\immediate\closeout\@partaux
\let\@setckpt\@gobbletwo 
\let\@newl@bel\@testdef 
\@tempswafalse \makeatletter \input\c@lauxfile
\fi \c@lenddoca
\endgroup \deadcycles\z@
\c@lclosetocs}
\makeatother

\begin{document}

\begin{papers}
\import{test1}\newline
\import{test2}
\end{papers}

\end{document}
share|improve this answer
add comment

If the files you are wanting to put together in the same document all have a common preamble then you can use docmute to accomplish this. Then the include and input commands behave as expected, with only the common preamble used. If the individual documents are compiled they work as expected. When combined then only the single common preamble is used. (Formally the included (for page break)/inputted (included without page break) files preambles must be sublists of the main document preamble. I mean a list not a set as the order of the \usepackage's can be important.)

I use this for syllabus preparation were I have about 30 standalone documents which I combine into the syllabai for 4-6 courses. This allows me to edit and modify individual documents quickly both before the syllabus is published, but during the semester as changes have to be made.

share|improve this answer
add comment

Ended up using docmute as suggested in one of the answers. However, I still needed the following hack to avoid page breaks.

\let\clearpage\relax
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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