TeX Macro with Number

36 views
Skip to first unread message

Dominic Prakash

unread,
Aug 20, 2012, 4:22:48 AM8/20/12
to mathja...@googlegroups.com

In few of our legacy documents there are few TeX macros defined as \user1 and \user2.

Macros: {
      userx: ['\\pmb{#1}',1],
      user1: ['\\pmb{#1}',1],
       nulldelimiterspace: '0pt',
    }
In macros the "user1" doesnt have any effect. It doesnt give any errors either.

One other issue is in our TeX file \kern -\nulldelimiterspace. How to I define them in MathJax. If it is not possible with MathJax then I have to write a pre-process function to convert then before giving them view.

Regards
Dominic

David Carlisle

unread,
Aug 20, 2012, 8:25:00 AM8/20/12
to mathja...@googlegroups.com
On 20 August 2012 09:22, Dominic Prakash <ju...@dlink.org> wrote:
>
> In few of our legacy documents there are few TeX macros defined as \user1
> and \user2.

Unless you have a very non-standard TeX setup you can not define
macros with numbers in their name.
If by "legacy document" you mean existing TeX documents then almost
certainly \user1 and \user2 will be the macro \user taking arguments 1
and 2 respectively. (It is possible in TeX to define digits such that
they are allowed in macro names, but then they may not be used as
digits in numbers or lengths etc.)

David

Davide P. Cervone

unread,
Aug 20, 2012, 9:39:03 AM8/20/12
to mathja...@googlegroups.com
David beat me to it, as I was going to say essentially the same
thing. I think what you want is

Macros: {
user: ['\\pmb{#1}',1]
}

so that \user1 will get you a bold 1, and \user2 will get you a bold
2. You might be better off using \boldsymbol rather than \pmb as the
result will generally look better, although there are some symbols
that don't have a bold form in the MathJax fonts, so perhaps that is
why you use \pmb.

Also note that the last entry in your Macros block should NOT have a
comma after it, as that will confuse some versions of IE.

As for \nulldelimiterspace, see

https://groups.google.com/d/topic/mathjax-users/YZah00dYI1Y/discussion

You can add a prefilter to the TeX processing via

<script type="text/x-mathjax-config">
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
MathJax.InputJax.TeX.prefilterHooks.Add(function (data) {
data.math = data.math.replace(/\\kern *-\\nulldelimiterspace/g,"");
});
});
</script>

(place this BEFORE the script that loads MathJax.js itself). This
will remove all the \kern -\nulldelimiterspace references in your TeX
equations before processing them.

Davide

Dominic Prakash

unread,
Aug 21, 2012, 1:20:26 AM8/21/12
to mathja...@googlegroups.com
Thanks lot both David(s),

With the same "data.math.replace" function I was able to replace the \user2 with \pmb.It works great now.

data.math = data.math.replace(/\\user2/g,"\\pmb");

Best Regards
Dominic
Reply all
Reply to author
Forward
0 new messages