Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Could you tell me what's wrong with next code? I want to get a three columns tabular where numbers are typeset with typewriter family and centred below its header. Numbers won't have any decimal part, they are integers and their decimal, binary and hexadecimal representation.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{siunitx}
\usepackage{booktabs}
\begin{document}

\sisetup{math-rm=\mathtt, 
        group-digits=false, 
        table-figures-decimal=0, 
        table-number-alignment=center,
        input-digits={0123456789ABCDEF}
        }

\begin{tabular}{SS[minimum-integer-digits=8]S}
\toprule
{Decimal} & {Binary} & {Hexadecimal} \\
\midrule
63 & 00111111 & 3F \\
250 & 11111010 & FA \\
117 & 01110101 & 75 \\
220 & 11011100 & DC \\
171 & 10101011 & AB \\
94 & 01011110 & 5E \\
\bottomrule
\end{tabular}
\end{document}

As you can see, second column doesn't have enough space and second and third column are not correctly aligned. What am I misunderstanding in siunitx guide?

enter image description here

share|improve this question

1 Answer 1

up vote 7 down vote accepted

The binary numbers in the second column are centered with table-format=8.0. Also the overfull \hbox warnings are gone:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{siunitx}
\usepackage{booktabs}
\begin{document}

\sisetup{math-rm=\mathtt,
        group-digits=false,
        table-figures-decimal=0,
        table-number-alignment=center,
        input-digits={0123456789ABCDEF}
        }

\begin{tabular}{SS[minimum-integer-digits=8,table-format=8.0]S[table-format=2.0]}
\toprule
{Decimal} & {Binary} & {Hexadecimal} \\
\midrule
63 & 00111111 & 3F \\
250 & 11111010 & FA \\
117 & 01110101 & 75 \\
220 & 11011100 & DC \\
171 & 10101011 & AB \\
94 & 01011110 & 5E \\
\bottomrule
\end{tabular}
\end{document}

Result

share|improve this answer
    
Thank you. I thought that table-figures-decimal=0 was enough. It looks like I also need to specify table-format. But why first column was well aligned without any other information? –  Ignasi Mar 10 at 14:29
    
@Ignasi: I think the default setting of table-figures-integer=3 is the reason that the first column is already centered. –  Heiko Oberdiek Mar 10 at 14:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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