以下代码片段在方程数组环境中给出后续渲染:
F\left[C^{(n-k)}_{P_{ji}}\right]
但当我给代码片段添加颜色时(使用颜色包)如下(在此处添加换行符以方便阅读)在同样的环境下我遇到了以下一些不愉快的事情:
\color[rgb]{0.000,0.000,1.000}F\left[\color[rgb]{0.000,0.750,0.000}C
\color[rgb]{0.000,0.750,0.000}^{(n-k)}\color[rgb]{0.750,0.750,0.000}
_{P_{ji}}\color[rgb]{0.000,0.000,1.000}\right]
^
无论我是否在and之前_
或后续 s 内包含上标和下标的颜色代码,我都会得到这个{}
。
1我为何会得到这种差异?
2我可以使用这些包轻松地在我的代码中更正它吗?
3这是一个错误吗?
以下是完整的文档以供说明:
\documentclass[fleqn,10pt]{article}
\newcommand\independent{\protect\mathpalette{\protect\independenT}{\perp}}
\def\independenT#1#2{\mathrel{\rlap{$#1#2$}\mkern2mu{#1#2}}}
\usepackage{color}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{eqnarray}
F\left[C^{(n-k)}_{P_{ji}}\right]
\end{eqnarray}
\begin{eqnarray}\color[rgb]{0.000,0.000,1.000}F\left[\color[rgb]{0.000,0.750,0.000}C\color[rgb]{0.000,0.750,0.000}^{(n-k)}\color[rgb]{0.750,0.750,0.000}_{P_{ji}}\color[rgb]{0.000,0.000,1.000}\right]\end{eqnarray}
\end{document}
答案1
一条\color
指令插入了一个空的数学公式,这使得下标无法附加到前面的原子。
\mathcolor
尽可能使用。
\documentclass{article}
\usepackage{xcolor}
\begin{document}
\begin{equation}
F\left[C^{(n-k)}_{P_{ji}}\right]
\end{equation}
\begin{equation}
\color[rgb]{0.000,0.000,1.000}F\left[
\color[rgb]{0.000,0.750,0.000}C
^{\mathcolor[rgb]{0.000,0.750,0.000}{(n-k)}}
_{\mathcolor[rgb]{0.750,0.750,0.000}{P_{ji}}}
\color[rgb]{0.000,0.000,1.000}
\right]
\end{equation}
\end{document}
永远不要使用eqnarray
:参见eqnarray 与 align