Tag Info

Hot answers tagged

318

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


123

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


47

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


31

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


30

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


29

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


29

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


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

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


21

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


20

You can place (almost) arbitrary LaTeX code in macros for later use. So you can use these to store your equations. Here is a simple example showing some possibilities: \documentclass{article} %% Can be in external file which can be inserted with \input \newcommand{\myeqintf}{f(x) = \int_a^x g(t)\,dt} \newcommand{\myeqintt}{\begin{displaymath} f(x) = ...


19

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


19

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


18

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.


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

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}


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


16

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.


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

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

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

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


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


14

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


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

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

\includepdf[pages=1-10, angle=90, pagecommand={}]{requirements/Requirements.pdf} Add pagecommand={} as one of your options


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


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



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