Questions tagged [write]
{write} is about writing to files in TeX macros.
179 questions
4 votes
2 answers
163 views
expl3: l3file: \iow_now:Ne... doesn't expand tokens before writing to the stream?
MWE: \documentclass{article} \begin{document} \ExplSyntaxOn \iow_new:N \g__test_iow \iow_open:Nn \g__test_iow { test.pl } \iow_now:Ne \g__test_iow { \# } \iow_close:N \g__test_iow \ExplSyntaxOff \end{...
7 votes
1 answer
168 views
LaTeX environment to write verbatim Python code to an external file
I’d like to have a solution environment that does the following: It writes the contents of the environment to an external file \jobname.py. All the solutions should be in the same file \jobname.py. ...
3 votes
1 answer
120 views
Writing result of a non-expandable command
I have a token list that includes (at least) one non-expandable command (defined by \NewDocumentCommand) and want to write the result to a log file (lets assume the critical command generates ...
1 vote
2 answers
114 views
Write randomly generated content to external tex file
I am trying to generate random fractions and write their simplification to an external tex file using the code below. But, il only repeats the last one several times. Is there a why to write each ...
0 votes
0 answers
43 views
wrapping a \item inside another command and writing to file has unexpected behavior when input
I am currently trying to write a pair of commands, the first can be used repeatedly (with different arguments) and writes out to a file, the second inputs the file with some custom wrappings. This has ...
3 votes
2 answers
90 views
XeTeX, LuaTeX: how to use \write for obtaining a UTF8 file with BOM marker?
I have a document that typesets some data, but also writes it to a csv file using \write. The data includes UTF8 characters. As a convenience, it should be possible to open the csv file under Windows ...
0 votes
0 answers
49 views
How to record the location of each rectangle
The following code renders a paper test and attempts to write out an answer file with the location of each answer, so an autograder can pick out each answer, scan it in and try to grade. The answer ...
4 votes
2 answers
258 views
Dynamically growing an enumerated list in a file
Please consider the MWE below. This is a simplified version of a large project. I need to create an enumerated list that is generated dynamically during runtime. This list is included at some later ...
0 votes
0 answers
114 views
Patching \cref and \Cref to write additional information to the .aux file
I need to patch the macros \cref and \Cref so that when used like this: \cref{label1,label2,label3} besides generating the normal layout in the document, they write something like this to the .aux (...
0 votes
1 answer
57 views
Preserving newlines and spaces while writing argument to a file
I am making a function that should write its argument to a file (for further processing by Python) From the following question I get something that mostly works. Adding newlines while writing text to ...
2 votes
1 answer
159 views
Export all minted code fragments to files
I would like to export all the code fragments of a lectures book I wrote in a ordered tree structure as <chapter>/<section>/<some name or number>.<ext>. the code is in variuous ...
4 votes
2 answers
226 views
`\immediate\write` not working on first page
\documentclass{article} \usepackage{lipsum} \newwrite\foo \openout\foo=foo.foo \begin{document} \immediate\write\foo{A} \immediate\write\foo{B} \lipsum \immediate\write\foo{C} \lipsum \immediate\...
0 votes
0 answers
60 views
Capture text before my command and write it to an external file
I have some LaTeX that's something like this: Donec id elit non mi porta gravida at eget metus. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Morbi leo risus, porta ac ...
2 votes
2 answers
178 views
Understanding expansion in \addtocontents
I am confused about how expansion works in \addtocontents, or more precisely in \protected@write. As I understand it, \addtocontents should essentially expand its second argument with \protected@edef ...
6 votes
2 answers
625 views
How can I use morewrites and memoize?
Consider the following MNWE, which I'm compiling with pdfTeX: \documentclass{article} \usepackage{morewrites} \usepackage{memoize} \usepackage{tikz} \begin{document} \begin{tikz} \draw (0,0) -| (1,1)...