General ⇒ \write curly brace
-
- 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.
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
-
- Site Moderator
- Posts: 814
- Joined: Tue Jul 01, 2008 2:19 pm
\write curly brace
Code: Select all
\immediate\write\outputstream{PageProps = \string{ \string} }
-
- Posts: 7
- Joined: Tue Jun 23, 2009 10:59 pm
Re: \write curly brace
Is there some way of doing this?
-
- 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
-
- 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!
-
- Posts: 7
- Joined: Tue Jun 23, 2009 10:59 pm
Re: \write curly brace
-
- 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}
-
- Posts: 7
- Joined: Tue Jun 23, 2009 10:59 pm