将表头中的文本分成两行

将表头中的文本分成两行

我需要写一个包含数值的表格。我选择使用siunitx进行对齐和四舍五入,这很好。但是,这个标题有点复杂,包含一些数学内容,并且必须指定列单位。这是 MWE

\documentclass{article}
\usepackage{booktabs,booktabs,tabularx,siunitx}
\sisetup{table-auto-round = true} 
\begin{document}
    \begin{table}
        \centering
        \caption{Table MWE}
        \begin{tabular}{
                S[table-format = 1.2]
                S[table-format = 1.4]
                S[table-format = 2.3]
                S[table-format = 1.4]
            }
            \toprule
            \multicolumn{1}{c}{$A_\mathrm{nom}$} &
            \multicolumn{1}{c}{$\frac{\dot{m} C_p \Delta T}{A_\mathrm{nom}}$} &
            \multicolumn{1}{c}{$k$} &
            \multicolumn{1}{c}{$\Delta T$} \\
            \multicolumn{1}{c}{[\si{mm^2}]} &
            \multicolumn{1}{c}{[\si{W/m^2}]} &
            \multicolumn{1}{c}{[\si{W/m.K}]} &
            \multicolumn{1}{c}{[\si{\degreeCelsius}]} \\
            \midrule
            1.55    &   1.12345 &   10.2344     &   0.33122 \\
            1.75    &   2.34567 &   20.8455     &   0.54947 \\
            2.25    &   3.45678 &   30.5666     &   0.86800 \\
        \end{tabular}
    \end{table}
\end{document}

但我不喜欢行与行之间的对齐和垂直分隔。我宁愿有一个拆分单元格,类似于@egreg 在这篇文章中的回答:https://tex.stackexchange.com/a/543235/50886。但是没有用。你们有什么建议吗?欢迎大家发表评论

答案1

这里有很多不同的选项,它们都\thead来自该makecell包。我更改了第二列标题中的分数,以尝试提高可读性:

在此处输入图片描述

\documentclass{article}
\usepackage{booktabs,tabularx,siunitx}
\usepackage{amsmath}
\sisetup{table-auto-round = true} 
\usepackage{makecell}
\renewcommand{\theadfont}{\normalsize}
\begin{document}
    \begin{table}
        \centering
        \caption{Table MWE}
        \begin{tabular}{
                S[table-format = 1.2]
                S[table-format = 1.4]
                S[table-format = 2.3]
                S[table-format = 1.4]
            }
            \toprule
            {\thead{$A_\mathrm{nom}$\\{} [\si{mm^2}]}} &
            {\thead{$\frac{\dot{m} C_p \Delta T}{A_\mathrm{nom}}$\\{} [\si{W/m^2}]}} &
            {\thead{$k$\\{} [\si{W/m.K}]}} &
            {\thead{$\Delta T$\\{} [\si{\degreeCelsius}]}} \\
            \midrule
            1.55    &   1.12345 &   10.2344     &   0.33122 \\
            1.75    &   2.34567 &   20.8455     &   0.54947 \\
            2.25    &   3.45678 &   30.5666     &   0.86800 \\
        \end{tabular}
    \end{table}


    \begin{table}
        \centering
        \caption{Table MWE}
        \begin{tabular}{
                S[table-format = 1.2]
                S[table-format = 1.4]
                S[table-format = 2.3]
                S[table-format = 1.4]
            }
            \toprule
            {\thead{$A_\mathrm{nom}$\\{} [\si{mm^2}]}} &
            {\thead{$\dfrac{\dot{m} C_p \Delta T}{A_\mathrm{nom}}$\\{} [\si{W/m^2}]}} &
            {\thead{$k$\\{} [\si{W/m.K}]}} &
            {\thead{$\Delta T$\\{} [\si{\degreeCelsius}]}} \\
            \midrule
            1.55    &   1.12345 &   10.2344     &   0.33122 \\
            1.75    &   2.34567 &   20.8455     &   0.54947 \\
            2.25    &   3.45678 &   30.5666     &   0.86800 \\
        \end{tabular}
    \end{table}


    \begin{table}
        \centering
        \caption{Table MWE}
        \begin{tabular}{
                S[table-format = 1.2]
                S[table-format = 1.4]
                S[table-format = 2.3]
                S[table-format = 1.4]
            }
            \toprule
            {$A_\mathrm{nom}$ [\si{mm^2}]} &
            {$\frac{\dot{m} C_p \Delta T}{A_\mathrm{nom}}$ [\si{W/m^2}]} &
            {$k$ [\si{W/m.K}]} &
            {$\Delta T$ [\si{\degreeCelsius}]} \\
            \midrule
            1.55    &   1.12345 &   10.2344     &   0.33122 \\
            1.75    &   2.34567 &   20.8455     &   0.54947 \\
            2.25    &   3.45678 &   30.5666     &   0.86800 \\
        \end{tabular}
    \end{table}



    \begin{table}
        \centering
        \caption{Table MWE}
        \begin{tabular}{
                S[table-format = 1.2]
                S[table-format = 1.4]
                S[table-format = 2.3]
                S[table-format = 1.4]
            }
            \toprule
            {$A_\mathrm{nom}$ [\si{mm^2}]} &
            {$\dfrac{\dot{m} C_p \Delta T}{A_\mathrm{nom}}$ [\si{W/m^2}]} &
            {$k$ [\si{W/m.K}]} &
            {$\Delta T$ [\si{\degreeCelsius}]} \\
            \midrule
            1.55    &   1.12345 &   10.2344     &   0.33122 \\
            1.75    &   2.34567 &   20.8455     &   0.54947 \\
            2.25    &   3.45678 &   30.5666     &   0.86800 \\
        \end{tabular}
    \end{table}


    \begin{table}
        \centering
        \caption{Table MWE}
        \begin{tabular}{
                S[table-format = 1.2]
                S[table-format = 1.4]
                S[table-format = 2.3]
                S[table-format = 1.4]
            }
            \toprule
            {\thead{$A_\mathrm{nom}$\\{} [\si{mm^2}]}} &
            {\thead{$(\dot{m} C_p \Delta T)/(A_\mathrm{nom})$\\{} [\si{W/m^2}]}} &
            {\thead{$k$\\{} [\si{W/m.K}]}} &
            {\thead{$\Delta T$\\{} [\si{\degreeCelsius}]}} \\
            \midrule
            1.55    &   1.12345 &   10.2344     &   0.33122 \\
            1.75    &   2.34567 &   20.8455     &   0.54947 \\
            2.25    &   3.45678 &   30.5666     &   0.86800 \\
        \end{tabular}
    \end{table}


    \begin{table}
        \centering
        \caption{Table MWE}
        \begin{tabular}{
                S[table-format = 1.2]
                S[table-format = 1.4]
                S[table-format = 2.3]
                S[table-format = 1.4]
            }
            \toprule
            {$A_\mathrm{nom}$ [\si{mm^2}]} &
            {$(\dot{m} C_p \Delta T)/(A_\mathrm{nom})$ [\si{W/m^2}]} &
            {$k$ [\si{W/m.K}]} &
            {$\Delta T$ [\si{\degreeCelsius}]} \\
            \midrule
            1.55    &   1.12345 &   10.2344     &   0.33122 \\
            1.75    &   2.34567 &   20.8455     &   0.54947 \\
            2.25    &   3.45678 &   30.5666     &   0.86800 \\
        \end{tabular}
    \end{table}
\end{document}

相关内容