我有一个 LaTeX 代码,它在我的第一个模板中运行良好,但是当我将它复制到我的新模板时,它不起作用,我真的不知道为什么会出现这个错误:
\noalign 位置错误。您在错误的位置使用了 \hline 命令,可能在表格之外。如果 \hline 命令写在表格内,请尝试在其前面添加 \。
这是我在 Overleaf 中的文件的链接:https://www.overleaf.com/1445775647ghxgtdjxxdwx
这是我的代码:
\documentclass[USenglish]{article}
% for 2-column layout use \documentclass[USenglish,twocolumn]{article}
\usepackage[utf8]{inputenc} %(only for the pdftex engine)
%\RequirePackage[no-math]{fontspec}[2017/03/31]%(only for the luatex or the xetex engine)
\usepackage[big,online]{dgruyter} %values: small,big | online,print,work
\usepackage{lmodern}
\usepackage{microtype}
\usepackage[numbers,square,sort&compress]{natbib}
% New theorem-like environments will be introduced by using the commands \theoremstyle and \newtheorem.
% Please note that the environments proof and definition are already defined within dgryuter.sty.
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{hhline}
\usepackage{empheq}
\usepackage{blindtext}
\usepackage{multicol}
\usepackage{tabularray}
\begin{document}
%%%--------------------------------------------%%%
\articletype{Research Article}
\received{Month DD, YYYY}
\revised{Month DD, YYYY}
\accepted{Month DD, YYYY}
\journalname{De~Gruyter~Journal}
\journalyear{YYYY}
\journalvolume{XX}
\journalissue{X}
\startpage{1}
\aop
\DOI{10.1515/sample-YYYY-XXXX}
%%%--------------------------------------------%%%
\title{Insert your title here}
\runningtitle{Short title}
%\subtitle{Insert subtitle if needed}
\author*[1]{First Author}
%\ use * to mark the author as the corresponding author
\author[2]{Second Author}
\author[2]{Third Author}
\runningauthor{F.~Author et al.}
\affil[1]{\protect\raggedright
Institution, Department, City, Country of first author, e-mail: author\[email protected]}
\affil[2]{\protect\raggedright
Institution, Department, City, Country of second author and third author, e-mail: author\[email protected], author\[email protected]}
%\communicated{...}
%\dedication{...}
\abstract{}
\keywords{Please insert your keywords here, separated by commas.}
\begin{table}[h]
\centering
\begin{tabular}{|c|c|c|c|c|c|c|c|c|}
\hline
\multicolumn{5}{|c|}{Gaussian } & \multicolumn{4}{|c|}{IMQ}\\ \hline
Level & Cond($\mathbf{A}$) & Max EV & Min EV & \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}} Cholesky\\ Y/N? \end{tabular}} & Cond($\mathbf{A}$) & Max EV & Min EV &\multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}} Cholesky\\ Y/N? \end{tabular}} \\ \hline
1 & 3.55E+00 & -3.3E+00 & -1.2E+01 & Y & 1.76E+00 & -5.4E+00 & -9.6E+00 & Y \\ \hline
2 & 7.13E+00 & -6.7E+00 & -4.8E+01 & Y & 2.41E+00 & -3.2E+01 & -7.7E+01 & Y \\ \hline
3 & 1.78E+01 & -1.1E+01 & -1.9E+02 & Y & 3.59E+00 & -1.7E+02 & -6.2E+02 & Y \\ \hline
4 & 5.09E+01 & -1.5E+01 & -7.7E+02 & Y & 5.26E+00 & -9.5E+02 & -5.0E+03 & Y \\ \hline
5 & 1.36E+02 & -2.3E+01 & -3.1E+03 & Y & 6.84E+00 & -5.9E+03 & -4.0E+04 & Y \\ \hline
6 & 2.69E+02 & -4.6E+01 & -1.2E+04 & Y & 7.81E+00 & -4.1E+04 & -3.2E+05 & Y \\ \hline
\end{tabular}
\caption{The condition number of the matrix $\mathbf{A}$ and the minimum/maximum eigenvalue of the matrix $\mathbf{A}$ using Gaussian RBF and IMQ RBF with $C=1$.}
\label{Tab: Cond_A_C1}
\end{table}
\end{document}
请问我该如何修复这个错误?
答案1
该软件包的用户指南dgruyter
明确指出垂直规则应该不是可用于表格中。此外,用户指南指出,该booktabs
包由包自动加载dgruyter
,这意味着您应该使用诸如\toprule
、\midrule
和\bottomrule
之类的命令,\cmidrule
而不是\hline
和\cline
。
考虑到这一点,以下解决方案——它还利用了siunitx
包的功能来以科学格式排版数字——应该会引起您的兴趣。
\documentclass[english]{article}
% for 2-column layout use \documentclass[USenglish,twocolumn]{article}
%%\usepackage[utf8]{inputenc} % that's the default
%\RequirePackage[no-math]{fontspec}[2017/03/31]%(only for the luatex or the xetex engine)
\usepackage[big,online]{dgruyter} %values: small,big | online,print,work
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{microtype}
\usepackage[numbers,square,sort&compress]{natbib}
%%%%%\usepackage[utf8]{inputenc}
%\usepackage{multirow}
%\usepackage{hhline}
%\usepackage{empheq}
%\usepackage{blindtext}
%%%%%\usepackage{multicol} % not needed
%\usepackage{tabularray}
% new:
\usepackage{siunitx}
\begin{document}
%%%--------------------------------------------%%%
\articletype{Research Article}
\received{Month DD, YYYY}
\revised{Month DD, YYYY}
\accepted{Month DD, YYYY}
\journalname{De~Gruyter~Journal}
\journalyear{YYYY}
\journalvolume{XX}
\journalissue{X}
\startpage{1}
\aop
\DOI{10.1515/sample-YYYY-XXXX}
%%%--------------------------------------------%%%
\title{Insert your title here}
\runningtitle{Short title}
%\subtitle{Insert subtitle if needed}
\author*[1]{First Author}
%\ use * to mark the author as the corresponding author
\author[2]{Second Author}
\author[2]{Third Author}
\runningauthor{F.~Author et al.}
\affil[1]{\protect\raggedright
Institution, Department, City, Country of first author, e-mail: author\[email protected]}
\affil[2]{\protect\raggedright
Institution, Department, City, Country of second author and third author, e-mail: author\[email protected], author\[email protected]}
%\communicated{...}
%\dedication{...}
\abstract{}
\keywords{Please insert your keywords here, separated by commas.}
\begin{table}[h]
\sisetup{tight-spacing,print-zero-exponent}
\setlength{\tabcolsep}{0pt} % let LaTeX figure out intercol. whitespace
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}
l
S[table-format= 1.2e1] *{2}{S[table-format=-1.1e1]} c
S[table-format= 1.2e1] *{2}{S[table-format=-1.1e1]} c }
%\toprule % is automatic
Level & \multicolumn{4}{c}{Gaussian} & \multicolumn{4}{c}{IMQ} \\
\cmidrule{2-5} \cmidrule{6-9}
& {Cond($\mathbf{A}$)} & {Max EV} & {Min EV} & Cholesky? &
{Cond($\mathbf{A}$)} & {Max EV} & {Min EV} & Cholesky?
\\
\midrule
1 & 3.55E+00 & -3.3E+00 & -1.2E+01 & Y & 1.76E+00 & -5.4E+00 & -9.6E+00 & Y \\
2 & 7.13E+00 & -6.7E+00 & -4.8E+01 & Y & 2.41E+00 & -3.2E+01 & -7.7E+01 & Y \\
3 & 1.78E+01 & -1.1E+01 & -1.9E+02 & Y & 3.59E+00 & -1.7E+02 & -6.2E+02 & Y \\
4 & 5.09E+01 & -1.5E+01 & -7.7E+02 & Y & 5.26E+00 & -9.5E+02 & -5.0E+03 & Y \\
5 & 1.36E+02 & -2.3E+01 & -3.1E+03 & Y & 6.84E+00 & -5.9E+03 & -4.0E+04 & Y \\
6 & 2.69E+02 & -4.6E+01 & -1.2E+04 & Y & 7.81E+00 & -4.1E+04 & -3.2E+05 & Y \\
%\bottomrule % is automatic
\end{tabular*}
\caption{The condition number of the matrix $\mathbf{A}$ and the minimum\slash maximum eigenvalue of the matrix $\mathbf{A}$ using Gaussian RBF and IMQ RBF with $C=1$.}
\label{Tab: Cond_A_C1}
\end{table}
\end{document}