Let me give it as an example:

I want to write some commands to a file

\immediate\write\tempfile{"\toprule"}%Yes it don't work like this!

Then somewhere after:

\begin{tabular}{r l l l l l l l}
\input{mycommands}%add toprule here
  • 1
    Why do you want to write this to a file? If it's just contents you need to create during runtime you could as well define a global macro that stores the contents. – Skillmon Oct 22 '19 at 12:07
  • My problem is different, the above case is just an example. – Reza Afzalan Oct 22 '19 at 12:16
  • 2
    In that case it might be a good idea to explain your use case. – Skillmon Oct 22 '19 at 12:21

You must prevent expansion when writing to the file. And you can't use \input to load the file if it starts e.g. with a \toprule: \input is not expandable and so not allowed in this place. The primitive input command will work.


\begin{tabular}{r l l l l l l l}
\csname @@input\endcsname mycommands.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.