關於 \table 環境內形狀的對齊。如何使表格和圓角矩形居中?

關於 \table 環境內形狀的對齊。如何使表格和圓角矩形居中?
\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有關排版專業品質表格的指導,但也許這更像是矩陣而不是表格?

相關內容