Skip to main content

Questions tagged [write]

{write} is about writing to files in TeX macros.

Filter by
Sorted by
Tagged with
0 votes
0 answers
82 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 (...
Gabriele's user avatar
  • 2,003
0 votes
1 answer
35 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 ...
Atnas's user avatar
  • 497
1 vote
1 answer
77 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 ...
max's user avatar
  • 51
4 votes
2 answers
179 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\...
Ray's user avatar
  • 165
0 votes
0 answers
41 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 ...
Circle B's user avatar
  • 123
2 votes
2 answers
119 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 ...
mbert's user avatar
  • 4,496
6 votes
2 answers
411 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)...
cfr's user avatar
  • 207k
0 votes
1 answer
28 views

How to \immediate\write multiple lines produced using \newline and \StrSubstitute

Why this does not work when the lines are produced using \newline (instead of ^^J) and \StrSubstitute as follows? Thanks \documentclass{article} \usepackage{xstring} \begin{document} \def\mystrings{\...
Krantz's user avatar
  • 158
-1 votes
1 answer
67 views

How can I write this type of "V" in latex in the image below [closed]

How can I write this type of "V" in latex
Memristor's user avatar
  • 119
3 votes
2 answers
109 views

Explicit carriage-return character in \write

Is it possible to \write and explicit carriage-return character in LaTeX? Reason for this question: I have workflow where a latex run generates output for another program, which requires CRLF line ...
sslbrg's user avatar
  • 78
0 votes
1 answer
43 views

Prevent active character from being expanded in macro argument

Goal: Have an active character not expanded when writing to file MWE \documentclass{article} \makeatletter % == Package code -- untouchable \def\foo{\@ifnextchar[{\@foo}{\@foo[x]}} \...
aker's user avatar
  • 15
0 votes
2 answers
80 views

How to save a macro to a file, unexpanded?

I want this to work, but it doesn't: \documentclass{article} \begin{document} \newcommand\hello{Hello, \LaTeX!} \newwrite\foo \immediate\openout\foo foo.tex \immediate\write\foo{\hello} \immediate\...
yegor256's user avatar
  • 12.2k
0 votes
0 answers
101 views

Best practices for \cite and \citep

Imagine that \cite{webb2004oscillations}) and \citep{webb2004oscillations}) yield, respectively Webb and Owen, 2004 (Webb and Owen, 2004) When writing a paper, what is the best practice to cite this ...
sam wolfe's user avatar
  • 257
2 votes
2 answers
191 views

Using \g@addto@macro in a loop

I am confused when using \g@addto@macro in a loop. My code is: \documentclass{article} \usepackage{ifthen} \usepackage{newfile} \usepackage{xstring} \makeatletter \DeclareRobustCommand\@initial[1]{#...
Crosfield's user avatar
  • 119
1 vote
0 answers
46 views

Incomplete \iffalse when using datetime package and \write

Objective A function that enables me to write custom log data. The result is the command \writeToLog (see MWE), which writes its input to the file log.txt. Issue In my actual document I'm using the ...
Steven's user avatar
  • 153
1 vote
2 answers
115 views

How to write the string "^^^^" into a file

I am trying to write "^^^" into an already opened file (under the variable \myfile) using the command \immediate\write\myfile{"^^^"} This, however results in an error. I am ...
Murali Agastya's user avatar
1 vote
2 answers
97 views

Macro to define macros within .aux file is not working

Here are some macros that I am trying to define (based on this question): \odef{foo}{bar} will define an "object" with name foo and value bar. \objRef{foo} will insert the value of the foo &...
Ben Zelnick's user avatar
1 vote
0 answers
55 views

How to escape before saving to a file?

I'm trying to create a command that will be able to save plain text to a file (without any TeX commands): \documentclass{article} \begin{document} \newwrite\xwrite \newcommand\tofile[1]{ \immediate\...
yegor256's user avatar
  • 12.2k
5 votes
1 answer
234 views

Need macro to \write content into a file as a string from LaTeX

We are writing a cls file that produces a text file as a side effect of running latex. This will be done in a cloud service within a docker container, so security is a serious concern. The output file ...
mccurley's user avatar
  • 159
0 votes
0 answers
44 views

Preserve vertical lastskip over \write

Is there a way to save a vertical \lastskip over \write, or, more generally, is there a way to program a "vertical version" of \@bsphack … \@esphack? In the following minimal example \...
Lupino's user avatar
  • 2,762
0 votes
1 answer
116 views

Write the contents of a bibliography from thebibliography environment to a file

I need to write contents from thebibliography environment (BixTeX/BibLaTeX are not used) to an XML file. Each bibliographic source should be in a separate pair of <reference> and </reference&...
Crosfield's user avatar
  • 119
1 vote
1 answer
94 views

Writing to a file values of function in expl3

I'm trying to master LaTeX3 using the example of the problem of parsing LaTeX code and then writing function values ​​to a file. Problem. Generate a piece of XML file in pdfLaTeX containing normalized ...
Crosfield's user avatar
  • 119
0 votes
0 answers
107 views

\pageref{} produce wrong page number when \label{} comes top of the page

I am trying to create a para id with page number as a separate file, through a command \def\paraopenid#1{\label{#1}\immediate\write\paraID{<ParaID="#1" StartPageNumber="\...
pdy-ind's user avatar
  • 2,122
0 votes
0 answers
59 views

Writing to and compiling .tex document from another GUI

I am a math teacher and I have a .tex template for my quizzes that looks something like this: \begin{document} \begin{flushleft} Name: \underline{\hspace{2in}} \hfill /XX % where XX is ...
Gabe's user avatar
  • 1
1 vote
1 answer
404 views

How to write and expand \gls command to a text file?

Is it possible to expand the \gls command in order to print it's "output" in a text file? Here a 'MWE.tex' file content: \documentclass{article} \usepackage{glossaries-extra} \...
zetyty's user avatar
  • 777
8 votes
1 answer
450 views

What is the difference between \write and \immediate\write?

What is the difference between \write and \immediate\write commands when writing to a text file? \write command seems to write nothing on the text file... Here a MWE: \documentclass{article} \...
zetyty's user avatar
  • 777
4 votes
1 answer
106 views

Using the word "write" as a label makes compilation crash

Took me all night (literally) to figure out. Compilation was failing one time out of two, with the following original error (line 12) : "Bad space factor (0)". That was crazy because ...
Vincent Krebs's user avatar
0 votes
1 answer
101 views

Append content to a file containing sharp

In my library, I need to be able to append some text to a file. The problem is that that file may contain the # symbol, and it turns out that every time I append something to a file containing a #, ...
tobiasBora's user avatar
  • 8,944
0 votes
0 answers
145 views

How get the result of a macro that uses xstring functions before writing to a file

I encountered the need to write last name with initials (extracted from the full author's string based on first chars of first and middle name) into an external file. I use the xstring package to ...
Crosfield's user avatar
  • 119
1 vote
0 answers
29 views

Print information when changing pages

Can I print some information when generating a new page? For example, in the following example, I want to print "new page!" or page number in a txt file every time a new page is generated. \...
happy's user avatar
  • 159
3 votes
1 answer
154 views

Use \immediate\write18 with Single Quote

I would like to use \immediate\write18 (encoded in the \OuputToFileA macro) to output a string containing a single quote. If I replace the single quote with another character, such as X \StrSubstitute{...
Peter Grill's user avatar
0 votes
1 answer
87 views

how to change the format of date to exported to a CSV file

I want to write export some Information in a csv data. One thing I don't get in in the csv data, it is the date. Firstly when I use \today in my Latex document I get 15.January 2022, but I want it in ...
IH Pro's user avatar
  • 141
1 vote
1 answer
46 views

Using \immediate\write18 when lineno package yields spurious text

I am getting spurious text in the output of \immediate\write18 when the lineno package is used. The MWE below yields the following in the file foo.tex: If one comments out the line that includes ...
Peter Grill's user avatar
7 votes
1 answer
266 views

Inconsistent behaviour of \detokenize on macro beginning with "e" or "f"

I need to write to a file the unexpanded LaTeX. The macro \OuputToFile is bascially an \immediate\write18 and works fine with the following: \OuputToFile{\detokenize{$\OuterMacro{\cXXX{X}}$}}% \...
Peter Grill's user avatar
2 votes
1 answer
128 views

merge many txt to one

There are plenty of .txt files and I try to figure a way in Latex to merge all *.txt to one *.txt. I thought about \newread and \newwrite but I don't know if there is a better way or how to start. the ...
IH Pro's user avatar
  • 141
1 vote
1 answer
97 views

Converting data to utf8 in a write

I need to \write (or to \iow_now:Nn) a file containing utf8-encoded text, from a LaTeX file in an encoding that is not necessarily utf8 (for context: one typical use of this is to collect metadata ...
Vincent Beffara's user avatar
0 votes
0 answers
36 views

Tex adding information to txt

Is there any possibility to add Information to a .txt or other type of document? For example I have the following .tex \begin{filecontents*}{Info.tex} @ P & 1 & 60 & 2 & 77 \\ ...
IH Pro's user avatar
  • 141
1 vote
1 answer
48 views

problem creating tex from tex because of missing space

I have saved a name in \Name. It is ABC. So actually I wrote both possibilities this one \immediate\write\file{\read\noexpand\NoFile to \\Name} and this one \immediate\write\file{\read\noexpand\...
IH Pro's user avatar
  • 141
1 vote
1 answer
55 views

tex document creat tex document with special content

I want a *.tex document that create a *.tex that content the following lines: \newread\NoFile \newcounter{AME} \openin\NoFile=V/AME.txt \read\NoFile to \AME \closein\NoFile so I looked up in the ...
IH Pro's user avatar
  • 141
6 votes
1 answer
244 views

How to extract variables from an auxiliary file?

I would like to use an auxiliary file to read and write some information. Context In this case, I am using this auxiliary file to record the widths used in the footnote formatting. Indeed, I want my ...
B Legrand's user avatar
  • 433
1 vote
2 answers
57 views

How to automatically protect all the commands passed in an argument?

I need to write to an auxfile some mathematical formulas. The following MWE does not work: \documentclass{article} \usepackage{amsmath} \newwrite\filehandle \newcommand{\addToFile}[1]{\immediate\write\...
Colas's user avatar
  • 6,872
7 votes
1 answer
464 views

Maximum amount of characters per line in .tex-input files?

According to TeXbook TeX does preprocess files of .tex-input line per line (converting all characters of the line to TeX's internal character-representation-scheme (ASCII or Unicode), truncating ...
Mrs. Marsupial Wallaby's user avatar
3 votes
1 answer
254 views

Suppress filecontents warning if the file is defined before documentclass

I would like to define filecontents blocks before documentclass in my LaTeX document. Is there any way to suppress warning Writing or overwriting file ./filename? My MWE is as follows: \begin{...
TobiR's user avatar
  • 604
3 votes
3 answers
162 views

newwrite out of a table with umlauts

I have a follow-up question on https://tex.stackexchange.com/a/598981/46023 Everything works in the MWE there, but when used in my original example it no longer works (note: originaltable.csv is a ...
cis's user avatar
  • 8,912
3 votes
2 answers
103 views

newwrite and read in with umlauts

I write the file out.csv, which contains umlauts and tried to read it in. How can I make this work? \documentclass[margin=5pt, varwidth]{standalone} \usepackage{pgfplotstable} \pgfplotsset{compat=...
cis's user avatar
  • 8,912
4 votes
2 answers
423 views

LaTeX expansion of number into ordinal suffix

For a project I am working on I want to automatically 'calculate' the ordinal suffix for numbers. I need to calculate ordinals for various numbers, and later also write them to an external file (the ...
G. de Man's user avatar
  • 364
3 votes
1 answer
154 views

Problem with special characters when writing to an external file

The following MWE throws the error Undefined control sequence. Test avec \unhbox \voidb @x \bgroup \let \unhbox \voidb @x \setbo... l.1 ...e\egroup \spacefactor \accent@spacefactor } ? How can I ...
Colas's user avatar
  • 6,872
0 votes
1 answer
39 views

Error when writing \section in an external file

The following MWE throws the error Undefined control sequence. \GenericError ... #4 \errhelp @err@ ... l.9 \immediate\write\fich@sol {\section{Test}} ? What's the problem? \documentclass{...
Colas's user avatar
  • 6,872
0 votes
0 answers
83 views

How to create a TeX variable whose name depends on a parameter

I would like to create multiple \newwrite in my document, for instance: one by chapter. I've tried the following but it doesn't work. I guess, in the end, my question falls back to: giver a parameter #...
Colas's user avatar
  • 6,872
7 votes
3 answers
591 views

How do I \write18 a koma var?

I'm trying to do some shell processing of data that depends on the settings inside the TeX file. To do this I want to \immediate\write18 a command that depends on a \usekomavar, but pdflatex complains ...
bitmask's user avatar
  • 1,215