Using hex values for colors in LaTex/MathJax

空扰寡人 提交于 2020-01-05 02:59:14

问题


I have a couple variables in my javascript that hold color values, i.e.

var color = #ABCDEF

I'm trying to use these variables to color some text that I have, but it seems that MathJax doesn't support hex color values. Is there anyway to circumvent this in order to use the variable in the \color?


回答1:


You can try \color[HTML]{ABCDEF}.

You need to add \usepackage{xcolor} to the preamble.




回答2:


it seems that MathJax doesn't support hex color values

Sure it does. E.g., \color{#ABCDEF}{x+1} works fine in the standard configurations. You can also load MathJax's color extension to make the \color command more compatible with LaTeX's syntax (thought it doesn't implement the HTML color model suggested by sergej, but does do rgb and several others).

You don't give enough of your code to tell how you intend to use you color variable, but one thing that is wrong is that you have left out the quotation marks:

var color = "#ABCDEF";

The issue now will be how you get this value into the \color command within you math expressions. If you are trying to make all the math on your page be a different color, it would be best to use CSS for that. E.g.,

<style>
  .MathJax {color: #ABCDEF}
</style>

would do it for MathJax's HTML-CSS output.



来源:https://stackoverflow.com/questions/32260914/using-hex-values-for-colors-in-latex-mathjax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!