如何使“多行”参数适合其预先指定的列宽?

如何使“多行”参数适合其预先指定的列宽?

内容multirow水平溢出:

在此处输入图片描述

我知道我可以通过指定某个长度而不是 来解决这个问题*\multirow{5}{*}{Polynomial Fit According to Eq. }但我希望自动指定 表示的宽度*,并且该宽度与相应的列宽完全相等,>{\hsize=0.3\hsize}C在本例中就是。例如,查看以“根据方程近似立方”开头的行。内容会自动调整。这正是我想要的,但它似乎不适用于\multirow命令。

这是我的源代码:

\documentclass[]{IEEEtran}

    % Floats
    \usepackage{caption}

        \captionsetup{justification = centering}


    % Math
    \usepackage{amsmath}
    \usepackage{amssymb, amsfonts}
    \usepackage[]{mathtools}


    % Tables
    \usepackage{ragged2e}
    \usepackage{tabularx}
        \newcolumntype{C}{ >{ \arraybackslash \Centering } X }

    \renewcommand \tabularxcolumn [1] { >{ \centering } m{#1} }


        \newcommand {\arraystretchdefaultl} {1.3}
        \newcommand{\arraystretchdefault}{ \renewcommand {\arraystretch} {\arraystretchdefaultl} }
        \arraystretchdefault

        \newcommand {\scalelinespace} [1] {\rule{0pt}{#1\normalbaselineskip}}

        \newlength{\tabcolsepdefaultl}
        \setlength{\tabcolsepdefaultl}{2.12mm}
        \newcommand{\tabcolsepdefault}{ \setlength{\tabcolsep}{\tabcolsepdefaultl} }
        \tabcolsepdefault

        \newlength{\arraycolsepdefaultl}
        \setlength{\arraycolsepdefaultl}{2.12mm}
        \newcommand{\arraycolsepdefault}{ \setlength{\arraycolsep}{\arraycolsepdefaultl} }
        \arraycolsepdefault


    \usepackage{booktabs}   
    \usepackage{multirow}

\begin{document}


\begin{table*}[h t p]

    % Table options

    % Caption
    \caption{\Large \textbf{A table with multi-rows and multi columns}}
    \label{table:fit_WT_par}

    % Center the table
    \centering



    % Table contents
    \begin{tabularx}{1\textwidth}{ >{\hsize=0.3\hsize}C *{2}{|C} *{2}{|C} *{2}{|C} }



        \toprule


        & 
        \multicolumn{6}{c}{ \textbf{WT Model} }
        \\
        \hline

        \textbf{Fit Type} &
        \multicolumn{2}{c|}{ \textbf{GEV MP R} } &
        \multicolumn{2}{c|}{ \textbf{G58-850} } &
        \multicolumn{2}{c}{ \textbf{E-92} }
        \\
        \hline


        \multirow{5}{*}{Polynomial Fit According to Eq. } &
        \multicolumn{2}{c|}{

            \multirow{5}{4.5 cm}{\RaggedLeft $c_{7 }= -9.7, \; c_{6} = 531$ $c_{5} = -122, \; c_{4} = 152$ $c_{3} = -111, \; c_{2} = 473$ $c_{1} = -10927270, \; c_{0} = 105$}

        } &
        \multicolumn{2}{c|} {


            \multirow{5}{4.5 cm}{\justifying $c_{8} = -1.30, \; c_{7} = 85.3$ $c_{6} = -236, \; c_{5} = 360$ $c_{4} = -328979, \; c_{3} = 184$ $c_{2} = -6194947, \; c_{1} = 113$ $c_{0} = -874$}

        } &
        \multicolumn{2}{c} {


            \multirow{5}{4.5 cm}{\centering $c_{9} = -0.0535, \; c_{8} = 2.79$ $c_{7} = -53.1, \; c_{6} = 364$ $c_{5} = 150, \; c_{4} = -416$ $c_{3} = 290, \; c_{2} = -972$ $c_{1} = 1609, \; c_{0} = -104$}

        }
        \\

        &
        \multicolumn{2}{c|}{ }
        &
        \multicolumn{2}{c|} {}
        &
        \multicolumn{2}{c} {}
        \\


        &
        \multicolumn{2}{c|}{}
        &
        \multicolumn{2}{c|} {}
        &
        \multicolumn{2}{c} {}
        \\


        &
        \multicolumn{2}{c|}{}
        &
        \multicolumn{2}{c|} {}
        &
        \multicolumn{2}{c} {}
        \\


        &
        \multicolumn{2}{c|}{}
        &
        \multicolumn{2}{c|} {}
        &
        \multicolumn{2}{c} {}
        \\
        \hline



        Approximate Cubic According to Eq. &
        \multicolumn{2}{c|}{\centering  $C_{p, \, max} = 0.3926$} &
        \multicolumn{2}{c|}{\centering $C_{p, \, max} = 0.4453$} &
        \multicolumn{2}{c}{\centering $C_{p, \, max} = 0.4729$}
        \\
        \hline


        Exponential (Eq. ) &
        \multicolumn{2}{c|}{\centering $K_{p} = 2.687, \; \beta = 2.201$} &
        \multicolumn{2}{c|}{\centering $K_{p} = 12.88, \; \beta = 1.532$} &
        \multicolumn{2}{c}{\centering $K_{p} = 11.12, \; \beta = 1.564$}
        \\



        \bottomrule






    \end{tabularx}




\end{table*}


\end{document}

答案1

  • 在您的表中您不需要\multirow单元格。
  • 然而,如果你坚持在你的表格设计中使用它们,你可以利用multirow包的新功能,它提供了新的选项,=通过这个选项,多列单元格可以超过列的定义宽度。例如,该列的类型为p{22mm}\multirow{2}{=}{<cell content>}宽度为 22 毫米。

  • 不清楚为什么表只有四列时要定义七列。

  • multicolum(除了一个)都是多余的。
  • 我不会在表格中使用垂直规则
  • array如果在tabularx单元格中嵌套设置 x,则第二、第三和第四列中的方程式更具可读性

在此处输入图片描述

(红线表示文本边框)。

 \documentclass[]{IEEEtran}
% Floats
\usepackage{caption}
    \captionsetup{justification = centering}
% Math
%\usepackage{amsmath} % loaded by `mathtools`
\usepackage{amssymb}
\usepackage{mathtools}
% Tables
\usepackage{ragged2e}
\usepackage{booktabs, tabularx}
\renewcommand\tabularxcolumn[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{C}{>{\Centering} X }
\usepackage{siunitx} % <--- added

\begin{document}
    \begin{table*}
\caption{\Large \textbf{A table with multi-rows and multi columns}}
\label{table:fit_WT_par}
    \centering
\begin{tabularx}{0.85\textwidth}{@{}>{\hsize=0.16\hsize}C
                           *{3}{>{\hsize=0.28\hsize}C}
                            @{}}
    \toprule
    &   \multicolumn{3}{c}{\textbf{WT Model }}                      \\
    \cmidrule(lr){2-4}
\textbf{Fit Type}
    & \textbf{GEV MP R} & \textbf{G58-850}  & \textbf{E-92}         \\
    \midrule
Polynomial Fit According to Eq.
    &   $\begin{array}{@{}lll@{}}
        c_{7 }= -9.7            & c_{6} = 531   \\
        c_{5} = -122            & c_{4} = 152   \\
        c_{3} = -111            & c_{2} = 473   \\
        c_{1} = -\num{10927270} & c_{0} = 105
        \end{array}$
        &   $\begin{array}{@{}lll@{}}
            c_{8} = -1.30           & c_{7} = 85.3  \\
            c_{6} = -236            & c_{5} = 360   \\
            c_{4} = -\num{328979}   & c_{3} = 184   \\
            c_{2} = -\num{6194947}  & c_{1} = 113   \\
            c_{0} = -874            &
        \end{array}$
            &   $\begin{array}{@{}lll@{}}
            c_{9} = -0.0535 & c_{8} = 2.79  \\
            c_{7} = -53.1   & c_{6} = 364   \\
            c_{5} = 150     & c_{4} = -416  \\
            c_{3} = 290     & c_{2} = -972  \\
            c_{1} = 1609    & c_{0} = -104
            \end{array}$                    \\
    \midrule
Approximate Cubic According to Eq.
    & $C_{p,\max} = 0.3926$
        & $C_{p,\max} = 0.4453$
            & $C_{p,\max} = 0.4729$         \\
    \midrule
Exponential (Eq. )
    & $K_{p} = 2.687,\beta = 2.201$
        & $K_{p} = 12.88,\beta = 1.532$
            & $K_{p} = 11.12,\beta = 1.564$ \\
    \bottomrule
\end{tabularx}
    \end{table*}
\end{document}
  • 如果你想让表格宽度等于\textwidthrešlace

\begin{tabularx}{0.85\textwidth}{...}

宽度

\begin{tabularx}{1\textwidth}{...}

在上面的代码中,我删除了所有未使用的包和序言中的定义,这些与该表无关。

答案2

实际上,您不需要任何多行,只需要 4 列。这是一个更简单的代码,第一列的宽度是其他列宽度的 1/3。此外,您应该使用booktabs垂直规则:水平和垂直规则不能正确相交。我\bottomrule用amsmath mathtools\Xhline替换了它——后者可以帮您完成此操作。\documentclass[]{IEEEtran}makecell. Last point: needless to loadif you load

    % Floats
    \usepackage{caption}
        \captionsetup{justification = centering}

    % Math
    \usepackage{amssymb, amsfonts}
    \usepackage[]{mathtools}

    % Tables
    \usepackage{ragged2e}
    \usepackage{tabularx}
        \newcolumntype{C}{ >{ \arraybackslash \Centering } X }

    \renewcommand \tabularxcolumn [1] { >{ \centering } m{#1} }

        \newcommand {\arraystretchdefaultl} {1.3}
        \newcommand{\arraystretchdefault}{ \renewcommand {\arraystretch} {\arraystretchdefaultl} }
        \arraystretchdefault

        \newcommand {\scalelinespace} [1] {\rule{0pt}{#1\normalbaselineskip}}

        \newlength{\tabcolsepdefaultl}
        \setlength{\tabcolsepdefaultl}{2.12mm}
        \newcommand{\tabcolsepdefault}{ \setlength{\tabcolsep}{\tabcolsepdefaultl} }
        \tabcolsepdefault

        \newlength{\arraycolsepdefaultl}
        \setlength{\arraycolsepdefaultl}{2.12mm}
        \newcommand{\arraycolsepdefault}{ \setlength{\arraycolsep}{\arraycolsepdefaultl} }
        \arraycolsepdefault
    \usepackage{booktabs}
    \usepackage{multirow, makecell}

\begin{document}

\begin{table*}[h t p]
    % Table options
    % Caption
    \caption{\Large \textbf{A table with multi-rows and multi columns}}
    \label{table:fit_WT_par}
   % Center the table
    \centering
    % Table contents
    \begin{tabularx}{1\textwidth}{>{\hsize=0.4\hsize}C *{3}{|>{\hsize=1.2\hsize\arraybackslash}C}}
        \toprule
        \multicolumn{4}{c}{\textbf{WT Model}} \\
        \hline
 \textbf{Fit Type} & \textbf{GEV MP R} & \textbf{G58-850} & \textbf{E-92} \\
 \hline
 Polynomial Fit According to Eq. & \RaggedLeft $c_{7 }= -9.7, \; c_{6} = 531$, $c_{5} = -122, \; c_{4} = 152$, $c_{3} = -111, \; c_{2} = 473$, $c_{1} = -10927270, \; c_{0} = 105$ &
\justifying $c_{8} = -1.30, \; c_{7} = 85.3$, $c_{6} = -236, \; c_{5} = 360$, $c_{4} = -328979, \; c_{3} = 184$, $c_{2} = -6194947, \; c_{1} = 113$, $c_{0} = -874$ &
$c_{9} = -0.0535, \; c_{8} = 2.79$, $c_{7} = -53.1, \; c_{6} = 364$, $c_{5} = 150, \; c_{4} = -416$, $c_{3} = 290, \; c_{2} = -972$, $c_{1} = 1609, \; c_{0} = -104$ \\
 \hline
 Approximate Cubic According to Eq. & $C_{p, \, \max} = 0.3926$ & $C_{p, \,\max} = 0.4453$ & $C_{p, \, \max} = 0.4729$ \\
 \hline
 Exponential (Eq. ) & $K_{p} = 2.687, \; \beta = 2.201$ & $K_{p} = 12.88, \; \beta = 1.532$ & $K_{p} = 11.12, \; \beta = 1.564$ %
 \\
 \Xhline{0.8pt}
 \end{tabularx}
\end{table*}

\end{document} 

在此处输入图片描述

相关内容