{input} is about the \input command which makes LaTeX process the content of a given file basically the same way as if it would be written instead of \input.

learn more… | top users | synonyms

401
votes
4answers
166k views

When should I use \input vs. \include?

There are two different commands to incorporate another file into the source of some document, \input and \include. When should I use one or the other? What are the differences between them? Are there ...
34
votes
4answers
4k views

\input only part of a file

I would like to include part of the contents of a .tex file into a different .tex file. I don't have the option of modifying the file to include. The file to include may change so simply copying and ...
34
votes
3answers
4k views

Replace \input{fileX} by the content of fileX automatically

Suppose I have a document with multiple include or input statements \input{fileA} \input{fileB} etc. Is there an easy way to generate a single .tex file where \input{fileA} is replaced by the ...
27
votes
4answers
19k views

How to make the main file recognize relative paths used in the imported files?

I'm currently using doxygen to generate some documentation for a project, and doxygen generate some LaTeX code that then can be used to generate a nice pdf. But let's say I would like to write ...
27
votes
2answers
2k views

Insert libreoffice table as input

This question led to a new package: odsfile Suppose you have an localc spreadsheet myspread.ods and you want to insert the content of the range H4:I40 as a table into your latex document. I ...
21
votes
2answers
6k views

Inputting multiple files in LaTeX

Suppose I have a directory containing a bunch of LaTeX source files, and I want to input all of them into a single main file. I could do this by saying \input{dir/file1.tex} \input{dir/file2.tex} ...
19
votes
1answer
551 views

Rationale to use \input{filename} on the pdflatex command line?

In a tex.SX user profile, I read the best practice recommendation Execute pdflatex \input{filename} instead of pdflatex filename. I have always used the latter one, directly, in scripts, and in ...
17
votes
4answers
12k views

\input and absolute paths

Sometimes it is convenient to use an absolute path to include a preamble. To do so, I use the following "hack": \documentclass[a4paper, 12pt]{article} \newcommand{\folder}{/path/to/folder} ...
15
votes
6answers
2k views

\endinput: what is it for?

I am working on a big document and I am using the \include command to put chapters one after the other. On the internet I came to know about the existence of the \endinput command. However I do not ...
15
votes
3answers
2k views

Create list of all external files used by master LaTeX document?

Is there an easy way to create a list of all external files (complete path) which are used by a LaTeX document (and its "sub-documents") by \input \include \includegraphics ? (may I have forgotten ...
15
votes
3answers
2k views

Expandable version of \InputIfFileExists or \IfFileExists

From this question: Cannot use \toprule when doing \input inside tabular -- why? I know that everything inside the tabular environment should better be expandable. The MWE below suggests that ...
14
votes
1answer
553 views

Why is \input not expandable?

In latex.ltx I found \def\input{\@ifnextchar\bgroup\@iinput\@@input} where \@@inputis expandable. I would like to know if there is an expandable version of \input. The problem comes from an example ...
14
votes
1answer
589 views

How do I create a macro which reads the content of a file when the macro is defined?

I am trying to do something like: \newcommand{\sometext}{\input{somefile.txt}} This works, but requires inputting the file every time the macro is used in the document. I would like to know a way ...
13
votes
3answers
482 views

Need help creating a custom aux file read/write routine to suit my needs

I require two new commands, \createreference and \citereference, to work with. They should work as shown in the following examples: \createreference{john}{John Q. Citizen} should write the text “John ...
13
votes
3answers
9k views

Path to External Files in Nested \input

Problem I usually load a helping TeX file that contains my customizations, e.g., usual packages, corporate standard colors, and macros for abbreviations. I want my helping file to also load another ...
13
votes
1answer
418 views

Help automating calendar creation

I'm doing calendars for all the family, and I have a problem automating the process. I'm using the calendar tikz library. I need to include the moon phase in the calendar. I can do it with this code ...
13
votes
2answers
192 views

Which TeX procedure removes trailing tabs?

From reading the TeX source, it seems that the input_ln procedure is responsible for removing trailing spaces from lines upon input (before category codes are considered). A very short excerpt from ...
13
votes
2answers
193 views

How to get rid of unwanted spaces with \input?

For my project to bring scripting to (Xe)(La)TeX, I need to execute command lines with write18, redirect output to a temporary file, and then insert the produced text using \input. I've noticed some ...
12
votes
2answers
333 views

How can I easily use the same preamble on all my documents?

I use multiple computers (Mac and PC), so creating a path (e.g. \input{c:/folder/Preamble}) won't work. I really want to assign a URL (in Dropbox) to the file and input the file via the URL, but I ...
12
votes
2answers
2k views

Splitting a large document into several files

Why is it recommended to split a large document into several parts and include them with \include? Is it only a relic of the past times when computers and LaTeX compilers were slower, or is it still ...
12
votes
1answer
250 views

Is there a limit to the size of a tex-file?

I've been writing a document for some time now. It is steadily growing and hopefully will continue to do so. Lately I realised that -- although I just recently bought a new MacBook -- when I work on ...
12
votes
2answers
1k views

Space inserted after “\input” call

I've noticed a significant issue with the \input command, it seems. For some reason, I can't seem to prevent it from adding a space after it reads its input. Even if there is no newlines or spaces ...
12
votes
2answers
922 views

How to avoid automatic .tex extension in filenames?

I am in an mildly unfortunate situation in which, because of the way I prepared the files automatically, I ended up with a file to be attached but also another file with the same name but ending in ...
12
votes
2answers
7k views

How to use the import package?

I've read about the import package and am now trying to use it in my document, but I only run into errors. I have a main file named /ProjectPath/header.tex which loads all packages, etc. ...
11
votes
3answers
207 views

Read authors from file

At our university, we students write a lot of summaries in LaTeX. We have the convention of adding a CONTRIBUTORS.txt file to the repository containing the document code, which lists all contributors ...
11
votes
3answers
874 views

force long text inside \item[{\texttt{}] to wrap

I have a LaTeX document that is automatically generated and then inserted as part of my own larger document with \input. This other document has a description environment for examples, one item for ...
11
votes
2answers
2k views

How to make \include work with a quoted string path containing spaces?

In Windows, \input can work with a quoted string path containing spaces, but \include cannot. How to fix it? \documentclass{book} \begin{document} %\input works! \input{"Contents/Installing and ...
10
votes
6answers
307 views

How can I '\input' a file without getting the implicit newline?

Intro I'm working on a lightweight package that allows you to put any content (typically LaTeX code) in an environment, then use that content multiple times, each time scanned separately, so you can ...
10
votes
2answers
273 views

Large document edited by a dozen people

We, a team of 12 people, plan to write a 50 pages paper. The paper will be divided into chapters. Usually, no more than 2 or 3 people will work on a given chapter. Having one large file will create ...
10
votes
1answer
104 views

`\input`ting contents of a file into a `hyperref`'s `pdfkeywords`

I use git to manage the development of my LaTeX documents, and I have a makefile I use to build a PDF from the LaTeX source. For the sake of provenance, I would like to embed the most recent git ...
10
votes
1answer
574 views

Tabs in output file written by xelatex and pdflatex are different

I'm trying out pgfplots with gnuplot to generate the data. This works by having pgfplots write some stuff to an external file, run gnuplot on the file, and then use the generated data to plot the ...
10
votes
2answers
516 views

randomize the order of text lines in a .tex file

I need to create an environment (let's call it randomizer) that randomly changes the order of its lines, which may contain any text or latex commands (assume without verifying that they don't break ...
10
votes
1answer
57 views

Reading (input) a file whose name is created with a label

I don't want to get into the details of why I want to do this, but I would like to: create a new counter called filenumber; create a file whose filename is \jobname\thefilenumber.txt and write to ...
9
votes
2answers
259 views

How to use the contents of a file as a number

I want to create a loop including n images.The number n is the only content of a help file (created by the application that generates the images). Is it possible to read the contents of the help file ...
9
votes
3answers
273 views

Make newlines expand to custom command

I am making a guest list which I will print on a sticker sheet, cut them out, then stick them to envelopes. This means that each guest/guest group will have a bounding box drawn around it as a cutting ...
9
votes
2answers
175 views

How not to load a file repeatedly?

I created a file version.tex with a git log message. This .tex-file is then included in my main.tex file like this: \renewcommand{\footsnippy}{% Author Name, Title of my Book, % ...
9
votes
1answer
1k views

Can a default path be set globally for \input{…} akin to \graphicspath{…}?

For the graphicx package, we can use \graphicspath{...} so that we can directly use filenames in the argument of \includegraphics{...}. Can a similar thing be done for directly using filenames in ...
9
votes
3answers
304 views

Write on a file and input it

I'm trying to redefine a \tableofcontents-like command. I proceed this way : the displayed elements are written to a file, and the file is input when I want the display. If I know the toc will be ...
9
votes
1answer
167 views

Can I use \input inside an \include?

I know it is not possible to nest one \include inside another, but what about \input? Is it possible to have something like: \documentclass{article} \begin{document} \include{file1} ...
9
votes
1answer
140 views

Suppress message during compilation

I use a macro with \write18 and \@@input, several times in each page of a large document. But \@@input output a message during compilation: (filename) This is very annoying and flood the other ...
8
votes
3answers
7k views

Include data from a .txt

I am using a finite element program that outputs data in .txt files. And I want to input these data in my latex code. Is there a way to input the data files so that they appear as the program output ...
8
votes
2answers
2k views

Cannot use \toprule when doing \input inside tabular — why?

Using \input inside a tabular environment does not seem to work in all cases, but I don't see why. The MWE below gives the following error message: ! Misplaced \noalign. \toprule ->\noalign ...
8
votes
2answers
583 views

Bind reports/articles into a book, but keep the ability to compile them individually

I see a few questions and answers about writing a book/thesis in LaTeX (here's one). But I would like to be able to compile reports separately as I write them to have a bunch of standalone documents. ...
8
votes
4answers
237 views

Checking for a matching entry within a file

I have a file containing a list, like this: apple orange pear pineapple How can I create a macro which checks if an item is on that list. E.g.: \isfruit{pear} returns "1". \isfruit{carrot} ...
8
votes
2answers
258 views

Dynamic upper bound for foreach loop

I want to read the upper bound for my foreach loop from a file. I've tried the following, but it gives all manner of errors. \documentclass{article} \usepackage{tikz} \begin{filecontents*}{foo} 42 ...
8
votes
2answers
104 views

\input - \return-command

I'm looking for a command like \return with which I can manually exit a TeX file, which is included by \input. (At the end of my TeX file are some notices, which I sometimes want to print, sometimes ...
8
votes
4answers
1k views

How to write a command to file

I am trying to write to a auxillary file using \newwrite\tempfile [...] \immediate\openout\tempfile=list.tex \immediate\write\tempfile{Text to write to file} \immediate\closeout\tempfile It works ...
8
votes
2answers
135 views

\input in the reverse order

I wonder if there is a reverse version of input. For instance, I maintenance a list of things. list.txt \myitem{20080103}{a} \myitem{20090202}{b} I could do \input{list.txt} and define \myitem in ...
8
votes
3answers
221 views

How to join two or more external .tex file using another .tex file and then compile?

Suppose I have two tex files file1.tex and file2.tex. I want to join them in another tex file. I have tried to do this with the following one : \documentclass{book} \begin{document} ...
8
votes
1answer
330 views

Is there a “selective” input command in LaTeX?

I'm likely going to have to write a document that includes some portions of source code, which I'd rather keep in separate source files. I know that I can include the contents of those files in my ...