表格標題中的文字垂直居中

表格標題中的文字垂直居中

我想將表格單元格的內容集中在標題中。在波蘭文文件指南中,表格標題的內容必須水平和垂直居中。我已經發現這樣的答案,但我無法實現它,因為程式碼沒有解釋。我還嘗試了 -type 列的應用m以及它們與命令\multirow[c]{1}{\mycolumnwidth}{My cell content}的一些組合。\multicolumn調整文字高度\multirow{1}{\mycolumnwidth}[\myyshift]{My cell content}不是一個解決方案 - 必須自動執行垂直居中。有一些答案對於 plain TeX,但我想使用tabular或類似的環境。

在此輸入影像描述

微量元素:

\documentclass[table]{standalone}
\usepackage{dcolumn}
\usepackage{multirow}

\newcolumntype{d}{D{.}{.}{2.1}}
\renewcommand{\arraystretch}{1.3}

\begin{document}
    \begin{tabular}{|l|d|d|}
        \hline
        \multicolumn{1}{|c|}{\multirow[c]{1}{23mm}{\centering\textbf{Title of side-heading}}} &
        \multicolumn{1}{>{\centering}p{23mm}|}{\textbf{Arbitrary values}} &
        \multicolumn{1}{>{\centering}p{23mm}|}{\textbf{Some other random values}}\\
        \hline
        Description 1 & 63.5 & 48.7\\
        \hline
        Description 2 & 88.4 & 51.3\\
        \hline
    \end{tabular}
\end{document}

答案1

siunitxmakecell

在此輸入影像描述

\documentclass[table]{standalone}
\usepackage{siunitx}
\usepackage{makecell}
\renewcommand{\theadfont}{\normalsize\bfseries}
\renewcommand{\arraystretch}{1.3}

\begin{document}
    \begin{tabular}{|l|S[table-format=2.1]|S[table-format=2.1]|}
        \hline
        {\thead{Title of\\ side-heading}} &
        {\thead{Arbitrary\\ values}} &
        {\thead{Some other\\ random\\ values}}\\
        \hline
        Description 1 & 63.5 & 48.7\\
        \hline
        Description 2 & 88.4 & 51.3\\
        \hline
    \end{tabular}
\end{document}

相關內容