dollar sign curly bracket in code, not for mako

830 views
Skip to first unread message

Ben123

unread,
Nov 9, 2011, 9:45:01 AM11/9/11
to Mako Templates for Python
I'm using Mako for a script which needs to include a string
interpreted by LaTeX: '${\cal W}(y,z)$'. However, Mako complains since
the contents of ${} are not recognized as a variable.

I was unable to find anything on this in the Mako documentation
http://www.makotemplates.org/docs/search.html?q=escape+dollar+sign&check_keywords=yes&area=default#

Any advice?


Thanks,

Ben

Michael Bayer

unread,
Nov 9, 2011, 12:18:29 PM11/9/11
to mako-d...@googlegroups.com
You can use <%text> for that, or something like this:

${'$'}{\cal W}(y,z)$

or perhaps clearer:

${'${\cal W}(y,z)$'}

> --
> You received this message because you are subscribed to the Google Groups "Mako Templates for Python" group.
> To post to this group, send email to mako-d...@googlegroups.com.
> To unsubscribe from this group, send email to mako-discuss...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mako-discuss?hl=en.
>

Deron Meranda

unread,
Nov 9, 2011, 1:05:29 PM11/9/11
to mako-d...@googlegroups.com
With Latex you may also be able to use the \(...\) syntax for
math-mode expressions rather than the $...$

\( \cal W}(y,z) \)

(caveat: \(\) is "fragile" whereas $$ is robust, but unless you're
putting formulas in section header names or such you're probably ok)


Also if you're finding so many $'s in your documents that its
confusing, you could also define a mako filter

<%!
def math(text):
return "\begin{math}" + text + "\end{math}"
%>

${" \cal W}(y,z) " |math}

--
Deron Meranda
http://deron.meranda.us/

Ben123

unread,
Nov 9, 2011, 2:12:05 PM11/9/11
to Mako Templates for Python
Thanks for the help. I am now using

${'${\cal W}(y,z)$'}


On Nov 9, 11:18 am, Michael Bayer <mike...@zzzcomputing.com> wrote:
> You can use <%text> for that, or something like this:
>
> ${'$'}{\cal W}(y,z)$
>
> or perhaps clearer:
>
> ${'${\cal W}(y,z)$'}
>
> On Nov 9, 2011, at 6:45 AM, Ben123 wrote:
>
>
>
>
>
>
>
> > I'm using Mako for a script which needs to include a string
> > interpreted by LaTeX: '${\cal W}(y,z)$'. However, Mako complains since
> > the contents of ${} are not recognized as a variable.
>
> > I was unable to find anything on this in the Mako documentation
> >http://www.makotemplates.org/docs/search.html?q=escape+dollar+sign&ch...
Reply all
Reply to author
Forward
0 new messages