Using LuaLaTeX with TeXlive 2016, although I imagine that this question applies to nearly anything:
I know how to create a file using \immediate\write on a line-by-line basis. But I would like to do it for multiple lines, where the number of lines is not known in advance (it is the result of gathering text items in a macro). Something like this:
\newwrite\file
\immediate\openout\file=pickafilename.txt
\immediate\write\file{Hello! I am a new file.}
\immediate\write\file{\MacroContainingTextMacros}
\closeout\file
The \MacroContainingTextMacros has a few small macros within it, which I wish to expand as the file is written. Each of those small macros contains a few lines of plain text. So I cannot use verbatim, or filecontents.
Any ideas?
^^Jmeant. I see it in code. I thought maybe it was a programmer's Smiley Face. – Oct 21 '16 at 18:15^^is primitive TeX syntax for shifting the character code by 64 (which is what ctrl does, more or less) – David Carlisle Oct 21 '16 at 18:31^^Mas well -- for carriage return. – jpaugh Oct 21 '16 at 21:00a, if you want, it just depends on the value of\newlinecharwhich is 10 by default. using^^Mis tricky even if you set\newlinecharto 13 as it is\endlinecharand acts like a comment hiding the rest of the input line. – David Carlisle Oct 21 '16 at 21:09mystringsdefined as follows:\usepackage{xstring} \def\mystrings{\noindent\StrSubstitute{% B; new; test old; found people; sun; atom; number; life}% {; }{\noexpand\noexpand\noexpand\newline}} \mystrings. Should I ask a new question for this? – Krantz Oct 28 '23 at 13:14^^Jat all. – David Carlisle Oct 28 '23 at 13:25