简体   繁体   English

使用textcolor时,如何配置MathJax以识别方程式中的textrm {}?

[英]How can configure MathJax to recognize textrm{} in equation when using textcolor?

I'm trying to make an HTML page from LaTEX document that recently achieve it, I used the following mathjax, script configuration, after the head tag: 我试图用最近实现的LaTEX文档制作一个HTML页面,我在head标签之后使用了以下mathjax,脚本配置:

<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>    
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX", "output/HTML-CSS"],

  tex2jax: {
    inlineMath: [ ['$','$'], ["\\(","\\)"] ],
    displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
    processEscapes: true
  },
    "HTML-CSS": { fonts: ["TeX"] }
  });
</script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    "HTML-CSS": { 
      styles: {".MathJax": {color: "#FF0000 ! important"}} 
    }
  });                 

  MathJax.Hub.Queue(
    ["resetEquationNumbers",MathJax.InputJax.TeX],
    ["PreProcess",MathJax.Hub],
    ["Reprocess",MathJax.Hub]
 );
</script>

When I try to write the following equation: 当我尝试编写以下方程式时:

\[
\det A=|A|=\left\{
\begin{array}{ll}
-\textrm{fixation d'une  \textcolor{red}{ligne:}} i=\color{red}{p} \Rightarrow |A|=(-1)^{\color{red}{p}+j}\Delta_{\color{red}{p}j}\\
-\textrm{fixation d'une colonne:  } j=\color{red}{p} \Rightarrow |A|=(-1)^{\color{red}{p}+i}\Delta_{i\color{red}{p}}
\end{array}
\right.
\]

The command textcolor{red} doesn't work. 命令textcolor{red}不起作用。 What can I do it with MathJax to configure it in order to get a colorful text in equation? 我如何使用MathJax对其进行配置,以使其在方程式中获得彩色文本?

This is the result of my compilation: 这是我编译的结果:

我的编辑画面

As per the documentation , MathJax does does not focus on textmode and only allows the following within its text-mode macros ( \\text{} etc): $ for re-entering math mode, \\ref and \\eqref . 根据文档 ,MathJax不专注于文本模式,仅允许在其文本模式宏( \\text{}等)中执行以下操作: $用于重新进入数学模式, $ \\ref\\eqref

So there is no way to get anything like \\textcolor inside \\text to work. 因此,没有办法使\\textcolor内的\\text \\textcolor类的东西起作用。

However, you can wrap \\color around \\text to color the text and thus you could define a custom macro \\textwithcolor{red}{some text mode} , eg, by using $\\require{color}\\newcommand{\\textwithColor}[2]{\\color{#1}{\\text{#2}}} \\textwithColor{red}{halleo}$ . 但是,您可以将\\color包裹在\\text周围\\textwithcolor{red}{some text mode} \\text着色,从而可以定义自定义宏\\textwithcolor{red}{some text mode} ,例如,通过使用$\\require{color}\\newcommand{\\textwithColor}[2]{\\color{#1}{\\text{#2}}} \\textwithColor{red}{halleo}$

You would still need to drop out of text mode to use it. 您仍然需要退出文本模式才能使用它。

FWIW, there is an open issue for MathJax v3 to reconsider macros within text mode. FWIW, MathJax v3在文本模式下重新考虑宏存在一个未解决的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM