我正在尝试创建一个包含多个包含方括号的输入的表格。我在网上做了一些研究,发现大多数人可以通过将方括号括起来来插入方括号。然而,就我的情况而言,这还不够。
表格代码:
\documentclass[11pt, oneside]{article}
\usepackage{geometry}
\geometry{letterpaper}
%\geometry{landscape}
%\usepackage[parfill]{parskip}
\usepackage{graphicx}
\usepackage{eqnarray,amsmath}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{mathtools}
\usepackage{setspace}
\onehalfspacing
\usepackage[T1]{fontenc}
\usepackage{subcaption}
\usepackage{pdflscape}
\usepackage{etoolbox}
\usepackage{pdfpages}
\usepackage{atbegshi}
\makeatletter
\newcommand*{\AM@pagecommandstar}{}
\define@key{pdfpages}{pagecommand*}{\def\AM@pagecommandstar{#1}}
\patchcmd{\AM@output}{\begingroup\AM@pagecommand\endgroup}
{\ifthenelse{\boolean{AM@firstpage}}{\begingroup\AM@pagecommandstar\endgroup}{\begingroup\AM@pagecommand\endgroup}}{}{} % Patch to use new option
\patchcmd{\AM@split@optionsii}{\equal{pagecommand}{\AM@temp}\or}
{\equal{pagecommand}{\AM@temp}\or\equal{pagecommand*}{\AM@temp}\or}{}{}
\makeatother
\usepackage{capt-of}
\usepackage[utf8]{inputenc} % Any characters can be typed directly from the keyboard, eg éçñ
\usepackage{textcomp} % provide lots of new symibols
\usepackage{graphicx} % Add graphics capabilities
%\usepackage{epstopdf} % to include .eps graphics files with pdfLaTeX
\usepackage{flafter} % Don't place floats before their definition
%\usepackage{topcapt} % Define \topcation for placing captions above tables (not in gwTeX)
% \usepackage{natbib} % use author/date bibliographic citations
\usepackage{amsmath,calc}
\usepackage{amsmath,amssymb} % Better maths support & more symbols
\usepackage{bm} % Define \bm{} to use bold math fonts
\usepackage{hyperref}
\usepackage{caption}
\usepackage{titlesec}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{rotating}
\usepackage[babel]{csquotes}
\usepackage[backend=biber]{biblatex}
\addbibresource{library.bib} % with extension
\setcounter{secnumdepth}{4}
\titleformat{\paragraph}
{\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}
\titlespacing*{\paragraph}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
% PDF hyperlinks, with coloured links
\hypersetup{linkcolor=red,citecolor=blue,filecolor=dullmagenta,urlcolor=darkblue} % coloured links
%\hypersetup{linkcolor=black,citecolor=black,filecolor=black,urlcolor=black} % black links, for printed output
\usepackage{memhfixc} % remove conflict between the memoir class & hyperref
% \usepackage[activate]{pdfcprot} % Turn on margin kerning (not in gwTeX)
\usepackage{pdfsync} % enable tex source and pdf output syncronicity
\newcommand\scalemath[2]{\scalebox{#1}{\mbox{\ensuremath{\displaystyle t#2}}}}
\newcommand{\norm}[1]{\left\lVert#1\right\rVert}
\begin{document}
\begin{table}[]
\centering
\caption{My caption}
\label{my-label}
\begin{tabular}{llll}
\multicolumn{1}{c}{Start composition} & \multicolumn{1}{c}{End composition} & \multicolumn{1}{c}{Relative error} & \multicolumn{1}{c}{Net convective flux $\frac{mol}{m^2 s}$} \\
\multicolumn{1}{c}{{[}0.4; 0.3; 0.3{]}} & \multicolumn{1}{c}{{[}0.5; 0.4; 0.1{]}} & \multicolumn{1}{c}{0.0948} & \multicolumn{1}{c}{-4.481e-5} \\
{[}0.4; 0.3; 0.3{]} & {[}0.5; 0.41; 0.09{]} & 0.1110 & -4.845e-5 \\
{[}0.4; 0.3; 0.3{]} & {[}0.5; 0.42; 0.08{]} & 0.13 & -5.503e-5 \\
{[}0.4; 0.3; 0.3{]} & {[}0.5; 0.43; 0.07{]} & 0.1520 & -5.8641e-5 \\
{[}0.4; 0.3; 0.3{]} & {[}0.5; 0.44; 0.06{]} & 0.1803 & -6.508e-5 \\
{[}0.4; 0.3; 0.3{]} & {[}0.5; 0.45; 0.05{]} & 0.2099 & -7.2323e-5 \\
{[}0.4; 0.3; 0.3{]} & {[}0.5; 0.46; 0.04{]} & 0.2506 & -8.1422e-5 \\
{[}0.4; 0.3; 0.3{]} & {[}0.5; 0.47; 0.03{]} & 0.3002 & -9.3138e-5 \\
{[}0.4; 0.3; 0.3{]} & {[}0.5; 0.48; 0.02{]} & 0.3626 & -1.0982e-4 \\
{[}0.4; 0.3; 0.3{]} & {[}0.5; 0.49; 0.01{]} & 0.4593 & -1.3841e-4 \\
{[}0.4; 0.3; 0.3{]} & {[}0.5; 0.5; 0.0{]} & 0.9588 & -0.0019
\end{tabular}
\end{table}
\end{document}
我在多行中收到的错误是额外的对齐制表符已更改为 \cr。
如果这个问题能得到解决的话,对我真的很有帮助,谢谢!
答案1
您可能更喜欢使用命令来布局每一行,这样可以节省输入时间,并且可以更轻松地更改布局。
\documentclass[11pt, oneside]{article}
\usepackage{geometry}
\geometry{letterpaper}
%\geometry{landscape}
%\usepackage[parfill]{parskip}
\usepackage{graphicx}
\usepackage{eqnarray,amsmath}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{mathtools}
\usepackage{setspace}
\onehalfspacing
\usepackage[T1]{fontenc}
\usepackage{subcaption}
\usepackage{pdflscape}
\usepackage{etoolbox}
\usepackage{pdfpages}
\usepackage{atbegshi}
\makeatletter
\newcommand*{\AM@pagecommandstar}{}
\define@key{pdfpages}{pagecommand*}{\def\AM@pagecommandstar{#1}}
\patchcmd{\AM@output}{\begingroup\AM@pagecommand\endgroup}
{\ifthenelse{\boolean{AM@firstpage}}{\begingroup\AM@pagecommandstar \endgroup}{\begingroup\AM@pagecommand\endgroup}}{}{} % Patch to use new option
\patchcmd{\AM@split@optionsii}{\equal{pagecommand}{\AM@temp}\or}
{\equal{pagecommand}{\AM@temp}\or\equal{pagecommand*}{\AM@temp}\or}{}{}
\makeatother
\usepackage{capt-of}
\usepackage[utf8]{inputenc} % Any characters can be typed directly from the keyboard, eg éçñ
\usepackage{textcomp} % provide lots of new symibols
\usepackage{graphicx} % Add graphics capabilities
%\usepackage{epstopdf} % to include .eps graphics files with pdfLaTeX
\usepackage{flafter} % Don't place floats before their definition
%\usepackage{topcapt} % Define \topcation for placing captions above tables (not in gwTeX)
% \usepackage{natbib} % use author/date bibliographic citations
\usepackage{amsmath,calc}
\usepackage{amsmath,amssymb} % Better maths support & more symbols
\usepackage{bm} % Define \bm{} to use bold math fonts
\usepackage{hyperref}
\usepackage{caption}
\usepackage{titlesec}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{rotating}
\usepackage[babel]{csquotes}
\usepackage[backend=biber]{biblatex}
\addbibresource{library.bib} % with extension
\setcounter{secnumdepth}{4}
\titleformat{\paragraph}
{\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}
\titlespacing*{\paragraph}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
% PDF hyperlinks, with coloured links
\hypersetup{linkcolor=red,citecolor=blue,filecolor=dullmagenta,urlcolor=darkblue} % coloured links
%\hypersetup{linkcolor=black,citecolor=black,filecolor=black,urlcolor=black} % black links, for printed output
\usepackage{memhfixc} % remove conflict between the memoir class & hyperref
% \usepackage[activate]{pdfcprot} % Turn on margin kerning (not in gwTeX)
\usepackage{pdfsync} % enable tex source and pdf output syncronicity
\newcommand\scalemath[2]{\scalebox{#1}{\mbox{\ensuremath{\displaystyle t#2}}}}
\newcommand{\norm}[1]{\left\lVert#1\right\rVert}
\begin{document}
\newcommand{\data}[8]{[#1; #2; #3] & [#4; #5; #6] & #7 & #8 \\}
\begin{table}[]
\centering
\caption{My caption}
\label{my-label}
\begin{tabular}{llll}
\toprule
Start composition & End composition & Relative error & Net convective flux $\frac{mol}{m^2 s}$ \\
\midrule
\data{0.4}{0.3}{0.3}{0.5}{0.41}{0.09}{0.1110}{-4.845e-5}
\data{0.4}{0.3}{0.3}{0.5}{0.41}{0.09}{0.1110}{-4.845e-5}
\data{0.4}{0.3}{0.3}{0.5}{0.41}{0.09}{0.1110}{-4.845e-5}
\data{0.4}{0.3}{0.3}{0.5}{0.41}{0.09}{0.1110}{-4.845e-5}
\data{0.4}{0.3}{0.3}{0.5}{0.41}{0.09}{0.1110}{-4.845e-5}
\data{0.4}{0.3}{0.3}{0.5}{0.41}{0.09}{0.1110}{-4.845e-5}
\data{0.4}{0.3}{0.3}{0.5}{0.41}{0.09}{0.1110}{-4.845e-5}
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案2
我没有从您的代码中得到任何错误,但问题是已知的:而不是{[}
使用\relax
之后\\
。
[0.4; 0.3; 0.3] & [0.5; 0.41; 0.09] & 0.1110 & -4.845e-5 \\ \relax
[0.4; 0.3; 0.3] & [0.5; 0.42; 0.08] & 0.13 & -5.503e-5 \\ \relax
答案3
在我看来,最简单的解决方法是如果下一行以符号开头,则将“ ”替换\\
为“ ” 。\\\relax
[
我还建议您更改第 3 列和第 4 列的列类型,以便列中的数字在各自的小数点标记上对齐(水平)。
\documentclass[a4paper,12pt]{article}
\usepackage{siunitx,booktabs}
\usepackage[skip=0.333\baselineskip]{caption}
\begin{document}
\begin{table}
\centering
\caption{My caption}
\label{my-label}
\begin{tabular}{@{}cc
S[table-format=1.4]
S[table-format=-1.4e1,tight-spacing] @{}}
Start composition & End composition & {Relative error} & {Net convective flux} \\
&&& {(\si[per-mode=symbol]{\mol\per\meter\squared})}\\
\midrule\relax
[0.4; 0.3; 0.3] & [0.5; 0.40; 0.10] & 0.0948 & -4.481e-5 \\\relax
[0.4; 0.3; 0.3] & [0.5; 0.41; 0.09] & 0.1110 & -4.845e-5 \\\relax
[0.4; 0.3; 0.3] & [0.5; 0.42; 0.08] & 0.13 & -5.503e-5 \\\relax
[0.4; 0.3; 0.3] & [0.5; 0.43; 0.07] & 0.1520 & -5.8641e-5 \\\relax
[0.4; 0.3; 0.3] & [0.5; 0.44; 0.06] & 0.1803 & -6.508e-5 \\\relax
[0.4; 0.3; 0.3] & [0.5; 0.45; 0.05] & 0.2099 & -7.2323e-5 \\\relax
[0.4; 0.3; 0.3] & [0.5; 0.46; 0.04] & 0.2506 & -8.1422e-5 \\\relax
[0.4; 0.3; 0.3] & [0.5; 0.47; 0.03] & 0.3002 & -9.3138e-5 \\\relax
[0.4; 0.3; 0.3] & [0.5; 0.48; 0.02] & 0.3626 & -1.0982e-4 \\\relax
[0.4; 0.3; 0.3] & [0.5; 0.49; 0.01] & 0.4593 & -1.3841e-4 \\\relax
[0.4; 0.3; 0.3] & [0.5; 0.50; 0.00] & 0.9588 & -0.0019
\end{tabular}
\end{table}
\end{document}