# Tag Info

544

\input{filename} imports the commands from filename into the target file; it's equivalent to typing all the commands from filename right into the current file where the \input line is \include{filename} essentially does a \clearpage before and after \input{filename}, together with some magic to switch to another .aux file, and omit the inclusion at all if ...

187

Short answer: \input is a more lower level macro which simply inputs the content of the given file like it was copy&pasted there manually. \include handles the file content as a logical unit of its own (like e.g. a chapter) and enables you to only include specific files using \includeonly{filename,filename2,...} to save times. Long answer: The \...

66

\input effectively replaces the command with the contents of the input file. \input's can be nested. So, you can write: \documentclass{article} \begin{document} AAA \input{b} AAA \end{document} where b.tex is: BBB \input{c} BBB and c.tex is: CCC to get output like: AAA BBB CCC BBB AAA include triggers a newpage both before and after the ...

49

You can use the standalone, docmute or subfiles package to make LaTeX ignore the second preamble. Simply load the standalone package in the main file and \input or \include the document. This is a good way if the to-be-included documents just holds a picture which should also be compiled standalone. In this case having main files for every picture file ...

40

From the LaTeX Wikibook : When working on big documents, you might want to split the input file into several parts. LaTeX has three commands to insert a file into another when building the document. The simplest is the \input command: \input{filename} \input inserts the contents of another file, named filename.tex; note that the ....

36

I'm fuzzy on the details, but the import package should do what you want. Off the top of my head, I think the syntax is \usepackage{import} ... \subimport{code/doc/latex/}{refman.tex} Update: Thanks Willie for pointing out \subimport which seems to be the better command to use here over \import. The commands \import{full_path}{file} and \subimport{...

33

for a single page of a multipage .pdf: \documentclass{article} \usepackage{graphicx} \begin{document} \includegraphics[page=2,scale=0.75]{bplot.pdf} \end{document} or if you want all pages: \documentclass{article} \usepackage{pdfpages} \begin{document} \includepdf[pages={1-},scale=0.75]{bplot.pdf} \end{document}

31

31

Here's a case where \endinput might be useful. Suppose I'm writing a textbook and that each chapter ends with problems followed by their solutions. I want to build two separate editions: one for students, without solutions, one for teachers, with solutions. I can define a conditional, say \ifstudent, and prepare my chapters as <text> \section*{...

30

The snapshot package gives you a list of the external dependencies of a LaTeX document. Use it by saying \RequirePackage{snapshot} before the \documentclass command (to have the information written to a .dep file), or by saying \RequirePackage[log]{snapshot} before the \documentclass command (to have the information written to the .log file).

28

28

\includegraphics makes a box that is positioned the same way \mbox{} or A are positioned. If you want to move it 3cm to the left use \hspace*{-3cm}\includegraphics.....

27

Cut the content (the part between \begin{document}...\end{document} of B.tex into a new file B-content.tex. Change B.tex to be: \documentclass{...} % your preamble here \begin{document} \include{B-content} \end{document} Then put \include{B-content} into A.tex.

27

Cross referencing and citation should work fine with \input. input is more or less invisible to the TeX processing, it just allows you to split up the file into smaller units for ease of editing. If you do not use \includeonly then \include{file} is more or less the same as \clearpage\input{file}\clearpage so like \input but with forced page breaks. Since ...

26

With modern distributions, you can't, for security reasons: the idea is that tex input files should only allow files to be written at the same level or lower in the directory hierarchy, because tex will happily overrwrite preexisting files. Reading is ok, as with \input{../xyz} but the trouble is that \include{../xyz} causes writing of a file ../xyz.aux, ...

25

No, you don't need it. \endinput is used for terminating the input process in the middle of a file. A \endinput at the end of a file is useless (and harmless). Some people like to use \endinput to show the end of file explicitly. IMHO, it make no sense.

22

You can't precompile chapters, but you can use the \includeonly mechanism to ensure that your cross-references and page numbers stay correct while choosing to only include parts of your source.

22

Let's assume you have \include{fileA} \include{fileB} If there is no \clearpage when fileA ends and TeX starts reading fileB, there might be a \write relative to fileA pending and it will get lost: the \write commands relative to \label are performed at shipout, not immediately. When the next shipout occurs, the fileA.aux file will have already been ...

21


21

Your comments indicate that you'd like to have some kind of database of equations. An easy approach would be to have a separate file equations.tex, say, which defines two macros \saveequation{<ID>}{<equation code>} \useequation{<ID>} and also contains the equations defined with \saveequation and maybe also calls some often needed related ...

19

You should use \include instead of \input, and then in the preamble say with \includeonly which of the included files you want in your pdf file, like this: \documentclass{memoir} \includeonly{chapter1,chapter3} \begin{document} \include{chapter1} \include{chapter2} \include{chapter3} \end{document} The first run(s) of pdflatex should be done without the \...

18

\include uses a separate .aux file. If the file is not included, the .aux file is still read and the references of the .aux file are available. Entries into the .aux file can be written \immediate or at the time, when the page is shipped out. Therefore \include starts a new page. Thus the labels of the previous page goes into the previous .aux file. Then ...

17

The \include command uses \clearpage at the beginning, however there's no page build up so far in the preamble, so it has no effect. Here's some code from the latex.ltx file (shortened!) \def\include#1{\relax \ifnum\@auxout=\@partaux \@latex@error{\string\include\space cannot be nested}\@eha \else \@include#1 \fi} \def\@include#1 {% \clearpage %....

17

There are lots of incorrect latex input constructs that don't actually give an error, they just do whatever they do by accident and luck. \include only does anything useful if used after the preamble, if used before it probably works like an inefficient version of \input and you manage to avoid an error just the way it works out, but no part of the behaviour ...

16

The excludeonly package defines an \excludeonly command that does what you want. Package description: The package defines an \excludeonly command, which is (in effect) the opposite of \includeonly. If both \includeonly and \excludeonly exist in a document, only files "allowed" by both will be included. The package redefines the internal \...

16

Just put them all in a mymacros.sty file and add the single line on top (which is also optional!): \ProvidesPackage{mymacros}[2011/02/23 v1.0 My own macros] That's all what is required for a simple package. No plainTeX knowledge required. Load it as usually using \usepackage{mymacros} Please note that \include can't be used in the preamble. For this kind ...

16

It seems that you are using the chapterbib package to produce your multiple bibliographies. The error messages that you are getting suggests that you are not compiling your document correctly. I'll explain how to compile your document with a simple example; I'll assume that your main document is called test.tex and looks like this: \documentclass{report} \...

16

If you need page numbers at the bottom, \includepdf[pagecommand={\thispagestyle{plain}}, pages=1-10, angle=90]{requirements/Requirements.pdf} Change "plain" to "headings" if you are in the report or book class and want for the included pages the same style as the others.

16

TeX only processes the input line by line, so there is a limit on the number of characters in a line, but not on the total size of the file. Your editor however probably does need to read the entire file into memory so may have limits on the file size. The editor I use warns if the file is more than 10MB but will open files larger than that, up to the ...

15

TeX works in a linear fashion with an input file, and while there are methods to split up in input (ultimately based on the \input primitive), these are for the author's convenience only. TeX still processes all of the input in a linear manner: once a file is \input it is as though the material was all in one big file. At the same time, it is possible for ...

Only top voted, non community-wiki answers of a minimum length are eligible