![为什么使用颜色会破坏上标/下标的水平间距?](https://linux22.com/image/303220/%E4%B8%BA%E4%BB%80%E4%B9%88%E4%BD%BF%E7%94%A8%E9%A2%9C%E8%89%B2%E4%BC%9A%E7%A0%B4%E5%9D%8F%E4%B8%8A%E6%A0%87%2F%E4%B8%8B%E6%A0%87%E7%9A%84%E6%B0%B4%E5%B9%B3%E9%97%B4%E8%B7%9D%EF%BC%9F.png)
以下代码片段在方程数组环境中给出后续渲染:
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