表格调整大小时会添加“高度”一词,并且标题格式不正确

表格调整大小时会添加“高度”一词,并且标题格式不正确

我有一张很长的表格,我想格式化它,但当我使用时\resizebox,pdf 无法呈现(我使用的是 Overleaf)。我尝试了{adjustbox},它成功了,但不知何故在表格末尾插入了单词“height”。甚至在尝试这两个选项之前,标题的格式就不正确。它是半斜体,没有空格,并且一行一行地超出页面。

代码如下:

\begin{table}[]
\begin{adjustbox}{width=\columnwidth,center}
\begin{tabular}{llllllllllllll}

\hline
\rowcolor[HTML]{C0C0C0} 
\begin{tabular}[c]{@{}l@{}}\rho\\ (g/cm^3)\end{tabular} & \begin{tabular}[c]{@{}l@{}}E_1\\ (MPa)\end{tabular} & \begin{tabular}[c]{@{}l@{}}E_2\\ (MPa)\end{tabular} & $\nu$_1_2 & $\nu$_2_3 & \begin{tabular}[c]{@{}l@{}}G_1_2\\ (MPa)\end{tabular} & \begin{tabular}[c]{@{}l@{}}G_2_3\\ (MPa)\end{tabular} & \begin{tabular}[c]{@{}l@{}}$\sigma$_1_,_T\\ (MPa)\end{tabular} & \begin{tabular}[c]{@{}l@{}}$\sigma$_1_,_C\\ (MPa)\end{tabular} & \begin{tabular}[c]{@{}l@{}}$\sigma$_2_,_T\\ (MPa)\end{tabular} & \begin{tabular}[c]{@{}l@{}}$\sigma$_2_,_C\\ (MPa)\end{tabular} & \begin{tabular}[c]{@{}l@{}}$\tau$_1_2\\ (MPa)\end{tabular} & \begin{tabular}[c]{@{}l@{}}$\tau$_2_3\\ (MPa)\end{tabular} & \begin{tabular}[c]{@{}l@{}}U_1_,_T\\ (N/mm)\end{tabular} \\ \hline
1.22                                                 & 140000                                             & 9000                                               & 0.28 & 0.49 & 5400                                                & 5400                                                & 2570                                                  & 1570                                                  & 63.4                                                  & 266                                                   & 95.8                                                 & 95.8                                                 & 12.5                                                  \\
                                                     &                                                    &                                                    &      &      &                                                     &                                                     &                                                       &                                                       &                                                       &                                                       &                                                      &                                                      &                                                       \\
                                                     &                                                    &                                                    &      &      &                                                     &                                                     &                                                       &                                                       &                                                       &                                                       &                                                      &                                                      &                                                      
\end{tabular}
\caption{Mechanical property of the carbon fiber/epoxy composite material. Variable $\rho$ is mass density, E_i, $\nu$_ij, G_ij, and $\tau$_ij are Young's modulus, Poisson's ratio, shear modulus, and shear strength in corresponding directions; $\sigma$_i,T/C and U_i,T/C are tensile/compressive strengths in the corresponding directions \cite{liu2014failure}}
\end{table}

以下是我正在使用的所有软件包

\documentclass[fleqn,10pt]{wlscirep}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{amsmath}
\usepackage[labelfont=bf]{caption}
\usepackage{graphics}
\usepackage{graphicx}
\usepackage{array}
\usepackage{color}
\usepackage{siunitx}
\usepackage [english]{babel}
\usepackage [autostyle, english = american]{csquotes}
\usepackage[font=normal,labelfont=bf]{caption}
\usepackage[pagebackref=true,breaklinks=true,colorlinks,bookmarks=false]{hyperref}
%\MakeOuterQuote{"}
\usepackage{times}
\usepackage{gensymb}
\usepackage{float}
\usepackage{multirow}
\usepackage{rotating}
\usepackage{fullpage}
\usepackage{subcaption}
\usepackage{colortbl}
\usepackage[table,xcdraw]{xcolor}
\usepackage{adjustbox}

这些是标题中出现的所有错误:

Improper \spacefactor.
Illegal unit of measure (pt inserted).
Missing $ inserted.
You can't use `\hrule' here except with leaders.
Missing } inserted.
Missing number, treated as zero.
You can't use `\spacefactor' in math mode.
Overfull \hbox (333.14093pt too wide) in paragraph at lines 145--145
Missing number, treated as zero.
Missing \endgroup inserted.

答案1

  • 在哪里可以找到 documjentclass wlscirep
  • 您的列标题太乱了。您期望从 得到什么$\nu$_1_2?我猜应该写成$\nu_{1_2}$$\nu_{12}$。请澄清一下。
  • 而不是\begin{tabular}[c]{@{}l@{}} ...\end{tabular}尝试使用\makecell[l]{...}。至少代码更短,因此不容易出错
  • 标题中的数学表达式不在数学环境中。
  • 每行应有n-1“&”符号,其中n定义列数。
  • hyperref应该最后加载。
  • 修正上述内容,使用articledocumentclass 时的结果是:

在此处输入图片描述

\documentclass[fleqn,10pt]{article}
\usepackage{fullpage}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{times}
\usepackage{gensymb}
\usepackage{amsmath}
\usepackage[font=normal,labelfont=bf]{caption}
\usepackage{subcaption}
\usepackage{adjustbox} % it load graphicx too
\usepackage{array}
\usepackage{siunitx}
\usepackage [english]{babel}
%\MakeOuterQuote{"}
\usepackage [autostyle, english = american]{csquotes}
\usepackage{float}
\usepackage{makecell,   % new
            multirow}
\usepackage{rotating}
\usepackage[table,xcdraw]{xcolor}
\usepackage[pagebackref=true,breaklinks=true,colorlinks,bookmarks=false]{hyperref}

\begin{document}
\begin{table}[htb]
\begin{adjustbox}{width=\columnwidth,center}
\begin{tabular}{lll lll lll lll ll}
    \hline
    \rowcolor[HTML]{C0C0C0}
\makecell[l]{$\rho$\\ (g/cm$^3$)}
    & \makecell[l]{$E_1$\\ (MPa)}~~ % ~ added that length of cell content is sufficient long
        & \makecell[l]{$E_2$\\ (MPa)}
            & $\nu_{1_2}$
                & $\nu_{2_3}$
                    & \makecell[l]{$G_{12}$\\ (MPa)}
                       & \makecell[l]{$G_{2_3}$\\ (MPa)}
                            & \makecell[l]{$\sigma_{1_T}$\\ (MPa)}
                                & \makecell[l]{$\sigma_1, C$\\ (MPa)}
                                    & \makecell[l]{$\sigma_2, T$\\ (MPa)}
                                        & \makecell[l]{$\sigma_2, C$\\ (MPa)}
                                            & \makecell[l]{$\tau_{1_2}$\\ (MPa)}
                                                & \makecell[l]{$\tau_{2_3}$\\ (MPa)}
                                                    & \makecell[l]{$U_{1}, T$\\ (N/mm)} \\
    \hline
1.22    & 140000    & 9000  & 0.28 & 0.49 & 5400    & 5400  & 2570  & 1570  & 63.4  & 266   & 95.8  & 95.8  & 12.5  \\
         &          &       &      &      &         &       &       &       &       &       &       &       &       \\
         &          &       &      &      &         &       &       &       &       &       &       &       &
\end{tabular}
\end{adjustbox}
\caption{Mechanical property of the carbon fiber/epoxy composite material. Variable $\rho$ is mass density, $E_i$, $\nu_{ij}$, $G_{ij}$, and $\tau_{ij}$ are Young's modulus, Poisson's ratio, shear modulus, and shear strength in corresponding directions; $\sigma_i,T/C$ and $U_i,T/C$ are tensile/compressive strengths in the corresponding directions \cite{liu2014failure}}
\end{table}
\end{document}

附录:
使用更高级的表格包tabularray与库booktabssiunitx(都加载相应的包),\small表格中的字体大小,表格可以在不使用adjustbox环境的情况下编写,并且可以更好地垂直间距单元格的内容:

在此处输入图片描述

\documentclass[fleqn,10pt]{article}
\usepackage{fullpage}
\usepackage[T1]{fontenc}
\usepackage [english]{babel}
\usepackage{textcomp}
\usepackage{times}
\usepackage{gensymb}
\usepackage{amsmath}
\usepackage[font=normal,labelfont=bf]{caption}
\usepackage{subcaption}
\usepackage{adjustbox}  % it load graphicx too
\usepackage [autostyle, english = american]{csquotes}
%\MakeOuterQuote{"}
\usepackage{float}
\usepackage{rotating}
\usepackage[xcdraw]{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}

\usepackage[pagebackref=true,breaklinks=true,colorlinks,bookmarks=false]{hyperref}

\begin{document}
\begin{table}[htb]
\small
\begin{tblr}{colsep  = {3pt},
             colspec = {l X[1.1,c, si={table-format=6}] X[c, si={table-format=4}] 
                        *{2}{X[0.7,c,si={table-format=1.2}]} 
                        *{4}{X[c, si={table-format=5}]} X[c, si={table-format=2.1}]   X[c, si={table-format=3}]    
                        *{3}{X[c, si={table-format=2.1}]}},
             row{1}  = {guard, mode=math, c, bg=gray!30},
             row{2}  = {guard, c, bg=gray!30}
             }
    \toprule
\rho    & E_1       & E_2   &   \SetCell[r=2]{c}    \nu_{12}
                                    &   \SetCell[r=2]{c}    \nu_{23}
                                             & G_{12}
                                                    & G_{23} 
                                                            &\sigma_{1_T} 
                                                                    & \sigma_1  
                                                                            & \sigma_2, T 
                                                                                    & \sigma_2, C 
                                                                                            & \tau_{1_2}
                                                                                                    &\tau_{2_3} 
                                                                                                            & U_{1}, T  \\
(\unit{g/cm^3})
        & (MPa)     & (MPa) &       &       & (MPa) & (MPa) & (MPa) & (MPa) & (MPa) & (MPa) & (MPa) & (MPa) & (N/mm)    \\
    \midrule
1.22    & 140000    & 9000  & 0.28 & 0.49   & 5400  & 5400  & 2570  & 1570  & 63.4  & 266   & 95.8  & 95.8  & 12.5      \\
        &           &       &      &        &       &       &       &       &       &       &       &       &           \\
        &           &       &      &        &       &       &       &       &       &       &       &       &           \\
    \bottomrule
\end{tblr}
\caption{Mechanical property of the carbon fiber/epoxy composite material. Variable $\rho$ is mass density, $E_i$, $\nu_{ij}$, $G_{ij}$, and $\tau_{ij}$ are Young's modulus, Poisson's ratio, shear modulus, and shear strength in corresponding directions; $\sigma_i,T/C$ and $U_i,T/C$ are tensile/compressive strengths in the corresponding directions \cite{liu2014failure}}
\end{table}
\end{document}

相关内容