次の表で問題が発生します。
\begin{table}[H]
\newcommand{\ctab}{\centering\arraybackslash}
\definecolor{F1}{RGB}{255,255,255}
\definecolor{F0}{RGB}{210,0,0}
\definecolor{F2}{RGB}{0,176,80}
\resizebox{0.85\textwidth}{!}{\begin{tabular}{|c|c|c|c|c|c|}
\hline
\rule{0pt}{30pt}
\multicolumn{2}{|c|}{\cellcolor{gray!50}\huge{\textbf{a}}} &
%\cellcolor{gray!50}\huge{\textbf{a}} &
%\cellcolor{gray!50}\huge{\textbf{}} &
\cellcolor{gray!50}\huge{\textbf{b}} &
\cellcolor{gray!50}\huge{\textbf{C}} &
\cellcolor{gray!50}\huge{$\mathbf{d}$} &
\cellcolor{gray!50}\huge{$\mathbf{e}$}
\\
\end{tabular}}
\caption{XY}
\label{tab:XY}
\end{table}
問題は複数列にあります。次のように変更すると、
%\multicolumn{2}{|c|}{\cellcolor{gray!50}\huge{\textbf{a}}} &
\cellcolor{gray!50}\huge{\textbf{a}} &
\cellcolor{gray!50}\huge{\textbf{}} &
それは機能します...
問題はどこだ?
ありがとう!
答え1
問題は、 がと同じセル内にあるために\rule
と の組み合わせで発生しています。 を保持したい場合は、別のセルまたは 内に配置します。 適切な間隔だけが必要な場合は、の直後にを挿入します。\multicolumn
\multicolumn
\multicolumn
\strut
\huge
使用方法\rule
:
\documentclass[]{article}
\usepackage[table]{xcolor}
\begin{document}
\begin{table}
\begin{tabular}{|c|c|c|c|c|c|}
\hline
\multicolumn{2}{|c|}{\cellcolor{gray!50}\huge{\textbf{a}}{\rule{0pt}{30pt}}} &
\cellcolor{gray!50}\huge{\textbf{b}} &
\cellcolor{gray!50}\huge{\textbf{C}} &
\cellcolor{gray!50}\huge{$\mathbf{d}$} &
\cellcolor{gray!50}\huge{$\mathbf{e}$}
\\
\hline
f&g&h&i&j&k\\
\hline
\end{tabular}
\caption{XY}
\label{tab:XY}
\end{table}
\end{document}
使用方法\strut
:
\documentclass[]{article}
\usepackage[table]{xcolor}
\begin{document}
\begin{table}
\centering%
\begin{tabular}{|c|c|c|c|c|c|}
\hline
\multicolumn{2}{|c|}{\cellcolor{gray!50}\huge\strut{\textbf{a}}} &
\cellcolor{gray!50}\huge{\textbf{b}} &
\cellcolor{gray!50}\huge{\textbf{C}} &
\cellcolor{gray!50}\huge{$\mathbf{d}$} &
\cellcolor{gray!50}\huge{$\mathbf{e}$}
\\
\hline
f&g&h&i&j&k\\
\hline
\end{tabular}
\caption{XY}
\label{tab:XY}
\end{table}
\end{document}
答え2
\extrarowheight
上部にパディングを追加するために使用できます全てセル(デフォルトの行の高さが狭いことを考えると、贅沢とは言えません)を定義するか、最小限先頭に文字 が付く列内のセルの上部と下部の垂直間隔S
。
コマンドを使用してコードを簡素化し\rowcolor
、\myhead
フォントの変更を含むコマンドを定義しました。最初の行の色を、より見やすいグレーに変更しました。
\documentclass[]{article}
\usepackage{ cellspace}
\usepackage[table, svgnames]{xcolor}
\setlength{\cellspacetoplimit}{4pt}
\setlength{\cellspacebottomlimit}{3pt}
\newcommand{\myhead}[1]{\huge\boldmath\bfseries#1}
\begin{document}
\begin{table}[!htb]
\centering
\begin{tabular}{|*{6}{Sc|}}
\hline
\rowcolor{GhostWhite!80!Gainsboro} \multicolumn{2}{|c|}{\myhead{a}}&
\myhead{b} &
\myhead{C} &
\myhead{$\mathbf{d}$} &
\myhead{$\mathbf{e}$}
\\
\hline
f&g&h&i&j&k\\
\hline
\end{tabular}
\caption{XY}
\label{tab:XYZ}
\end{table}
\end{document}