Tag Info

Hot answers tagged

421

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


153

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


61

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


38

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


37

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


33

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


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


25

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


25

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


25

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}


24

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


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

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


21

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


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


20

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.


20

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


19

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


19

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.


18

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.


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

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

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


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


14

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


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


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

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


13

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


13

Try \graphicspath{{articles/article1/}} before the \include.



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