我的文档中有一个多行多列的表格。这在 Fedora 上编译得很好,但在 Ubuntu 上编译时遇到问题。Fedora 和 Ubuntu 的 pdflatex 版本不同。我的 MWE 如下:
\documentclass{article}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{multirow}
\begin{document}
\begin{table}
\caption{Table Example}
\label{Table1}
\centering
\begin{tabular}{S[table-text-alignment=left]SSSS}
\toprule
\multirow{2}{*}{Two Rows} & \multirow{2}{*}{\makecell{Long\\ Data}} & \multicolumn{3}{c}{Short Data}\\
\cmidrule{3-5}
& & {First Column} & {Second Column} & {Third Column}\\
\midrule
{Data One} & 0 & 1 & 5 & 65 \\
{Data Two} & 1 & 0 & 32 & 235 \\
{Data Three} & 0 & 0 & 2 & 0 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
Fedora 上的 Latex 详细信息如下:
$ pdflatex --version
pdfTeX 3.14159265-2.6-1.40.17 (TeX Live 2016)
kpathsea version 6.2.2
Copyright 2016 Han The Thanh (pdfTeX) et al.
There is NO warranty. Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.31; using libpng 1.6.31
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with poppler version 0.57.0
Ubuntu 上的 Latex 详细信息如下:
$ pdflatex --version
pdfTeX 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian)
kpathsea version 6.2.3
Copyright 2017 Han The Thanh (pdfTeX) et al.
There is NO warranty. Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.34; using libpng 1.6.34
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with poppler version 0.62.0
在 Ubuntu 上编译时出现第 16 行的多个错误
\multirow{2}{*}{Two Rows} & \multirow{2}{*}{\makecell{Long\\ Data}} & \multicolumn{3}{c}{Short Data}\\
下面我仅给出 Ubuntu 上 pdflatex 的简短错误信息
Extra }, or forgotten $.
Missing $ inserted.
Missing } inserted.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! siunitx error: "invalid-number"
!
! Invalid numerical input '='.
这些错误仅当我在 Ubuntu(TeX Live 2017/Debian)上使用 pdflatex 编译代码时才会发生,而在 Fedora(TeX Live 2016)上使用 pdflatex 编译时则不会出现错误。我在 Fedora 和 Ubuntu 系统之间切换工作。如果有人能帮助解决这些错误,以便我的 MWE 也可以在 Ubuntu 系统上编译,我将不胜感激。
提前致谢
A。
答案1
列中的任何文本数据S
都应括在一对括号中{}
。我也同意@Mico的观点,第一列不需要是S
类型。
\documentclass{article}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{multirow}
\begin{document}
\begin{table}
\caption{Table Example}
\label{Table1}
\centering
\begin{tabular}{l*4{S}}
\toprule
\multirow{2}{*}{Two Rows} &
{\multirow{2}{*}{\makecell{Long\\ Data}}} &
\multicolumn{3}{c}{{Short Data}}\\
\cmidrule{3-5}
& & {First Column} & {Second Column} & {Third Column}\\
\midrule
{Data One} & 0 & 1 & 5 & 65 \\
{Data Two} & 1 & 0 & 32 & 235 \\
{Data Three} & 0 & 0 & 2 & 0 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}