\documentclass[12pt]{article}
\usepackage{lmodern}
\usepackage{pdflscape}
\usepackage{transparent}
\usepackage{iftex}
\usepackage{graphicx}
\usepackage[table]{xcolor}
\usepackage{makecell}
\usepackage[table]{xcolor}
\usepackage{ragged2e}
\usepackage{tikz}
\usepackage{tikzpagenodes}
\usepackage[left = 0.5in, right = 0.5in, top = 0.5in, bottom = 0.5in]{geometry}
\usetikzlibrary{shapes, arrows, positioning}
\begin{document}
\begin{landscape}
\begin{table}
\centering
\scalebox{4}{
\begin{tabular}{|c|c|c|c|c|c|}
\rowcolor[gray]{0.68}\multicolumn{6}{c}{
\begin{tikzpicture}
\node [draw = none, color = white, fill = gray!50, rounded rectangle, xshift = 0cm, yshift= 3cm] {\scriptsize ABCDEF BEDDDD TTTTTTT P};
\end{tikzpicture}
\vspace*{0.2cm}}\\
\hline
\rowcolor[gray]{0.97}
1 & 2 & 3 & 4 & 5 & 6\\
\hline
\rowcolor[gray]{0.97} 7 & 8 & 9 & 10 & 11 & 12 \\
\hline
\rowcolor[gray]{0.97}13 & 14 & 15 & 16 & 17 & 18\\
\hline
\rowcolor[gray]{0.97}19 & 20 & 21 & 22 & 23 & 24 \\
\hline
\rowcolor[gray]{0.97}25 & 26 & 27 & 28 & 29 & 30\\
\hline
\end{tabular}}
\end{table}
\end{landscape}
\end{document}
答案1
后面有一个多余的空格tikzpicture
,导致居中不准确。只需删除该空格即可:
\begin{tikzpicture}
\node [color = white, font=\scriptsize, fill = gray!50, rounded rectangle, yshift= 3cm] {ABCDEF BEDDDD TTTTTTT P};
\end{tikzpicture}%
但是,不建议使用\scalebox
。最好改变字体大小,特别是当您使用提供光学尺寸的字体时。
例如,
\centering
\LARGE
\begin{tabular}{|c|c|c|c|c|c|}
\rowcolor[gray]{0.68}\multicolumn{6}{c}{
\begin{tikzpicture}
\node [color = white, font=\small, fill = gray!50, rounded rectangle,align=center, yshift= 3cm] {ABCDEF BEDDDD TTTTTTT P};
\end{tikzpicture}%
\vspace*{0.2cm}}\\
\hline
\rowcolor[gray]{0.97}
1 & 2 & 3 & 4 & 5 & 6\\
\hline
\rowcolor[gray]{0.97} 7 & 8 & 9 & 10 & 11 & 12 \\
\hline
\rowcolor[gray]{0.97}13 & 14 & 15 & 16 & 17 & 18\\
\hline
\rowcolor[gray]{0.97}19 & 20 & 21 & 22 & 23 & 24 \\
\hline
\rowcolor[gray]{0.97}25 & 26 & 27 & 28 & 29 & 30\\
\hline
\end{tabular}
您可能还希望查看booktabs
有关排版专业质量表格的指导,但也许这更多的是矩阵而不是表格?