![LaTeX 和 LyX 表中的千位分隔符](https://linux22.com/image/317566/LaTeX%20%E5%92%8C%20LyX%20%E8%A1%A8%E4%B8%AD%E7%9A%84%E5%8D%83%E4%BD%8D%E5%88%86%E9%9A%94%E7%AC%A6.png)
我想在LyX
表格中获得千位分隔符。我有以下LaTeX
代码。它对第二列运行良好,但对第一列则不行,而且当我将其导入 LyX 时,它会添加额外的列并引发以下错误:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! siunitx error: "unknown-option"
!
! Unknown option 'tace-forct'.
!
! See the siunitx documentation for further information.
!
! For immediate help type H <return>.
!...............................................
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[group-separator={,}]{siunitx}
\makeatletter
\providecommand{\tabularnewline}{\\}
\makeatother
\usepackage{babel}
\begin{document}
\begin{tabular}{l*{2}{S[table-format=8.0]S[table-format=2.1]}}
X & Y\tabularnewline
2393527 & 1097991\tabularnewline
2998621 & 1460713\tabularnewline
3461273 & 1604816\tabularnewline
4592720 & 2309517\tabularnewline
4753075 & 1966610\tabularnewline
5334976 & 2192553\tabularnewline
5984026 & 2625223\tabularnewline
6575316 & 2720514\tabularnewline
\end{tabular}
\end{document}
如果有人能指导我如何在 LyX 表格中获取千位分隔符,我将不胜感激。谢谢
答案1
您对表格环境的定义存在错误。虽然表格仅包含两列,但 的参数中指定的列数\begin{tabular}
更大:有一列向左对齐(l
),并且有其他列的格式由 指定S[table_format=..]
。
您可以尝试这个稍微修改过的代码:
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[group-separator={,}]{siunitx}
\makeatletter
\providecommand{\tabularnewline}{\\}
\makeatother
\usepackage{babel}
\begin{document}
\begin{tabular}{*{2}{S[table-format=8.0]}}
X & Y\tabularnewline
2393527 & 1097991\tabularnewline
2998621 & 1460713\tabularnewline
3461273 & 1604816\tabularnewline
4592720 & 2309517\tabularnewline
4753075 & 1966610\tabularnewline
5334976 & 2192553\tabularnewline
5984026 & 2625223\tabularnewline
6575316 & 2720514\tabularnewline
\end{tabular}
\end{document}
要在 LyX 中获得正确的输出,请尝试以下操作:选择 X 列,右键单击“更多...”->“设置...”,输入“S”(不带引号)作为“LaTeX 参数”,然后单击“应用”->“确定”。对 Y 列重复相同操作。