我的第一行对齐有些问题。我希望所有行都处于同一水平。
我的代码:
\begin{table}[htb]
\centering
\caption{References of Questions}
\begin{tabular}{|p{3cm}|p{20cm}|}
\hline\rowcolor[gray]{0.8}\color{black}
Construct & Source of Questions \\\hline
A & Self-developed. \\\hline
B & Self-developed. \\\hline
B & Self-developed. \\\hline
\end{tabular}
\label{tab:Definitions}
\end{table}
答案1
没有理由发出\color{black}
。尝试将其删除,输出将如预期的那样。
\documentclass{article}
\usepackage[table]{xcolor}
\begin{document}
\begin{table}[htbp]
\centering
\caption{References of Questions}
\label{tab:Definitions}
\begin{tabular}{|p{3cm}|p{8cm}|}
\hline
\rowcolor[gray]{0.8}
Construct & Source of Questions \\
\hline
A & Self-developed. \\
\hline
B & Self-developed. \\
\hline
B & Self-developed. \\
\hline
\end{tabular}
\end{table}
\end{document}
如果您确实需要更改某一p
列的颜色,请在颜色命令前加上\leavevmode
。
\documentclass{article}
\usepackage[table]{xcolor}
\begin{document}
\begin{table}[htbp]
\centering
\caption{References of Questions}
\label{tab:Definitions}
\begin{tabular}{|p{3cm}|p{8cm}|}
\hline
\rowcolor[gray]{0.8}
\leavevmode\color{blue!70}
Construct & Source of Questions \\
\hline
A & Self-developed. \\
\hline
B & Self-developed. \\
\hline
B & Self-developed. \\
\hline
\end{tabular}
\end{table}
\end{document}
笔记
- 永远不要忘记
p
选择 - 最好
\label
将 放置在 附近\caption
。
答案2
\documentclass{article}
\usepackage{xcolor}
\usepackage{tabularray}
\begin{document}
\begin{table}[h]
\caption{References of Questions}
\label{tab:Definitions}
\begin{tblr}
{
colspec = {Q[l,m]X[l,m]},
row{1} = {bg=gray8!60},
hlines,vlines,
}
Construct & Source of Questions \\
A & Self-developed. \\
B & Self-developed. \\
B & Self-developed. \\
\end{tblr}
\end{table}
\begin{table}[h]
\caption{References of Questions}
\label{tab:Definitions}
\begin{tblr}
{
colspec = {Q[l,m]X[l,m]},
row{1} = {bg=gray8!60},
cell{1}{1} = {fg=blue},
hlines,vlines,
}
Construct & Source of Questions \\
A & Self-developed. \\
B & Self-developed. \\
B & Self-developed. \\
\end{tblr}
\end{table}
\begin{table}[h]
\caption{References of Questions}
\label{tab:Definitions}
\begin{tblr}
{
colspec = {Q[l,m]X[l,m]},
row{1} = {bg=gray8!60,fg=blue},
hlines,vlines,
}
Construct & Source of Questions \\
A & Self-developed. \\
B & Self-developed. \\
B & Self-developed. \\
\end{tblr}
\end{table}
\end{document}