Writing balanced braces doesn't require anything special, as the following transcript of an interactive TeX session shows:
$ tex
This is TeX, Version 3.1415926 (TeX Live 2011)
**\relax
*\newwrite\mywr
*\immediate\openout\mywr=temp.dat
*\immediate\write\mywr{{}}
*\bye
No pages of output.
Transcript written on texput.log.
$ cat temp.dat
{}
If you want to write unbalanced braces you can do with
\begingroup
\catcode`<=1 \catcode`>=2
\catcode`{=12 \catcode`}=12
\gdef\wbgroup<{>
\gdef\wegroup<}>
\endgroup
\newwrite\mywr
\immediate\openout\mywr=temp.dat
\immediate\write\mywr{\wbgroup}
\immediate\write\mywr{\wegroup}
\bye
that is, using \wbgroup
and \wegroup
for writing open and close brace respectively. The contents of temp.dat
will be
{
}
Notice that LaTeX already has equivalents of \wbgroup
and \wegroup
that are called \@charlb
and \@charrb
, which actually expand to category code 11 characters.
Alternative definitions for \wbgroup
and \wegroup
that expand to category code 12 characters are
\begingroup\lccode`?=`\{ \lccode`!=`\}
\lowercase{\endgroup\def\wbgroup{?}\def\wegroup{!}}
or
\edef\wbgroup{\iftrue\string{\else}\fi}
\edef\wegroup{\iffalse{\else\string}\fi}
If you want to know what is in the aux-file: Open it in an editor and look it up.
Actually every package (and you too) can write something to the aux-file if it want. So the aux-file normally contains quite a lot informations which are very document specific and which would cause troubles in another document.
So if you want to read an external aux-file you must be careful. E.g. an aux-file contains lines which should be written to the toc-file (\@writefile{toc}
) which you don't want to process in this case. The xr-package mentioned by Boris e.g. loops through external aux
-files and looks for \newlabel
commands but ignores everything else.
Best Answer
When dealing with UTF-8 coded document, one must keep in mind that characters are encoded by sequences of one to four bytes and that traditional TeX engines (including
pdftex
) are not able to directly interpret multibyte characters.Thus multibyte clusters are, as soon as possible, translated to the LaTeX Internal Character Representation. This is feasible because in a multibyte cluster the first byte tells about the length of the cluster and so it's not too difficult to compute from this and the following bytes the Unicode point we are faced with; LaTeX maintains a table mapping Unicode points to LaTeX commands. For example, the multibyte cluster that the screen shows as
Ü
gets translated into\IeC{\"U}
.What's the purpose of
\IeC
? When\"U
is found by LaTeX, it tries to expand\"
, which is wrong when writing to an auxiliary file: we want that\chapter{Über}
writes something equivalent toÜber
in the.toc
file and not the complicated sequence of commands needed to print it.Thus
\IeC
: it does nothing during normal typesetting, but when LaTeX is writing to auxiliary files the tokens\IeC{\"U}
are written out literally.If you want to write literally to your own auxiliary files, then this mechanism must be disabled, which can be obtained by protecting the tokens with
\unexpanded
. An example of what you want to obtain should be shown.