未分類

tex で行の色を1行ごとに交互につける

投稿日:

色を1行ごとに交互につけるには、\xcolor パッケージを使った上で、\rowcolors コマンドを使って色を指定する。

\usepackage[table]{xcolor}
\begin{document}

\begin{table}
{\rowcolors{2}{blue!80!yellow!50}{blue!90!yellow!20}
\begin{tabular}{ |c|c|c|c| }
\hline
1 & 2 & 3 \\
\hline
A & B & C\\
\hline
1 & 2 & 3 \\
\hline
A & B & C\\
\hline
1 & 2 & 3 \\
\hline
A & B & C\\
\hline
\end{tabular}
}
\end{table}

\end{document}

結果

参考

下の例では2行目以降の色が交互になる。\rowcolors{1} とすれば、1行目から色が交互になる。

-未分類

執筆者:


comment

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

関連記事

no image

tex で文字列を変数として設定する方法

\newcommand を使って指定する。入力の数は自由に指定できる。 例 \newcommand{\variable}[2]{Hello #1. Good #2.} \variable{Taro}{ …

no image

tex で数式モード内に普通の文字列を入力する方法

\textrm を使う。 例 $$y = f (x) \hspace{1cm} \textrm{This is a function.}$$ 結果

no image

matplotlib で x, y軸・タイトルのフォントサイズを調整する

ラベルの fontsize で指定する。 例 import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 2, 100) …

no image

python3 でリストの偶数番目・奇数番目の項目を出力する

リストに対して、::2 を使えば良い。 例 list1 = [‘日’,’月’,’火’,’水’,’木’,’金’,’土’] list2 = list1[::2] list3 = list1[1::2] p …

no image

tex で打ち消し線を入力する方法

次のように入力すればよい。打ち消し線は、英語で strikethrough と呼ぶ。 例 \usepackage[normalem]{ulem} \begin{document} Good \sout …