扫描使用 \multicolumn 时文件结束

扫描使用 \multicolumn 时文件结束

我用了http://www.tablesgenerator.com/#创建此表并加载所有需要的包。但它仍然不起作用。我的论文确实需要这个。有人可以帮忙吗?我的代码如下:

\begin{table}[h]
\centering
\begin{tabular}{llllll}
\hline
\multicolumn{1}{|l|}{} & \multicolumn{1}{l|}{$E_x$ {[}GPa{]}} & \multicolumn{1}{l|}{$E_y$ {[}GPa{]}} & \multicolumn{1}{l|}{$E_x$/$E_y$} & \multicolumn{1}{l|}{$E^f$ {[}GPa{]}} & \multicolumn{1}{l|}{$\rho$ {[}kg/$cm^3]$} \\ \hline
\multicolumn{1}{|l|}{Rosewood} & \multicolumn{1}{l|}{18,1} & \multicolumn{1}{l|}{1,06} & \multicolumn{1}{l|}{17,1} & \multicolumn{1}{l|}{18,1} & \multicolumn{1}{l|}{0,83} \\ \hline
\cellcolor[HTML]{C0C0C0}\textbf{One balsa ply} &  &  &  &  &  \\ \hline
\multicolumn{1}{|l|}{$[$\pm$$2_{3}$,$0_{2}$, Balsa{]}\_{s\}$} & \multicolumn{1}{l|}{19,5} & \multicolumn{1}{l|}{2,3} & \multicolumn{1}{l|}{8,4} & \multicolumn{1}{l|}{29,2} & \multicolumn{1}{l|}{0,80} \\ \hline
\multicolumn{1}{|l|}{$[$\pm$$10_3$,$0_{2}$, Balsa{]}\_{s\}$} & \multicolumn{1}{l|}{18,6} & \multicolumn{1}{l|}{2,2} & \multicolumn{1}{l|}{8,45} & \multicolumn{1}{l|}{26,97} & \multicolumn{1}{l|}{0,80} \\ \hline
\rowcolor[HTML]{FFFE65} 
\multicolumn{1}{|l|}{\cellcolor[HTML]{FFFE65}$[$\pm$$15_{3}$,$0_{2}$, Balsa{]}\_{s\}$} & \multicolumn{1}{l|}{\cellcolor[HTML]{FFFE65}17,3} & \multicolumn{1}{l|}{\cellcolor[HTML]{FFFE65}2,1} & \multicolumn{1}{l|}{\cellcolor[HTML]{FFFE65}8,23} & \multicolumn{1}{l|}{\cellcolor[HTML]{FFFE65}24,4} & \multicolumn{1}{l|}{\cellcolor[HTML]{FFFE65}0,80} \\ \hline
\cellcolor[HTML]{C0C0C0}\textbf{Two balsa plies} &  &  &  &  &  \\ \hline
\multicolumn{1}{|l|}{$[$0\_{2\}$, Balsa, $\pm$$6_3$,{]}\_{s\}$} & \multicolumn{1}{l|}{19,4} & \multicolumn{1}{l|}{2,3} & \multicolumn{1}{l|}{8,4} & \multicolumn{1}{l|}{15,6} & \multicolumn{1}{l|}{0,798} \\ \hline
\multicolumn{1}{|l|}{$[$0\_{2\}$, Balsa, $\pm$$10_3$,{]}\_{s\}$} & \multicolumn{1}{l|}{18,58} & \multicolumn{1}{l|}{2,24} & \multicolumn{1}{l|}{8,4} & \multicolumn{1}{l|}{15,06} & \multicolumn{1}{l|}{0,798} \\ \hline
\multicolumn{1}{|l|}{$[$0\_{3\}$, Balsa, $\pm$$10_3$,{]}\_{s\}$} & \multicolumn{1}{l|}{20,9} & \multicolumn{1}{l|}{2,51} & \multicolumn{1}{l|}{8,3} & \multicolumn{1}{l|}{19,5} & \multicolumn{1}{l|}{0,88} \\ \hline
\multicolumn{1}{|l|}{$[$0\_{3\}$, Balsa, $\pm$$15_3$,{]}\_{s\}$} & \multicolumn{1}{l|}{19,6} & \multicolumn{1}{l|}{2,40} & \multicolumn{1}{l|}{8,2} & \multicolumn{1}{l|}{19,2} & \multicolumn{1}{l|}{0,88} \\ \hline
\rowcolor[HTML]{FFFE65} 
\multicolumn{1}{|l|}{\cellcolor[HTML]{FFFE65}$[$0\_{3\}$, Balsa, $\pm$$20_3$,{]}\_{s\}$} & \multicolumn{1}{l|}{\cellcolor[HTML]{FFFE65}17,6} & \multicolumn{1}{l|}{\cellcolor[HTML]{FFFE65}2,28} & \multicolumn{1}{l|}{\cellcolor[HTML]{FFFE65}7,7} & \multicolumn{1}{l|}{\cellcolor[HTML]{FFFE65}18,9} & \multicolumn{1}{l|}{\cellcolor[HTML]{FFFE65}0,88} \\ \hline
\end{tabular}
\caption*{Table 9 - Lay-up properties with the best results highlighted.}
\end{table}

答案1

抱歉,你用的软件根本就不行,错误多多,下标混乱,语法错误多,基本无法修复。

输入每一个单元格作为\multicolumn是荒谬的。这里我展示了如何更轻松地输入表格。唯一要记住的技巧是\relax在 前面[开始一行。

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{caption,siunitx}

\definecolor{balsa1}{HTML}{C0C0C0}
\definecolor{balsa2}{HTML}{FFFE65}

\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{
  |l|
  S[table-format=2.2]|
  S[table-format=1.2]|
  S[table-format=2.2]|
  S[table-format=2.2]|
  S[table-format=1.3]|
}
\hline
 & 
 {$E_x$ (\si{\giga\pascal})} &
 {$E_y$ (\si{\giga\pascal})} &
 {$E_x/E_y$} &
 {$E^f$ (\si{\giga\pascal})} &
 {$\rho$ (\si{\kilo\gram\per\cubic\centi\meter})} \\ \hline
Rosewood & 18,1 & 1,06 & 17,1 & 18,1 & 0,83 \\ \hline
\cellcolor{balsa1}\textbf{One balsa ply} &  &  &  &  &  \\ \hline
\relax[$\pm2_{3}$, $0_{2}$, Balsa]$_{s}$ & 19,5 & 2,3 & 8,4 & 29,2 & 0,80 \\ \hline
\relax[$\pm10_3$, $0_{2}$, Balsa]$_{s}$ & 18,6 & 2,2 & 8,45 & 26,97 & 0,80 \\ \hline
\rowcolor{balsa2}%
\relax[$\pm15_{3}$, $0_{2}$, Balsa]$_{s}$ & 17,3 & 2,1 & 8,23 & 24,4 & 0,80 \\ \hline
\cellcolor{balsa1}\textbf{Two balsa plies} &  &  &  &  &  \\ \hline
\relax[$0_{2}$, Balsa, $\pm6_3$,]$_{s}$ & 19,4 & 2,3 & 8,4 & 15,6 & 0,798 \\ \hline
\relax[$0_{2}$, Balsa, $\pm10_3$,]$_{s}$ & 18,58 & 2,24 & 8,4 & 15,06 & 0,798 \\ \hline
\relax[$0_{3}$, Balsa, $\pm10_3$,]$_{s}$ & 20,9 & 2,51 & 8,3 & 19,5 & 0,88 \\ \hline
\relax[$0_{3}$, Balsa, $\pm15_3$,]$_{s}$ & 19,6 & 2,40 & 8,2 & 19,2 & 0,88 \\ \hline
\rowcolor{balsa2}%
\relax[$0_{3}$, Balsa, $\pm20_3$,]$_{s}$ & 17,6 & 2,28 & 7,7 & 18,9 & 0,88 \\ \hline
\end{tabular}
\caption*{Table 9 -- Lay-up properties with the best results highlighted.}
\end{table}
\end{document}

在此处输入图片描述


没有垂直线的改进版本

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{caption,siunitx,booktabs}

\definecolor{balsa1}{HTML}{C0C0C0}
\definecolor{balsa2}{HTML}{FFFE65}

\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{
  l
  S[table-format=2.2]
  S[table-format=1.2]
  S[table-format=2.2]
  S[table-format=2.2]
  S[table-format=1.3]
}
\toprule
 & 
 {$E_x$} &
 {$E_y$} &
 {$E_x/E_y$} &
 {$E^f$} &
 {$\rho$} \\
 & 
 {(\si{\giga\pascal})} &
 {(\si{\giga\pascal})} &
 {} &
 {(\si{\giga\pascal})} &
 {(\si{\kilo\gram\per\cubic\centi\meter})} \\
\midrule
Rosewood & 18,1 & 1,06 & 17,1 & 18,1 & 0,83 \\
\multicolumn{6}{c}{\cellcolor{balsa1}\textbf{One balsa ply}} \\
\relax[$\pm2_{3}$, $0_{2}$, Balsa]$_{s}$ & 19,5 & 2,3 & 8,4 & 29,2 & 0,80 \\
\relax[$\pm10_3$, $0_{2}$, Balsa]$_{s}$ & 18,6 & 2,2 & 8,45 & 26,97 & 0,80 \\
\rowcolor{balsa2}%
\relax[$\pm15_{3}$, $0_{2}$, Balsa]$_{s}$ & 17,3 & 2,1 & 8,23 & 24,4 & 0,80 \\
\multicolumn{6}{c}{\cellcolor{balsa1}\textbf{Two balsa plies}} \\
\relax[$0_{2}$, Balsa, $\pm6_3$,]$_{s}$ & 19,4 & 2,3 & 8,4 & 15,6 & 0,798 \\
\relax[$0_{2}$, Balsa, $\pm10_3$,]$_{s}$ & 18,58 & 2,24 & 8,4 & 15,06 & 0,798 \\
\relax[$0_{3}$, Balsa, $\pm10_3$,]$_{s}$ & 20,9 & 2,51 & 8,3 & 19,5 & 0,88 \\
\relax[$0_{3}$, Balsa, $\pm15_3$,]$_{s}$ & 19,6 & 2,40 & 8,2 & 19,2 & 0,88 \\
\rowcolor{balsa2}%
\relax[$0_{3}$, Balsa, $\pm20_3$,]$_{s}$ & 17,6 & 2,28 & 7,7 & 18,9 & 0,88 \\
\bottomrule
\end{tabular}
\caption*{Table 9 -- Lay-up properties with the best results highlighted.}
\end{table}
\end{document}

在此处输入图片描述

相关内容