# Tag Info

193

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

66

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

34

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

32

Edit: There is now LaTeX package for testing https://github.com/michal-h21/odsfile Before I post it on CTAN, any comments on style/grammar/spell in the documentation files, as well comments on the source code, are highly welcome. There is solution using luatex's zip library and pure lua xml processing library LuaXML, which you should install to same ...

26

Manuel has posted an answer that uses line numbers; there's a recent package on CTAN that lets you do it with tags in the input file: catchfilebetweentags. An example is \usepackage{catchfilebetweentags} ... \ExecuteMetaData[file.tex]{tag} where the contents of the external file is surrounded by the "tags": %<*tag> ... %</tag>

24

You can use the following tools to do this. All of them are on CTAN but are not part of either TeXLive nor MikTeX, so you need to manually install them. They need either Perl or a C compiler installed. Both should not be a problem with Linux but might be one under Windows or Mac. However IIRC TeXLive installs its own Perl interpreter. latexpand Perl ...

23

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

21

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

19

Advantages It is a good trick, if someone wants to put TeX code before. Examples: pdflatex '\def\foo{bar}\input{filename}' pdflatex '\includeonly{introduction}\input{filename}' or inside \write18 (shell escape feature): \immediate\write18{\detokenize{pdflatex '\def\foo{bar}\input{filename}'}} \immediate\write18{\detokenize{pdflatex ...

17

Your text ---------------> TeX --------------> PDF input encoding font encoding You need an input encoding to tell TeX how to interpret the contents of your text file, you need an font encoding for proper hyphenation. Old TeX can only hyphenate words from one font and therefore you need to squeeze all the characters you use ...

15

You could split every report into two files: a main file holding only the preamble and an \input as document body, and a second file holding all the actual content. Then you are able to \input or \include all the content files in another main file for the book. % Main file of one report, e.g. report01.tex \documentclass{report} \title{...} ...

14

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

14

13

The check if a file exists is not expandable, because the file is opened using \openin\somefilehandle=<filename> which makes an assignment to \somefilehandle. Then \ifeof\somefilehandle is used to check if the end-of-file (EOF) is already reached, which is immediately true for non-existing files. Empty files, I think, need to be read at least once ...

12

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

12

Here's how it goes in texlive (and presumably other web2c distros): The changefile tex.ch removes the Knuth definition of input_ln; The underscore gets lost in the conversion of web to c; The resulting C code #includes texmfmp.h which does #define inputln(stream, flag) input_line (stream) The function input_line() gets defined in texmfmp.c where the ...

12

I replaced your if-if-if-if construct with a simple \ifcase test. \moon works just fine now. Though the actual problem was another one. The counter assignments \global\advance\<counter> by 1 should be finished with a \relax. This also applies to the \ifnum but in this instance, it is not needed as math-mode is introduces right away. Without the \relax ...

11

In my answer on greek text I gave an explanation which I'll basically repeat and extend here. I'll be basically talking about text encoding here, as it is rather obvious that math requires special treatment. Please also look at encguide where all this is explained in more detail. First of all, all this refers to TeX engines like pdftex which only support ...

11

You can read the content of a file into a macro with Heiko Oberdiek's catchfile package: \CatchFileDef{\sometext}{somefile.txt}{<setup>} This will read the file like a normal TeX file, i.e. it can include macros etc. The <setup> argument can be empty for files read normally but can include special code to e.g. read the file content verbatim or ...

11

In TeX Live, the formats for pdf(la)tex and lua(la)tex are built loading the tcx translation file cp227.tcx that makes ^^I "printable". This means that a category code 12 ^^I is written out as a real tab character. On the other hand, xetex ignores tcx translation requests and behaves, in this respect, like Knuth's TeX (but it writes UTF-8, of course). A ...

11

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.

11

Normally this is done using the listings package. It provides a lstlisting environment for verbatim code and also a \lstinputlisting[<options,...>]{<file name>} to include an external file verbatim. As options you can select language=C++ to get specific syntax highlighting. I also usually use basicstyle=\ttfamily. See the listings package manual ...

11

The LaTeX \input command, by Lamport's choice, must support both \input{file} and \input file so it's necessary to define it in that way: a test on the following character is necessary as the primitive \input scans its argument in a very peculiar way. If you don't want to support the original syntax inside your environment, then putting ...

11

I did not understand where do you want to put the text: in the main file jobname.aux or in the separate file. If the former, this works (basically modelled after the standard \ref-\label mechanism): \documentclass{article} \makeatletter % The command reference writes \newreference into the aux file \def\createreference#1#2{\@bsphack ...

11

\input is trying to be intelligent, and this seems to be upsetting LaTeX's picky tabular definition. But you can access the original \input primitive from TeX which is less dangerous at this point. After defining \makeatletter \newcommand\primitiveinput[1] {\@@input #1 } \makeatother using \primitiveinput inside the tabular should work.

11

It's easy to see where the loop comes from as \Bigr is defined in terms of \Big which is (by default) \def\Big#1{{\hbox{$\left#1\vbox to11.5\p@{}\right.\n@space$}}} so defined in terms of \left It is probably safer just to do a replace/edit on the incoming file If you wanted to do this in TeX you'd neeed \let\oldleft\left \let\oldright\right and ...

11

Without a \read: \documentclass{article} \usepackage{catchfile} \newcommand{\setcounterfromfile}[2]{% #1 = counter, #2 = file name \CatchFileDef{\scfftemp}{#2}{\endlinechar=-1 }% \setcounter{#1}{\scfftemp}} \newcounter{cnt} \setcounterfromfile{cnt}{numberfile} \showthe\value{cnt} If numberfile.tex contains the only line 12345 (a very difficult ...

10

Here is an approach in pure TeX (well, e-TeX). The main idea is: to select a range of lines in a file, sed is overkill, TeX is more than enough. As a bonus, no temporary file is needed. \documentclass[a4paper]{article} \usepackage[ascii]{inputenc} \usepackage[T1]{fontenc} \usepackage{lmodern} \makeatletter \newread\pin@file \newcounter{pinlineno} ...

10

TestInput.out probably contains a new line at the end of the file (text files usually do, even when created with echo 'abc' > file). TeX interprets new lines as spaces. To remove that space, simply add \unskip directly afterwards, i.e. use A\input{TestInput.out}\unskip B (this will also remove any intentional space at the end of the file, should there ...

10

There is as far as I know no way to get around the problem. How TeX handles files with unusual numbers of dots (where "unusual" is any number unequal to 1) is quite inpredictable and also has changed over time. In miktex 2.4 e.g. \input{file.cfg} would have tried at first file.cfg then file.cfg.tex, in miktex 2.5 it tried only file.cfg, in the current 2.9 ...

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