3

I want to get thousand separator in LyX tables. I had the following LaTeX code. It works fine for the second column but not for the first column and also when I import it into LyX it adds extra columns and throws the following error:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! 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}

I'd highly appreciate if someone guide me how to get thousand separator in LyX tables. Thanks

1
  • That error simply means that you have mistyped (or that LyX somehow misinterprets) table-format, so LaTeX sees tace-forct.
    – egreg
    Aug 23 '15 at 9:00
4

There is a mistake in your definition of the tabular environment. While the table contains only two columns, the number of columns specified in the argument of \begin{tabular} is larger: there is one column aligned to the left (l) and additional columns with a format specified by S[table_format=..].

You could try this slightly modified code instead:

\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}

enter image description here

To obtain the correct output in LyX try the following: select column X, right click "More..." -> "Settings...", enter "S" (without quotation marks) as "LaTeX argument" and click "Apply" -> "OK". Repeat the same for column Y.

4
  • Thanks @RHertel for your answer. Your code works fine in LaTeX but I import it into LyX, it adds extra columns and also throws the same error as I had before. Any thoughts.
    – MYaseen208
    Aug 23 '15 at 8:10
  • Please check the updated post concerning the formatting of the table with LyX. Although there are some initial error messages and the table displays additional columns in the editor, the output is correct after those changes in the settings in LyX. I hope this helps.
    – RHertel
    Aug 23 '15 at 8:56
  • Thanks @RHertel for excellent answer. After typing S I could not allign the columns. Anyhow thanks.
    – MYaseen208
    Aug 23 '15 at 9:13
  • @RHertel, It is strange, but this does not work for some numbers (e.g., 8859) in the cells! Instead, I used "\usepackage[group-separator={,}, group-four-digits]{siunitx}" as the siunitx package definition and it works.
    – Alisa
    Oct 12 '17 at 23:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.