#author("2021-02-18T17:37:46+09:00","default:Miyashita","Miyashita") #author("2021-02-18T17:38:14+09:00","default:Miyashita","Miyashita") *表 table メモ [#i556c33c] #contents **基本形 [#yc6eeced] #codeprettify(lang-tex){{ \begin{table}[tb] % top, bottom % \caption{キャプション} \label{tab:1} \centering \begin{tabular}{|c|c|c|} \hline 11 & 12 & 13 \\ \hline 21 & 22 & 23 \\ \hline \end{tabular} % \end{table} }} \begin{center} は古いもので,\centering にすべきらしい.~ #codeprettify(lang-tex){{ \begin{tabular}{|c|c|c|} \hline }} の|と\hlineがそれぞれ縦罫線と横罫線を表す. \hline\hlineとすれば二重線.~ ~ 参考:[[LaTeX 表組 - Yamamoto's laboratory>http://www.yamamo10.jp/yamamoto/comp/latex/make_doc/table/table.php]] ~ **幅の指定 [#s0c78caa] #codeprettify(lang-tex){{ \begin{tabular}{ccc} }} など c,r,l (それぞれ中央,右,左寄せ)で指定すると,セル内の文字数に従って際限なくセル幅が伸びる.~ セル内で改行して折り返したいとき,幅を指定したい時は #codeprettify(lang-tex){{ \begin{tabular}{p{20mm}p{45mm}p{45mm} } }} のように p{幅} とする.~ p にすると左詰め.m, bにするとそれぞれ中央,右寄せ. ~ ~ **横長の表を縦のページに挿入 [#b88b9c92] 原稿自体は縦向きのままで, 横長の表を 90° 回転させた状態で表示したいとき. #codeprettify(lang-tex){{ \usepackage{lscape} }} をプリアンブルに書いて, #codeprettify(lang-tex){{ \begin{landscape} \begin{table}[p] ... \end{table} \end{landscape} }} とする.~ ~ **行,列,セルの塗りつぶし [#qd638b22] #codeprettify(lang-tex){{ \usepackage{colortbl} }} をプリアンブルに書き, #codeprettify(lang-tex){{ \rowcolor[rgb]{0.8,0.8,0.8} % 行全体 \columncolor[rgb]{0.8,0.8,0.8} % 列全体 \cellcolor[rgb]{0.8,0.8,0.8} % セル }} などを使う.~ \rowcolor は行の最初,~ \columncolor は #codeprettify(lang-tex){{ \begin{tabular}{cc>{\columncolor[rgb]{0.8,0.8,0.8} }c} % 3列目だけ着色 }} のように tabular の列の alignment を指定する直前に,~ \cellcolor はセルの最初に挿入する.~ ~ **一部だけを {中央,左,右}寄せに [#u351b735] #codeprettify(lang-tex){{ \begin{tabular}{lll} }} としたけど,例えば1行目だけは中央揃えがいい,という時は対象のセルの中で #codeprettify(lang-tex){{ \multicolumn{1}{c}{中央揃えになるー} }} とする.~ ~ 参考:[[【TeX】tabular環境で特定のセルのみ左揃え(中央揃え、右揃え)をする>http://munibus.hatenablog.com/entry/2015/07/05/182932]] ~ ~ **セル内で改行 [#e6c63bcd] #codeprettify(lang-tex){{ 1行目 \par\noindent 2行目 }} が一番単純?~ できないときはセルの中にもう1回 tabular を入れる. #codeprettify(lang-tex){{ \begin{tabular}{c} 1行目 \\ 2行目 \end{tabular} }} ~ ~ **セル内で文字+図 [#y0469861] セル内で下記ように書く.minipage を使って画像分の領域を確保する. セル内で下記のように書く.minipage を使って画像分の領域を確保する. #codeprettify(lang-tex){{ ここに文字を挿入,改行して図を入れよう!\par\noindent \begin{minipage}{\linewidth} \centering \includegraphics[width=\linewidth]{figfig.png} \end{minipage} }} ~ ~ **scaleboxで大きさの調整 [#h60c5acc] (フォーマットが統一的でなくなるので)使いたくはないけど,どうしようもない時に全体を縮小する方法.~ 文字が小さくなっても良ければ #codeprettify(lang-tex){{ \scalebox{0.9}{ % 0.9倍に \begin{tabular}{ccc} \hline 11 & 12 & 13 \\ 21 & 22 & 23 \end{tabular} } }} のようにtablularをscaleboxで囲む.