未分類

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

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

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

no image

python3 で文字列のリストを結合して1つの文字列にする方法

リストに対して、join メソッドを実行する。 例 list1 = [‘hello, ‘,’good ‘, ‘morning’] str1 = ”.join(list1) print(str1) 結 …

no image

tex で文字を上付きにした矢印を入力する方法

\overset を使う方法がある。 例 $\overset{\text{abc}}{\rightarrow}$ 結果

no image

python3 でカンマの入った数値の文字列を数値に変換する方法

replace と int 変換を組み合わせる。 例 str1 = ‘1,234,567’ int1 = int(str1.replace(‘,’,”)) print(int1) 結果 123456 …

no image

python3 でクラスの初期化を __init__ で行う

python でクラスのオブジェクトを生成したとき、__init__ メソッドが呼び出される(コンストラクタ)__init__ の引数には自身(self)を指定することが通例。一方、オブジェクト破棄の …