5
votes
1answer
27 views

Selectively apply \global to some tokens set via an \input file

This should be simple, but I can't quite guess the correct combination of \expandafter needed. The value of \MyTokenGlobal should not be changed via the \input, but the value of \MyTokenLocal should ...
10
votes
1answer
56 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 ...
5
votes
1answer
184 views

Use input inside a spreadtab environment with calculations

My aim is to create a command for inserting tables, which will format the table, and add calculations on its values, given a file containing the raw data of the rows only. ...
7
votes
3answers
133 views

Command that expands to the contents of a file

I'd like to make a macro that expands to the contents of a file. Basically something like \def{\mycommand}{\input{file.txt}} % file.txt contains "Hello%" \anothercommand{\mycommand} ...
9
votes
3answers
286 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 ...
15
votes
3answers
1k 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 ...
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 ...
13
votes
1answer
517 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 ...
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 ...
5
votes
1answer
794 views

Jobname of inputted file?

\begin{filecontents}{foo.tex} \def\foo{\jobname} \end{filecontents} \documentclass{article} \begin{document} \input{foo} \foo \end{document} This outputs the jobname of the main file not "foo". How ...