General ⇒ \write curly brace
-
stringkarma
- Posts: 7
- Joined: Tue Jun 23, 2009 10:59 pm
\write curly brace
I am trying to write a line to a text file (not unlike creating the aux file). I want to write out the line:
PageProps = {
to a file.
I can write:
PageProps =
or:
PageProps = {}
but if I try what I want, I get an error because of unbalanced braces.
Try it out with this
\newwrite\outputstream
\immediate\openout\outputstream=document.pdf.info
\immediate\write\outputstream{PageProps = { }
note that \{ doesn't seem to do it.
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
-
josephwright
- Site Moderator
- Posts: 814
- Joined: Tue Jul 01, 2008 2:19 pm
\write curly brace
Code: Select all
\immediate\write\outputstream{PageProps = \string{ \string} }-
stringkarma
- Posts: 7
- Joined: Tue Jun 23, 2009 10:59 pm
Re: \write curly brace
Is there some way of doing this?
-
josephwright
- Site Moderator
- Posts: 814
- Joined: Tue Jul 01, 2008 2:19 pm
\write curly brace
Code: Select all
\newwrite\outputstream
\immediate\openout\outputstream=document.pdf.info
\begingroup
\catcode`\[ = 1\relax
\catcode`\] = 2\relax
\catcode`\{ = 12\relax
\catcode`\} = 12 \relax
\immediate\write\outputstream[PageProperies = { ]
\endgroup
-
stringkarma
- Posts: 7
- Joined: Tue Jun 23, 2009 10:59 pm
\write curly brace
I have just one more question then. What if I wanted a command to write out a } to the file and close it. I am trying
Code: Select all
\providecommand{\finalizeinfo}[0]{
\begingroup
\catcode`\[ = 1\relax
\catcode`\] = 2\relax
\catcode`\{ = 12\relax
\catcode`\} = 12\relax
\immediate\write\outputstream[ } ]
\endgroup
\immediate\closeout\outputstream
}
Thanks again for all the help!
-
stringkarma
- Posts: 7
- Joined: Tue Jun 23, 2009 10:59 pm
Re: \write curly brace
-
josephwright
- Site Moderator
- Posts: 814
- Joined: Tue Jul 01, 2008 2:19 pm
\write curly brace
Code: Select all
\newwrite\outputstream
\immediate\openout\outputstream=document.pdf.info
\begingroup
\catcode`\[ = 1\relax
\catcode`\] = 2\relax
\catcode`\{ = 12\relax
\catcode`\} = 12 \relax
\gdef\OpenBrace[{]
\gdef\CloseBrace[}]
\endgroup
\immediate\write\outputstream{PageProperies = \OpenBrace }
\immediate\write\outputstream{\CloseBrace}
-
stringkarma
- Posts: 7
- Joined: Tue Jun 23, 2009 10:59 pm