Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option table-number-alignment=none #513

Closed
lvjr opened this issue Jul 22, 2021 · 3 comments
Closed

Option table-number-alignment=none #513

lvjr opened this issue Jul 22, 2021 · 3 comments

Comments

@lvjr
Copy link

lvjr commented Jul 22, 2021

In issue #510, I only mentioned table-text-alignment, but in fact table-number-alignment=none is also needed (and also for table-alignment). Sorry, I was not very familiar with siunitx package.

@josephwright
Copy link
Owner

There's a fundamental difference for numbers: there's already table-alignment-mode, as the entire method used to do alignment is selectable. Presumably you'll want table-alignment-mode = none? If you turn off the number alignment, then the columns won't come out with the decimal mark aligned. But that's going to happen whatever one does. Or are you imagining something quite different?

@josephwright
Copy link
Owner

josephwright commented Jul 22, 2021

I'm wondering if there's a (public) way of telling the code is 'inside' a tabularray cell? If so, I could just arrange that the relevant internals don't do anything without needing a setting. (I'm still not really getting what the issue is - (centred) table cells are of one of two forms: \hfil <content> \hfil or \hskip 0pt plus 0.5fill \kern 0pt <content> \hskip 0pt plus 0.5fill.)

@lvjr
Copy link
Author

lvjr commented Jul 22, 2021

I read the documentation of siunitx again and did some tests. Now I think it is a better choice to let siunitx do table-number-alignment and let tabularray do table-text-alignment only.
It works and we don't need to do anything further (at least for these simple examples I tested)

%  -*- coding: utf-8 -*-
\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}
\setlength{\parindent}{0pt}
\begin{document}

\section{table-alignment-mode=format}

Tabular:

\begin{tabular}{
 |S[table-column-width=4em,table-format=2.3,table-alignment=left]
 |S[table-column-width=4em,table-format=2.3,table-alignment=center]
 |S[table-column-width=4em,table-format=2.3,table-alignment=right]|
}
\hline
  {A}    & {B}    & {C}    \\
\hline
  11     & 11     & 11     \\
\hline
   2.111 &  2.222 &  2.333 \\
\hline
  33.11  & 33.22  & 33.33  \\
\hline
\end{tabular}

\bigskip

Tabularray:

\begin{tblr}{
 hlines, vlines, columns = {4em},
 colspec={
   Q[si={table-format=2.3,table-number-alignment=left},l]
   Q[si={table-format=2.3,table-number-alignment=center},c]
   Q[si={table-format=2.3,table-number-alignment=right},r]
 }
}
  {{{A}}} & {{{B}}} & {{{C}}} \\
  11      & 11      & 11      \\
   2.111  &  2.222  &  2.333  \\
  33.11   & 33.22   & 33.33   \\
\end{tblr}

\section{table-alignment-mode=none}

Tabular:

\begin{tabular}{
 |S[table-column-width=4em,table-alignment-mode=none,table-alignment=left]
 |S[table-column-width=4em,table-alignment-mode=none,table-alignment=center]
 |S[table-column-width=4em,table-alignment-mode=none,table-alignment=right]|
}
\hline
  {A}    & {B}    & {C}    \\
\hline
  11     & 11     & 11     \\
\hline
   2.111 &  2.222 &  2.333 \\
\hline
  33.11  & 33.22  & 33.33  \\
\hline
\end{tabular}

\bigskip

Tabularray:

\begin{tblr}{
 hlines, vlines, columns = {4em},
 colspec={
   Q[si={table-alignment-mode=none,table-number-alignment=left},l]
   Q[si={table-alignment-mode=none,table-number-alignment=center},c]
   Q[si={table-alignment-mode=none,table-number-alignment=right},r]
 }
}
  {{{A}}} & {{{B}}} & {{{C}}} \\
  11      & 11      & 11      \\
   2.111  &  2.222  &  2.333  \\
  33.11   & 33.22   & 33.33   \\
\end{tblr}

\section{table-alignment-mode=marker}

Tabular:

\begin{tabular}{
 |S[table-column-width=4em,table-alignment-mode=marker]
 |S[table-column-width=4em,table-alignment-mode=marker]
 |S[table-column-width=4em,table-alignment-mode=marker]|
}
\hline
  {A}    & {B}    & {C}    \\
\hline
  11     & 11     & 11     \\
\hline
   2.111 &  2.222 &  2.333 \\
\hline
  33.11  & 33.22  & 33.33  \\
\hline
\end{tabular}

\bigskip

Tabularray:

\begin{tblr}{
 hlines, vlines, columns = {4em},
 colspec={
   Q[si={table-alignment-mode=marker},c]
   Q[si={table-alignment-mode=marker},c]
   Q[si={table-alignment-mode=marker},c]
 }
}
  {{{A}}} & {{{B}}} & {{{C}}} \\
  11      & 11      & 11      \\
   2.111  &  2.222  &  2.333  \\
  33.11   & 33.22   & 33.33   \\
\end{tblr}

\end{document} 

image

@lvjr lvjr closed this as completed Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants