How to put escaped curly braces inside text

780 views
Skip to first unread message

Björn Peemöller

unread,
Dec 18, 2013, 5:52:12 AM12/18/13
to mathja...@googlegroups.com
Hi,

is there a way to escape curly braces inside the \text command? I want

$$\text{Look at the \{braces\}.}$$

to be rendered as

Look at the {braces}.

but I get

Look at the \{braces\}.

I know that I can achieve this in MathJax by omitting the backslashes,
but I generate both a PDF via LaTeX and a HTML file from Markdown using
pandoc, so I need a result that works both for LaTeX and MathJax.

The work around I found for now is

$$\text{Look at the }\mathtt{\{}\text{braces}\mathtt{\}}\texttt{.}$$

but that is far from ideal, I think. [Issue 349] mentions the escaping
of the dollar sign, maybe it is possible to also add escaping of braces?

Regards,
Bjᅵrn

[Issue 349]: https://github.com/mathjax/MathJax/issues/349

Victor Ivrii

unread,
Dec 18, 2013, 6:01:05 AM12/18/13
to mathja...@googlegroups.com
Björn

[Issue 349]: https://github.com/mathjax/MathJax/issues/349



You need to remember that MathJax is not a LaTeX and does not work in text mode. You are trying to create a really bad LaTeX and a really bad html. First, you need to look at switches in pandoc and to try to run pandoc in the modes which make good LaTeX and good html. Second, according  my experience with pandoc converting markdown files to latex cleaning resulting tex file either by some extra scripts or manually is required if one wants a decent tex file.

HTH. Victor

 

Björn Peemöller

unread,
Dec 18, 2013, 10:39:54 AM12/18/13
to mathja...@googlegroups.com
Am 18.12.2013 12:01, schrieb Victor Ivrii:
>
> You need to remember that MathJax is not a LaTeX and does not work in
> text mode. You are trying to create a really bad LaTeX and a really bad
> html. First, you need to look at switches in pandoc and to try to run
> pandoc in the modes which make good LaTeX and good html.

I agree with you that pandoc should produce correct MathML-LaTeX code,
but I won't bother if MathJax would recognize at least the following
escape sequences inside \text: \& \% \$ \# \_ \{ \}.

Note that \$ is already recognized and this change would need only three
lines to differ:

diff --git a/unpacked/jax/input/TeX/jax.js b/unpacked/jax/input/TeX/jax.js
index f0b85ae..d2ee4d4 100644
--- a/unpacked/jax/input/TeX/jax.js
+++ b/unpacked/jax/input/TeX/jax.js
@@ -1963 +1963 @@
- if (!text.match(/\\?\$|\\\(|\\(eq)?ref\s*\{/)) {return
[this.InternalText(text,def)]}
+ if (!text.match(/\\?(&|%|\$|#|_|\{|\})|\\\(|\\(eq)?ref\s*\{/))
{return [this.InternalText(text,def)]}
@@ -1991,2 +1991,2 @@
- } else if (c === '$' && match === '') {
- i--; text = text.substr(0,i-1) + text.substr(i); //
remove \ from \$
+ } else if ("&%$#_{}".indexOf(c) != -1 && match === '') {
+ i--; text = text.substr(0,i-1) + text.substr(i); //
remove \ from \c

Regards,
Bj�rn

Peter Krautzberger

unread,
Feb 12, 2014, 4:34:59 PM2/12/14
to mathja...@googlegroups.com
Hi Bjoern,

You might want to file a feature request on https://github.com/mathjax/MathJax/issues. Not that it means this will be implemented, but that's where clear cut feature requests should go.

Regards,
Peter.

Björn

--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages