tag:blogger.com,1999:blog-840127493134277990.post3567186964742670572..comments2023-09-23T10:51:06.332-03:00Comments on Python in Science: New-style String Formatting and LaTeXAnonymoushttp://www.blogger.com/profile/02885581033966597420noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-840127493134277990.post-55743146113951246482009-09-18T00:19:12.168-03:002009-09-18T00:19:12.168-03:00It's not clear to me what you want to do and w...It's not clear to me what you want to do and why it is a problem to escape the curly brackets like Marius suggested. Should you use the % syntax to populate templates on any language where % have special meaning you would run on the exact same problem and have to escape the % too. <br /><br />Escaping the curly brackets on a plain LaTeX snippet is a simple substitution (no manual rewriting Kaohttps://www.blogger.com/profile/13077657840953960081noreply@blogger.comtag:blogger.com,1999:blog-840127493134277990.post-83029019267391696492009-09-02T13:59:50.972-03:002009-09-02T13:59:50.972-03:00Just keep using the % formatting. I still have my ...Just keep using the % formatting. I still have my doubts it will ever go away from the language, and the moment it does you'll have somebody who'll write a module to emulate them.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-840127493134277990.post-83458311365867934802009-09-02T13:53:22.040-03:002009-09-02T13:53:22.040-03:00Maybe instead, generate your table in a plain text...Maybe instead, generate your table in a plain text format (such as the one used by reST or pandoc's enhanced Markdown), and then convert it to LaTeX in another pass?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-840127493134277990.post-67391229644277977722009-09-02T13:04:32.709-03:002009-09-02T13:04:32.709-03:00@Marius: That is a bit of an overkill! having to r...@Marius: That is a bit of an overkill! having to rewrite all your LaTeX statements just to be able to insert a single string!<br />;-)<br /><br />BTW, you don't need to escape backslashes if you use raw strings:<br />>>> r'\begin{article}'<br />'\\begin{article}'Anonymoushttps://www.blogger.com/profile/02885581033966597420noreply@blogger.comtag:blogger.com,1999:blog-840127493134277990.post-54260117037751160132009-09-02T12:24:06.026-03:002009-09-02T12:24:06.026-03:00>>> '\\begin{{{env}}}'.format(env...>>> '\\begin{{{env}}}'.format(env='article')<br /><br />'\\begin{article}'Marius Gedminashttps://www.blogger.com/profile/15155998626202067226noreply@blogger.com