下面是我的一个简化的示例表:
代码如下:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{makecell}
\begin{document}
\begin{table}[h]
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
\textbf{CENTER THIS} & \textbf{\makecell[t]{Words \\ are here}} & \textbf{\makecell[t]{Blank \\ \#1}} & \textbf{\makecell[t]{Blank \\ \#2}} & \textbf{\makecell[t]{Blank \\ \#3}} & \textbf{\makecell[t]{Blank \\ \#4}} & \textbf{\makecell[t]{Blank \\ \#5}} & \textbf{\makecell[t]{Blank \\ \#6}} \\
\hline
Words & \makecell[t]{Words \\ are here} & {} & {} & {} & {} & {} & {} \\
\hline
Words & \makecell[t]{Words \\ are here} & {} & {} & {} & {} & {} & {} \\
\hline
\end{tabular}
\end{table}
\end{document}
如何使标有“CENTER THIS”的单元格垂直居中?
答案1
托盘\makecell[cc]{Words \\ are here}
:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{makecell}
\begin{document}
\begin{table}[h]
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
\textbf{CENTER THIS}
& \textbf{\makecell[t]{Words \\ are here}}
& \textbf{\makecell[t]{Blank \\ \#1}}
& \textbf{\makecell[t]{Blank \\ \#2}}
& \textbf{\makecell[t]{Blank \\ \#3}}
& \textbf{\makecell[t]{Blank \\ \#4}}
& \textbf{\makecell[t]{Blank \\ \#5}}
& \textbf{\makecell[t]{Blank \\ \#6}} \\
\hline
Words & \makecell[cc]{Words \\ are here} & {} & {} & {} & {} & {} & {} \\
\hline
Words & \makecell[cc]{Words \\ are here} & {} & {} & {} & {} & {} & {} \\
\hline
\end{tabular}
\end{table}
\end{document}
编辑: 从你的评论可以看出,你遵循的是这样的:
\documentclass{article}
\usepackage{makecell}
\begin{document}
\begin{table}[h]
\renewcommand\cellalign{cc}
\begin{tabular}{|*{8}{c|}}
\hline
\textbf{CENTER THIS}
& \textbf{\makecell{Words \\ are here}}
& \textbf{\makecell{Blank \\ \#1}}
& \textbf{\makecell{Blank \\ \#2}}
& \textbf{\makecell{Blank \\ \#3}}
& \textbf{\makecell{Blank \\ \#4}}
& \textbf{\makecell{Blank \\ \#5}}
& \textbf{\makecell{Blank \\ \#6}} \\
\hline
Words & \makecell{Words \\ are here} & {} & {} & {} & {} & {} & {} \\
\hline
Words & \makecell{Words \\ are here} & {} & {} & {} & {} & {} & {} \\
\hline
\end{tabular}
\end{table}
\end{document}
但你可以尝试用tabularray
包来制作这个表。使用它你会得到更简单但更短的代码:
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{table}[h]
\begin{tblr}{hlines, vlines,
colspec={ *{8}{Q[c, m]} },
row{1} = {font=\bfseries}
}
CENTER THIS
& {Words \\ are here} & {Blank \\ \#1}
& {Blank \\ \#2}
& {Blank \\ \#3}
& {Blank \\ \#4}
& {Blank \\ \#5}
& {Blank \\ \#6} \\
Words & {Words \\ are here} & {} & {} & {} & {} & {} & {} \\
Words & {Words \\ are here} & {} & {} & {} & {} & {} & {} \\
\end{tblr}
\end{table}
\end{document}
答案2
\makecell[c]
在该行的其他单元格中使用。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{makecell}
\begin{document}
\begin{table}[h]
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
\textbf{CENTER THIS} & \textbf{\makecell[c]{Words \\ are here}} & \textbf{\makecell[c]{Blank \\ \#1}} & \textbf{\makecell[c]{Blank \\ \#2}} & \textbf{\makecell[c]{Blank \\ \#3}} & \textbf{\makecell[c]{Blank \\ \#4}} & \textbf{\makecell[c]{Blank \\ \#5}} & \textbf{\makecell[c]{Blank \\ \#6}} \\
\hline
Words & \makecell[t]{Words \\ are here} & {} & {} & {} & {} & {} & {} \\
\hline
Words & \makecell[t]{Words \\ are here} & {} & {} & {} & {} & {} & {} \\
\hline
\end{tabular}
\end{table}
\end{document}