Diagonal strikethrough (to indicate cancellation/simplification)

2,105 views
Skip to first unread message

Peter Cao

unread,
Feb 11, 2011, 8:45:12 AM2/11/11
to MathJax Users
What is the cleanest way to achieve a diagonal strikethrough? I hope
this feature is supported by mathjax.

It is useful primarily to indicate cancellation/simplification through
numerators and denominators of fractions, etc. An absolute must for
my site which is instructional in nature...

Apparently this is one way it is normally done, but this way involves
additional packages...
http://brasserie-seul.com/?Recettes&nr=46

Davide P. Cervone

unread,
Feb 11, 2011, 8:44:18 PM2/11/11
to mathja...@googlegroups.com
The \cancel macro is not currently implemented, but there is an
underlying MathML tag <menclose notation="updiagonalstrike"> that
could be used to accomplish it.

If you add this code

MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var TEX = MathJax.InputJax.TeX;
var MML = MathJax.ElementJax.mml;
TEX.Definitions.macros.cancel =
["myCancel",MML.NOTATION.UPDIAGONALSTRIKE];
TEX.Definitions.macros.bcancel =
["myCancel",MML.NOTATION.DOWNDIAGONALSTRIKE];
TEX.Parse.Augment({
myCancel: function (name,notation) {
var mml = this.ParseArg(name);
this.Push(MML.menclose(mml).With({notation:notation}));
}
});
});

just after the MathJax.Hub.Config() call (either in-line or in your
config/MathJax.js file), this will define \cancel and \bcancel. See
if that works for you. Unfortunately, there is no current way to get
cancelation arrows (the MathML for that hasn't been implemented yet in
MathJax, but will be in the future).

Davide

Peter Cao

unread,
Feb 12, 2011, 10:58:26 AM2/12/11
to MathJax Users
Would using MathML in this way not introduce with it the audience
restriction as far the need for MathPlayer and Internet Explorer?
I've been avoiding MathML ever since I first heard about it for that
very reason...

Davide P. Cervone

unread,
Feb 12, 2011, 11:02:01 AM2/12/11
to mathja...@googlegroups.com, Peter Cao
No. MathJax's internal format is MathML, and the HTML-CSS output jax
renders that MathML using HTML and CSS. When you use the TeX input
jax, ALL the TeX that you enter is converted to MathML internally.
That is why MathJax is only able to produce things that are
representable in MathML.

Davide

Peter Cao

unread,
Feb 12, 2011, 11:10:20 AM2/12/11
to MathJax Users
Ah, I see now. See that was a breakthrough for me. I've been
concentrating far more on the user end to date and not actually fully
cognaizant of the internal workings; I may learn a bit of JavaScript
in the near future so I can keep up with the technical side of
things.

projetmbc

unread,
Feb 13, 2011, 8:50:44 AM2/13/11
to MathJax Users
Hello,
I would like to change the color of the line used to strike the
expression.

Is it possible ? How can I acheive this ?

Davide P. Cervone

unread,
Feb 13, 2011, 9:22:57 AM2/13/11
to mathja...@googlegroups.com
Assuming that the text color is black and the color for the
strikethrough it red, you could do the following

\color{red}{\cancel{\color{black}{...}}}

You can define a macro to do this, as in

\def\colorcancel#1#2{\color{#1}{\cancel{\color{black}{#2}}}}

which you can add to the TeX block of your configuration:

TeX: {
Macros: {
colorcancel: ["\\color{#1}{\\cancel{\\color{black}{#2}}}",2]
}
}

Davide

projetmbc

unread,
Feb 13, 2011, 9:53:41 AM2/13/11
to MathJax Users
Thanks for all. The following does the job :

====================================================
<html>
<head>
<script type="text/javascript"
src="http://www.mathjax.org/mathjax/MathJax.js">
</script>
<script>
// http://groups.google.com/group/mathjax-users/browse_thread/thread/b6e1479f71244a27
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var TEX = MathJax.InputJax.TeX;
var MML = MathJax.ElementJax.mml;
TEX.Definitions.macros.cancel =
["myCancel",MML.NOTATION.UPDIAGONALSTRIKE];
TEX.Definitions.macros.bcancel =
["myCancel",MML.NOTATION.DOWNDIAGONALSTRIKE];
TEX.Parse.Augment({
myCancel: function (name,notation) {
var mml = this.ParseArg(name);

this.Push(MML.menclose(mml).With({notation:notation}));
}
});
});
MathJax.Hub.Config({
TeX: {
Macros: {
colorcancel: ["\\color{#1}{\\cancel{\\color{black}{#2}}}",2]
}
}
});
</script>
</head>
<body>
<div>
\(\colorcancel{red}{a + 2} = a + 2 + 5\) or \(\bcancel{a +2} = a + 2 +
5\) ...
</div>
</body>
</html>
====================================================

Hylke Koers

unread,
Mar 18, 2011, 12:00:19 PM3/18/11
to MathJax Users
Hi,

I noticed that this code is referring to our local MathJax
installation at www.mathjax.org/mathjax/MathJax.js. If you are still
using this, I'd like to ask you to switch to our CDN service which is
available at http://cdn.mathjax.org/mathjax/latest/MathJax.js

The CDN, which was officially released on March 15, eliminates the
need to download and install the MathJax software. It also offers very
fast download times to readers around the world, and makes it much
easier for authors to keep their pages working with the latest
browsers and devices, since patches and bug fixes will be deployed to
the CDN as soon as they become available. More information on the CDN
release can be found on the blog post
http://www.mathjax.org/2011/03/15/news/mathjax-launches-cdn-service-with-1-1-release/

With the CDN in place, we will no longer maintain our local
installation at www.mathjax.org/mathjax/MathJax.js -- so please switch
to the CDN as soon as you can. Instructions on using MathJax through
the CDN are available at http://www.mathjax.org/docs/1.1/start.html#mathjax-cdn

Hylke




On Feb 13, 3:53 pm, projetmbc <projet...@gmail.com> wrote:
> Thanks for all. The following does the job :
>
> ====================================================
> <html>
>         <head>
>                 <script type="text/javascript"
> src="http://www.mathjax.org/mathjax/MathJax.js">
>                 </script>
>                 <script>
> //http://groups.google.com/group/mathjax-users/browse_thread/thread/b6e...
Message has been deleted

shadow...@gmail.com

unread,
Oct 30, 2014, 12:38:28 PM10/30/14
to mathja...@googlegroups.com
The workaround works for me. Thanks so much for posting it!

Peter Krautzberger

unread,
Oct 30, 2014, 1:33:00 PM10/30/14
to mathja...@googlegroups.com
The cancel macros have since been implemented in an extension -- see http://docs.mathjax.org/en/latest/tex.html#cancel

Peter.

--
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/d/optout.

Reply all
Reply to author
Forward
0 new messages