Questions tagged [write]

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

Filter by
Sorted by
Tagged with
3
votes
2answers
76 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 ...
3
votes
1answer
51 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 ...
0
votes
1answer
23 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{...
0
votes
0answers
41 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 #...
7
votes
3answers
509 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 ...
1
vote
1answer
23 views

Writing properly escaped strings to a file

I have to write a properly (as in JSON or Javascript) escaped string to a file. My minimal example is \documentclass{standalone} \begingroup \catcode`<=1 \catcode`>=2 \catcode`{=12 \catcode`}=...
7
votes
2answers
131 views

\selectlanguage pushes section to new page

The following code \documentclass{article} \usepackage{kantlipsum} \usepackage[ngerman,english]{babel} \begin{document} \section{Foo} \kant[1] \begin{itemize} \item \item \item \item \item \end{...
1
vote
1answer
38 views

Problem writing to file through \directlua in a memoir class document

Below is a minimal example of some code where the memoir class seems to collide with Lua code, executed within a \directlua command, that writes to an external file. Can anyone help me figure out the ...
0
votes
0answers
27 views

changing from two columns to a single column in the same template

I'm using a two column latex template for Digital signal processing journal (Elsevier), and during writing i want to use a page as single column to put large images. How to change from two columns to ...
1
vote
1answer
38 views

How can I use \iow_now:Nx with umlauts/unicode?

I do some file writing with expl3 but also need the Nx version, which collides with the usage of umlauts. The Nn version handles the umlauts correctly but doesn’t expand the token list for writing it ...
0
votes
2answers
24 views

Show reference at begin of document with conditions

I'd like to show some reference at begin of document with some conditions. Here is the example code \documentclass{article} \usepackage{hyperref} \newcounter{ctest} \setcounter{ctest}{0} \...
0
votes
1answer
43 views

Biblatex: Writing the output of \thefield{…} to a file

Short question: in Biblatex, how do I print the (string) field contents to a file? When processing an entry I would like to do something like this: \write\file{\thefield{userc}}% the file contents ...
0
votes
1answer
29 views

Table with foreachloop as writeout in a external textfile

I create a table with 2 foreach-loops. Now I would like to have that as a textfile too. But there are some if-decision. How to use newwrite correctly here? \documentclass[]{article} \usepackage{tikz} ...
2
votes
2answers
47 views

How to use % inside \write18 command?

I'm doing this: \documentclass{article} \begin{document} \write18{echo '100%' > hash.tex} \input{hash.tex} \end{document} However, this doesn't work (doesn't compile). What is the workaround?
0
votes
1answer
40 views

newwrite: Adding text to a existing outfile

I have \documentclass[a4paper]{article} \begin{document} \newwrite\myoutfile \immediate\openout\myoutfile=\jobname-myoutfile.txt \immediate\write\myoutfile{ aaa } \immediate\closeout\myoutfile \...
0
votes
0answers
70 views

Writing to custom ouput file with lualatex: Hook to start of the writing process and substitute not-fully expandable macros

I am working on writing document with informations, that are at the end of each part summarized in summary. To prevent writing them twice, I am using datatool to create "buffers" in runtime, from ...
0
votes
1answer
29 views

Failing to write to file and input the same

\documentclass{minimal} \usepackage{etoolbox} \newwrite\tempfile \makeatletter \let\features\@gobble \makeatother \newcommand{\feature}[1]{% \expandafter\def\expandafter\features\expandafter{\...
2
votes
1answer
253 views

Verbatim write in Plain TeX

I am trying to write verbatim text into a file in Plain TeX. In LaTeX I could use the verbatim package. My goal is using Asymptote in Plain TeX. So I need something that works like \verbatim@start ...
0
votes
1answer
20 views

\newwrite, pgfplotstable: Put generated rows together to one pgfplotstable (follow-up question)

I get a Code from @egreg that create rows in outwritten textfiles in a loop. I need to put all these rows together in 1 pgfplotstable, that means something like \ifnum\the\filecount=1 \...
1
vote
2answers
42 views

\write and pgfplotstable: Adding \pgfplotstableread into \loop goes wrong

I get a code from @DavidCarlisle, that generate output-txt-files, and I want to put all the outputfiles in a pgfplotstable together. So I try adding \ifnum\the\filecount=1 \pgfplotstableread[col sep=...
1
vote
1answer
89 views

Writing expanded macro with space to file

I'm trying to write an expanded macro to a file without the expansion eating the space after it. I could replace the {} empty group with an explicit \space, but I want this to be fairly robust. Is ...
2
votes
1answer
198 views

Verbatim LaTeX content of an environment exported to an external file

Is there a way to export the content of an environment to an external file without blocking the action of the environment ? Typically in the following example, I would like to keep the content of the ...
1
vote
1answer
53 views

How to \write content with backslashes to a file?

The following MWE works as I expect but when I make certain changes I get errors: If I introduce say \textbf{something} within a \solution{} say \solution{\textbf{xx}}. If I change \theenumi to \...
1
vote
2answers
60 views

Writing into a file, strange behavior with expansion

I want to write some data into a file, but I need to replace a subtring in these data beforehand. For some reason, the expansion through the \write macro does not give the expected result. Instead, a ...
1
vote
1answer
73 views

writing functions and wrapping commands for abstraction

Can i write a little function (or macro or whatever) that wraps two commands (functions?) into one; united under a single alias? Specifically I want to wrap \input{} and \includegraphics{} into a ...
0
votes
1answer
102 views

Directly input a sage file in a sagetex block

Is there a command similar to \lstinputlisting with sagetex, which would import directly a .sage file in the relevant block, and have it evaluated by sagetex? If not, how would one write such a ...
0
votes
1answer
62 views

Add created parameters in child file to main.tex

My code/idea from 2 topics: Input a parameter from another file filecontents: select rows of group to display File parameters.tex: \documentclass{article} \usepackage[utf8]{vietnam} \usepackage{...
2
votes
1answer
56 views

`\unexpand\expandafter` add spaces : how to append a text at the end of a file

I'd like to append code to a file containing latex code... So I tried the solution proposed here, but unfortunately it fails when there are backslash in the file: How can I open a file in "append&...
0
votes
0answers
50 views

Tutorial: Low-Level Basic Implementation of an Asynchronous Table of Contents?

Closely Related: - Mimicking LaTeX's "table of contents" functionality Using documentclass{minimal}, what is the shortest way to write a low-level asynchronous Table of Contents, (...
2
votes
1answer
82 views

Write file content obeying whitespace using expl3

I want to create a control sequence using expl3 to write file content while obeying whitespace. So far I have the following MWE which does write to file, but ignores whitespace. \documentclass[]{...
5
votes
2answers
1k views

\immediate\write with plain text

I have read the question in TeX.SE, but I don't want user to add ^^J manually. That is, I want writer to output content originally. \documentclass{article} \begin{document} \newwrite\file \immediate\...
0
votes
1answer
87 views

remove space after writing a command when using \write

I'm writing a macro to write commands to a file. These commands are supposed to be read when building my document. The lines I use to write to the file is : \newwrite\outtest \immediate\openout\...
1
vote
1answer
71 views

Is this possible to fix this requirement (explain briefly in this question)?

My code is as follows: \documentclass{book} \usepackage{lipsum} \begin{document} blah blah blah blah blah blah \lipsum[1-2] \begin{figure} \includegraphics{...eps} \caption{caption text} \end{...
0
votes
0answers
108 views

Get path of (custom) auxiliary file when `-output-directory` flag is given to pdflatex

In short: Say the following is built using pdflatex -output-directory=tmp: \documentclass{article} \newwrite\fileHandle \immediate\openout\fileHandle=outfile.csv \immediate\write\fileHandle{hello ...
2
votes
2answers
66 views

kpfonts error with environ package and \write

Minimum Working Example \documentclass{article} \usepackage{kpfonts} \usepackage{environ} \makeatletter \AtBeginDocument{% \begingroup \newwrite\@bibmeta \immediate\openout\@...
0
votes
2answers
120 views

using \newcommand with \immediate\write inside beamer

I'm trying to write some strings to an external file using the \immediate\write as in the MWE below \documentclass[a4paper,9pt]{beamer} \begin{document} \begin{frame}[plain] %< comment out for ...
-1
votes
2answers
99 views

Re: Lack Of Optional Argument Makes 1st Item Of Environment Get Executed As If It Were Optional Argument

\documentclass{article} \usepackage{verbatim} %\usepackage{fancyvrb} \usepackage{xcolor} \usepackage{xkeyval} %RE: LACK OF OPTIONAL ARGUMENT MAKES 1ST ITEM OF ENVIRONMENT GET EXECUTED AS IF IT WERE ...
2
votes
1answer
163 views

Why does \openout produce output in plain tex when it does not in latex?

This is a follow up question of this question. Why this plain code (from shreevatsar's answer) \newwrite\outfile \openout\outfile\jobname.out \end produce a page but this (equivalent) latex code ...
1
vote
0answers
62 views

\write : maximum lines'

In the ledmac documentation, Peter Wilson wrote that, when writing to the .end file (which stores the endnote), it transforms all spaces to line breaks. We change \newlinechar so that in the ...
2
votes
1answer
60 views

Missing } error from multiple “\immedite\write”s within a foreach loop; the current plot has no coordinates error with gnuplot

I suspect that these errors are coming from a section of code in which I loop through a master data file and restructure it so that I can give the newly made file as an argument to pgfplots. If I ...
2
votes
2answers
218 views

How to perform a replacement on a string before doing a \write?

I'd like to output LaTeX code to a file, with the caveat that all backslashes are doubled (ie, \ is replaced with \\). This output will be consumed by another program. I've adapted egreg's answer ...
2
votes
0answers
177 views

Write fully expanded macros to auxiliary files

Considering the following code snippet: \documentclass{article} \usepackage{xparse} % \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \NewDocumentCommand{\edeftest}{m}{\edef\test{#1}#1} \...
0
votes
0answers
73 views

Write out an unbalanced brace to a file [duplicate]

I want to know if it's possible to write out the line \def\TEMP{ to a file, and then later write } to close the brace-pair in the written file? Essentially I'd like to do; \documentclass{article} \...
3
votes
3answers
897 views

Write accented characters to file using \write

I am trying to output some information to an auxiliary file using \write and among other things I have authors names that often include accented letters. If I use the string explicitly, the accented ...
1
vote
1answer
260 views

How to check if the footnote mark appears on the same page of the footonote text?

For my typesetting purposes I need to check if the "footnote tag" appears in the same page of (the beginning of) the "footnote text". Sometimes indeed, it happens that, e.g., I have the footnote tag ...
2
votes
1answer
40 views

Layout and export URLs

I use LaTeX for technical documentation of test-scenarios of a software system. The idea is as follows: I write a test scenario in LaTeX. In this test-scenario, I use pieces of data that are ...
0
votes
1answer
98 views

\write command generates “incomplete \iffalse” error

I'm using LaTeX to generate a 100 pages document. Every page is basically a different randomly generated identity. At the end of every page, I use the \write command to write some datas that I ...
1
vote
4answers
769 views

How to use color and symbol at the same time?

How can I write in LaTeX, for example: \sanela{} but in red color? I typed \verb|\sanela|\{\} but it seems like a lot to type? How to add color red here?
8
votes
1answer
240 views

Write dynamic command name to an auxiliary file

I have a collection of latex documents. I want to output some latex commands to an auxiliary file corresponding to each document. All these aux files will be later used (along with their TOCs) to ...
9
votes
1answer
220 views

TeX's \write command sometimes induces a spurious vertical space

in the process of debugging a problem with FiXme (reported by Lars Madsen), I fell on this issue which I'm afraid is beyond my expertise. Consider the following MWE: \documentclass{memoir} \...