LaTeXにおける表作成の基本と応用

表環境の定義

tabulartabular*は類似していますが、tabular*は幅調整が可能です。

\begin{tabular}[position]{columns}
rows
\end{tabular}
\begin{tabular*}{width}[position]{columns}
rows
\end{tabular*}

表をページ中央に配置するにはcenter環境を使用します。

\begin{center}
table contents
\end{center}

表環境のパラメータ

位置指定パラメータ(垂直方向)

パラメータ意味
t表上部と外部テキスト行の基準線を一致
b表下部と外部テキスト行の基準線を一致
未指定表を外部テキスト行の基準線に対して垂直中央配置

列指定パラメータ(必須)

パラメータ意味
l左揃え
r右揃え
c中央揃え
p指定幅で自動改行
|垂直線
||二重垂直線
\*{count}列形式の繰り返し(例: \*{3}{c} → c c c)

行内コマンド

  • \tabularnewline: \\と同等
  • \hline: 行の先頭または\\直後に配置
    • 行先頭: 表上部に水平線
    • \\後: 終了行に水平線
  • \cline{n-m}: n列からm列までの水平線
  • \vline: 行高の垂直線
  • \multicolumn{count}{columns}{text}: 列結合
  • @expression: 列間の空白を置換

スタイルパラメータ

  • \tabcolsep: 列間隔の半分
  • \arrayrulewidth: 罫線の幅
  • \doublerulesep: 二重線の間隔
  • \arraystretch: 行間の拡大率(初期値1)

三線表

booktabsパッケージを使用:

\usepackage{booktabs}
\begin{tabular}{lll}
\toprule
& \multicolumn{2}{c}{基本ツール} \\
\cmidrule{2-3}
OS & ディストリビューション & エディタ \\
\midrule
Windows & MikTeX & TeXstudio \\
macOS & MacTeX & TeXShop \\
共通 & TeX Live & TeXworks \\
\bottomrule
\end{tabular}

複数ページに跨る表

longtableパッケージ

\begin{longtable}{ll}
\multicolumn{2}{r}{(前ページより続き)} \\
\toprule
著者 & 作品 \\
\midrule
\endhead
\caption{長い表の例} \\
\toprule
著者 & 作品 \\
\midrule
\endfirsthead
\bottomrule
\multicolumn{2}{r}{(次ページへ続く)} \\
\endfoot
\bottomrule
\endlastfoot
夏目漱石 & 親譲りの無鉄砲で子供の時から... \\
& 周囲の人間もこれを業平のように... \\
& 当時も今も変らないつもりだが... \\
\end{longtable}

supertabularパッケージ

自動的にページ分割するsupertabular環境を提供します。

表の並列表示

\begin{table}
\begin{minipage}{0.48\textwidth}
\centering
\caption{品質評価表}
\begin{tabular}{|l|l|l|}
\hline
番号 & チャネルID & 品質値 \\
\hline
1 & A & Q1 \\
2 & B & Q2 \\
\hline
\end{tabular}
\end{minipage}
\hfill
\begin{minipage}{0.48\textwidth}
\centering
\caption{システム情報}
\begin{tabular}{|l|l|}
\hline
項目 & 説明 \\
\hline
Channels & 利用可能チャネル数 \\
Users & 現在の利用者数 \\
\hline
\end{tabular}
\end{minipage}
\end{table}

タグ: LaTeX tabular booktabs longtable supertabular

6月11日 19:27 投稿