
테이블 옵션과 함께 xcolor 패키지를 사용하여 내 문서에 대체 색상을 적용하려고 합니다. 내가 아는 한, 서문에서 교대 색상을 정의하는 것이 가능하므로 이 색상은 다음의 모든 테이블에 적용됩니다.
하지만 이런 식으로 사용하면 동일한 테이블 색상을 얻을 수 없습니다. 이 접근 방식에서 내가 잘못된 점은 무엇입니까?
\documentclass{scrbook}
\usepackage[table]{xcolor}
\rowcolors{2}{gray}{white}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{|ll|}
\hline
$1_1$ & $1_2$ \\
\hline
$2_1$ & $2_2$ \\
\hline
$3_1$ & $3_2$ \\
\hline
$4_1$ & $4_2$ \\
\hline
\end{tabular}
\end{table}
Text
\begin{table}[h]
\centering
\begin{tabular}{|ll|}
\hline
$1_1$ & $1_2$ \\
\hline
$2_1$ & $2_2$ \\
\hline
$3_1$ & $3_2$ \\
\hline
$4_1$ & $4_2$ \\
\hline
\end{tabular}
\end{table}
\end{document}
답변1
이 시도:
\documentclass{scrbook}
\usepackage[table]{xcolor}
\rowcolors{2}{gray}{white}
\let\oldtabular\tabular
\def\tabular{\global\rownum=0\relax\oldtabular}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{|ll|}
\hline
$1_1$ & $1_2$ \\
\hline
$2_1$ & $2_2$ \\
\hline
$3_1$ & $3_2$ \\
\hline
$4_1$ & $4_2$ \\
\hline
\end{tabular}
\end{table}
Text
\begin{table}[h]
\centering
\begin{tabular}{|ll|}
\hline
$1_1$ & $1_2$ \\
\hline
$2_1$ & $2_2$ \\
\hline
$3_1$ & $3_2$ \\
\hline
$4_1$ & $4_2$ \\
\hline
\end{tabular}
\end{table}
\end{document}