单元格中的灰色阴影导致左侧没有空白。有人能帮我解决这个问题吗?
\documentclass[border=5pt]{standalone}
\usepackage{amsmath}
\usepackage[table]{xcolor}
\usepackage{array}
\begin{document}
$\left(\begin{array}{ccccc|r}
1 & 2 & 3 & 4 & 5 &1 \\
0 & 0 & 0 & 0 & 0 & \cellcolor{lightgray}{-1}\\
0 & 0 & 0 & 0 & 0 & \cellcolor{lightgray}{4}\\
0 & 0 & 0 & 0 & 0 & \cellcolor{lightgray} {-2}
\end{array}\right)$
\end{document}
答案1
这个怎么样?
\documentclass[border=5pt]{standalone}
\usepackage{amsmath}
\usepackage[table]{xcolor}
\usepackage{array}
\begin{document}
$\left(\begin{array}{ccccc|lr}
1 & 2 & 3 & 4 & 5 & &1 \\
0 & 0 & 0 & 0 & 0 & &\cellcolor{lightgray}{-1}\\
0 & 0 & 0 & 0 & 0 & &\cellcolor{lightgray}{4}\\
0 & 0 & 0 & 0 & 0 & &\cellcolor{lightgray}{-2}
\end{array}\right)$
\end{document}
答案2
通过使用 填充来解决\columncolor
。
\documentclass[border=5pt]{standalone}
\usepackage{amsmath}
\usepackage[table]{xcolor}
\usepackage{array}
\begin{document}
$\left(\begin{array}{ccccc|>{\columncolor{lightgray}[1mm]}r}
1 & 2 & 3 & 4 & 5 & \multicolumn{1}{c}{1} \\
0 & 0 & 0 & 0 & 0 & -1 \\
0 & 0 & 0 & 0 & 0 & 4 \\
0 & 0 & 0 & 0 & 0 & -2
\end{array}\right)$
\end{document}