# Tag Info

289

\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 ...

105

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 ...

44

\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 ...

30

use package pdfpages and then: \documentclass{article} \usepackage{pdfpages} \usepackage{hyperref} \begin{document} \tableofcontents \clearpage\phantomsection \addcontentsline{toc}{section}{The first section name}% or chapter \includepdf[pages={1-10},linktodoc,linktodocfit=/Fit]{texte/dtk/dtk11-1/komoedie.pdf} \clearpage\phantomsection ...

29

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 ...

28

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 ...

26

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 ...

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 ...

20

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, ...

20


19

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> ...

18

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 ...

17

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).

17

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 ...

17

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 ...

15

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 ...

15

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 ones like to use \endinput to show the end of file explicitly. IMHO, it make no sence.

15

This is what has been working great for me for about two years now. create a .sty file containing your universal preamble. A .sty file, basically, is a regular TeX file starting with \ProvidesPackage{mystyle}, ending with \endinput, and everything else inbetween.*) in your Dropbox (or similar), create a directory named texmf-local, and a subdirectory such ...

14

The following macro \isincluded uses the same test that \include uses (code copied from there). If the file in the first argument will be included, then the second argument is called, otherwise the third. Also the macro catches the case, when \includeonly is not used and all files are included. \documentclass{article} \includeonly{file,file2} ...

13

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}

13

The purpose of the \include mechanism is to allow for partially compiling the document when making a modest amount of changes without the need to recompile the full document and still get cross-references etc correctly resolved (even to parts outside the current part under the knife). For this to work the part or parts that are included have to be ...

13

But isn't the very point of \include command to work separately from a long document? True, but it’s not the point of the \include command to include complete documents, as you’re trying to do; rather, it works on fragments of a document. What's the point if I can't compile the including file separately (having no preamble, etc)? The point isn’t ...

13

Use \include{../file}. .. is UNIX for the parent directory, which Tex uses. See Kpathsea: Path searching. Postscript Lev Bishop notes that this won't allow you to write to the parent directory, and that \include typically wants to write to a *.aux file in the parent directory. You can workaround the absence of write permission by setting TEXMFOUTPUT: ...

13

For ConTeXt, I have written a module, t-filter, that provides a nice user-interface for running external programs on a file. Using that module, you can write: \usemodule[filter] \defineexternalfilter [markdown] [filter={pandoc -t context -o \externalfilteroutputfile}] after which you can use \processmarkdownfile{....} to convert a markdown ...

12

\include by definition starts a new page both at its beginning and when the included file ends. The reason is that documents with "included" files should be properly compilable with only some of the files included. And to preserve page breaking and numbering even if a document is only partially compiled, the files are running \clearpage before and after to ...

12

You could also use the catchﬁlebetweentags package. This package enables you to use a separate file to store you equations and then refer to them using tags that you specify. This blog post, Loading equations from an external file, explains this quite well but for the lazy I'll include an example: First you put your equations in a .tex file, delimiting ...

11

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 ...

11

You won't get the behaviour that \include gives, where it saves the missing page numbers, chapter/footnote/equation/theorem/etc counters, bibliographic citations, etc, but if all you want is the ability to conditionally select which pieces of the document you want to compile, then there are several options, as discussed in the FAQ. The comment, version, ...

11

Solution 1: Put everything up to your \begin{document} in a separate file, say, preamble.tex. You can load this file in your document by saying \input{preamble}. Solution 2: Almost the other way around: put your chapters in separate files, and have a main file like this \documentclass... . . . \includeonly{chapter2} \begin{document} \include{chapter1} ...

11

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 ...

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