2

I am using the following code, based on How to use letter with SI unit in table using siunitx to create a table.

How can i make the column wide enouth to fit the content. Whats the best way for the dimensions column setup?

enter image description here

\begin{table}[!htp] % not just 'h!'
\centering % not a center environment
\begin{tabular}{
        @{}
        l
        S[table-format=1.1]
        S[table-format=1.3]
        S[table-format=1.2]
        S[table-format=1.2]
        S[table-format=1.2]
        @{}
    }
    \toprule
    Inductor &
    {$size$} &
    {$inductance$} &
    {$sensitivity$} &
    {$dc resistance d$} &
    {$SRF$}\\
    &
    {(\si{\milli\meter})} &
    {(\si{\milli\henry})} &
    {(\si{\milli\volt\per\ampere\meter})} &
    {(\si{\ohm})} &
    {(\si{\kilo\hertz})} \\
    \midrule
    Premo       &8.6x3x2.7 &18.5 &90 &165 &300  \\
    TDK         &7x12x33   &8.6   &23 &112 &135     \\
    \bottomrule
\end{tabular}
\label{tab:inductor}

\end{table}
3
  • Not related to the question, but do not use math mode ($) in order to get italic text. Use \textit instead.
    – leandriis
    Aug 7, 2019 at 9:01
  • Are you sure about \milli\volt\per\ampere\meter? Shouldn't it be \milli\volt\per\ampere\per\meter?
    – egreg
    Aug 7, 2019 at 9:26
  • To be correct it should be (mV)/(A/m), but this is the same as (mV*m)/A. But i am not familiar with the interpretation of this writing terminology.
    – Rico
    Aug 7, 2019 at 10:19

2 Answers 2

3

At a standard line width, the table is slightly overfull, so I use a tabular* trick; you'll need to check whether this works and the intercolumn space is adequate, otherwise you may resort to \small.

The second column is not S, but you should use \num for its entries. Set properly the number of digits for the other columns.

Please, don't use math mode for italics: it's not meant for that purpose.

\documentclass[a4paper]{article}
\usepackage{amsmath,siunitx,booktabs}

\begin{document}

\begin{table}[htp]
\centering

\setlength{\tabcolsep}{0pt} % let TeX do the calculations
\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  l
  c
  S[table-format=2.1]
  S[table-format=2.0]
  S[table-format=3.0]
  S[table-format=3.0]
  @{}
}
\toprule
Inductor &
  {\itshape size} &
  {\itshape inductance} &
  {\itshape sensitivity} &
  {\itshape DC resistance $d$} &
  {\itshape SRF}\\
&
  {(\si{\milli\meter\cubed})} &
  {(\si{\milli\henry})} &
  {(\si{\milli\volt\per\ampere\meter})} &
  {(\si{\ohm})} &
  {(\si{\kilo\hertz})} \\
\midrule
Premo & \num{8.6x3x2.7} & 18.5 & 90 & 165 & 300 \\
TDK   & \num{7x12x33}   &  8.6 & 23 & 112 & 135 \\
\bottomrule
\end{tabular*}

\caption{A table}\label{xyz}

\end{table}

\end{document}

enter image description here

1
  • Very smart trick to get a tabular to fit.
    – Sveinung
    Aug 7, 2019 at 11:35
2

It makes no real sense to use a S column specifier for the size column. However, use the notation {...} if you have not a number in the column cell and, of course, use proper specifications for numbers: 3.1 (iii.d) reserves space for three integers and one decimal

\documentclass[a4paper, 12pt]{article}
\usepackage{amsmath,siunitx,booktabs}

\begin{document}

\begin{tabular}{
        @{}
        l
        S[table-format=1.1]
        S[table-format=2.1]
        S[table-format=2.1]
        S[table-format=3.1]
        S[table-format=3.1]
        @{}
    }
    \toprule
    Inductor &
    {\itshape size} &
    {\itshape inductance} &
    {\itshape sensitivity} &
    {\itshape dc resistance d} &
    {\itshape SRF}\\
    &
    {(\si{\milli\meter})} &
    {(\si{\milli\henry})} &
    {(\si{\milli\volt\per\ampere\meter})} &
    {(\si{\ohm})} &
    {(\si{\kilo\hertz})} \\
    \midrule
    Premo       &{8.6x3x2.7} &18.5 &90 &165 &300  \\
    TDK         &{7x12x33}   &8.6   &23 &112 &135     \\
    \bottomrule
\end{tabular}

\end{document}

enter image description here

2
  • 1
    You might also want to correct the wron use of math mode to get italic text.
    – leandriis
    Aug 7, 2019 at 9:02
  • 1
    thanks, I looked only for the S[...] ... :-( Now edited
    – user187802
    Aug 7, 2019 at 9:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .