MathJax and Tex color based on rgb

678 views
Skip to first unread message

gregor.h...@googlemail.com

unread,
Apr 1, 2012, 7:48:48 AM4/1/12
to mathja...@googlegroups.com
Hi, 
MathJax supports the \color tag in text such as \color{red}{eq} but I can't get \color{rgb}{1.0,0.4,0.4} to work. I want to very dark grey. My html color is #333333 and the completely black just stick out as different. Any way to use this color with MathJax?

Thanks!

gregor.h...@googlemail.com

unread,
Apr 1, 2012, 8:07:50 AM4/1/12
to mathja...@googlegroups.com
problem solved, sorry. I was using svg output and changed to HTMLorMML, which uses the same color as the html text...

Davide P. Cervone

unread,
Apr 2, 2012, 10:05:37 AM4/2/12
to mathja...@googlegroups.com
As you have found out, the HTML-CSS output will inherit the font color
if the surrounding text. But the SVG output is not font-based, but
path-based, and SVG paths don't use the color CSS property. You could
set the default color for SVG output using

.MathJax_SVG svg > g,
.MathJax_SVG_Display svg > g {
fill: #333,
stroke: #333
}

for example.

Your \color{rgb}{1.0,0.4,0.4} is incorrect syntax. I think you may
mean to use \DefineColor, but that also requires a new color name, and
doesn't set the current color (you would need to use \color with the
new color name to do that). Finally, note that to use \DefineColor
you need to load the color extension by including

TeX: { extensions: ["color.js"] }

in your configuration. See

http://www.mathjax.org/docs/2.0/tex.html#color

for details.

Davide

On Apr 1, 2012, at 8:07 AM, <gregor.h...@googlemail.com> <gregor.h...@googlemail.com

Roald

unread,
Apr 28, 2012, 7:14:11 AM4/28/12
to MathJax Users
Hi Davide,

I'm having a hard time figuring out how to change the default SVG
color output.

> You could  set the defaultcolorforSVGoutput using
>         .MathJax_SVG svg > g,
>         .MathJax_SVG_Display svg > g {
>           fill: #333,
>           stroke: #333
>         }
> for example.

Where in particular would this be set?
Thanks

On Apr 2, 4:05 pm, "Davide P. Cervone" <d...@union.edu> wrote:
> As you have found out, the HTML-CSS output will inherit the fontcolor
> if the surrounding text.  But theSVGoutput is not font-based, but
> path-based, andSVGpaths don't use thecolorCSS property.  You could
> set the defaultcolorforSVGoutput using
>
>         .MathJax_SVGsvg> g,
>         .MathJax_SVG_Displaysvg> g {
>           fill: #333,
>           stroke: #333
>         }
>
> for example.
>
> Your \color{rgb}{1.0,0.4,0.4} is incorrect syntax.  I think you may
> mean to use \DefineColor, but that also requires a newcolorname, and
> doesn't set the currentcolor(you would need to use \colorwith the
> newcolorname to do that).  Finally, note that to use \DefineColor
> you need to load thecolorextension by including
>
>         TeX: { extensions: ["color.js"] }
>
> in your configuration.   See
>
>        http://www.mathjax.org/docs/2.0/tex.html#color
>
> for details.
>
> Davide
>
> On Apr 1, 2012, at 8:07 AM, <gregor.hochsch...@googlemail.com> <gregor.hochsch...@googlemail.com
>
>
>
>
>
>
>
>  > wrote:
> > problem solved, sorry. I was usingsvgoutput and changed to
> > HTMLorMML, which uses the samecoloras the html text...
>
> > On Sunday, April 1, 2012 7:48:48 AM UTC-4,
> > gregor.h...@googlemail.com wrote:
> > Hi,
> > MathJax supports the \colortag in text such as \color{red}{eq} but
> > I can't get \color{rgb}{1.0,0.4,0.4} to work. I want to very dark
> > grey. My htmlcoloris #333333 and the completely black just stick

David Carlisle

unread,
Apr 29, 2012, 5:13:36 PM4/29/12
to mathja...@googlegroups.com

Davide wrote:

Your \color{rgb}{1.0,0.4,0.4} is incorrect syntax.  I think you may mean to use \DefineColor, but that also requires a new color name,

LaTeX does though support specifying a colour model without defining a new name, but the colour model argument, being optional takes [] rather than {} so  \color[rgb]{1.0,0.4,0.4} would be legal in LaTeX color and would set the colour at that point.

Just as a point of information:-) Not saying that this need necessarily be supported in mathjax.

Davide P. Cervone

unread,
Apr 29, 2012, 5:29:57 PM4/29/12
to mathja...@googlegroups.com
Right, I had not thought of that when I looked at his answer.
MathJax's color extension DOES support \color[rgb]{1.0,0.4,0.4} so
that should work.

Davide

Davide P. Cervone

unread,
Apr 30, 2012, 8:44:53 AM4/30/12
to mathja...@googlegroups.com
The

.MathJax_SVG svg > g,
.MathJax_SVG_Display svg > g {
fill: #333;
stroke: #333
}

is a CSS declaration, so you could include it in your page's CSS
file. (Note, however, that I originally had a comma where there needs
to be a semicolon. I have corrected that in the code above).

Alternatively you can make it part of your MathJax configuration using
something like

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
styles: {
".MathJax_SVG svg > g, .MathJax_SVG_Display svg > g": {
fill: "#333",
stroke: "#333"
}
}
});
</script>

placed in your page BEFORE the script that loads MathJax.js.

Davide
Reply all
Reply to author
Forward
0 new messages