3

So with the new version of siunitx there is this woderful command called \qty{}{}, yet in my table, I would like to have the numerical value aligned on the decimal point (the g_m coloumn).

The quick woraround would be to separate this last coloumn into two, the first ona as an S -type, only with numerical value, then the last one an usual l -type with the unit using the \unit{} command.

But I bet there is a way, tweaking some setting in the table, to make \qty{}{} work the way I need.

The thing is I'm not familiar with the IEEE format yet. And this answer about \qty just span my table in an ugly way (still using the full code, preamble and so on, from my prevoius question my prevoius question about siunitx).

\begin{table}[!th]
    \renewcommand{\arraystretch}{1.3}
    \caption{Parameters of Mn\textsubscript{3} and Mn\textsubscript{4}}
    \label{tab:CM-1}
    \sisetup{
        table-alignment-mode = marker,        % changed from FORMAT
        table-number-alignment = center,
        table-figures-integer = 1,
        table-figures-decimal = 4,
    }
    \centering
    \begin{tabular}{l*{4}{S}}
        \toprule
        {Transistor}    & {W/L} & {W}   & {L}   & {g\textsubscript{m}}  \\
        \midrule
         Mn\textsubscript{3}    & \num{2.696}   & \qty{8.7}{\um}    & \qty{1}{\um}  & \qty{200}{\micro S}   \\
         Mn\textsubscript{4}    & \num{2.899}   & \qty{2.9}{\um}    & \qty{1}{\um}  & \qty{66.7}{\micro S}  \\
        \bottomrule     
    \end{tabular}
\end{table}

That gives the following output, gm not decimal aligned

Fr3d
  • 141
  • 3
    Firstly, please always provide a full but minimal example and not a sniplet like this. Secondly, it is more traditional to add the unit as a part of the header. Then the S column can do its thing with the amount part. Here I don't think it is supported for S to look inside \num or \qty. – daleif Apr 19 '23 at 08:08
  • Sorry, I always think that's a common use, I tend to forget it is highly costumizable using so many packages and they may interfere one with the other, or there can be a missing one.... – Fr3d Apr 19 '23 at 14:37

2 Answers2

6

Each cell under the column type S is parsed by siunitx, which expects numbers. Otherwise, you will get errors.

If you really want units next to every number in the table, one way is to physically add \unit{} after each quantity. It can be done in column definition. However because of S, extra space occupied by units also has to be "added". The code below produces an output, which I believe is something you would expect

enter image description here

and the code

\documentclass{article}
\usepackage{siunitx}
\usepackage{booktabs}

\begin{document} \begin{table}[!th] \renewcommand{\arraystretch}{1.3} \caption{Parameters of Mn\textsubscript{3} and Mn\textsubscript{4}} \label{tab:CM-11} \sisetup{ table-alignment-mode = marker, % changed from FORMAT table-number-alignment = center, table-figures-integer = 1, table-figures-decimal = 4, % table-align-text-after = false, % units stick to quantities } \centering \begin{tabular}{ l S[table-format=1.3] S[table-format=1.1{,\unit{\micro\metre}}]<{,\unit{\micro\metre}} S[table-format=1.0{,\unit{\micro\metre}}]<{,\unit{\micro\metre}} S[table-format=3.1{,\unit{\micro\siemens}}]<{,\unit{\micro\siemens}} } \toprule Transistor & {W/L} & \multicolumn{1}{c}{W} & \multicolumn{1}{c}{L} & \multicolumn{1}{c}{g\textsubscript{m}} \ \midrule Mn\textsubscript{3} & 2.696 & 8.7 & 1 & 200 \ Mn\textsubscript{4} & 2.899 & 2.9 & 1 & 66.7 \ \bottomrule
\end{tabular} \end{table} \end{document}


IMO you should avoid repeated information in cells. Hence, I would move units to the corresponding headers and leave only numbers in the body. I see this as a clearer output

enter image description here

and the code

\documentclass{article}
\usepackage{siunitx}
\usepackage{booktabs}

\begin{document} \begin{table}[!th] \renewcommand{\arraystretch}{1.3} \caption{Parameters of Mn\textsubscript{3} and Mn\textsubscript{4}} \label{tab:CM-1} \sisetup{ table-alignment-mode = marker, % changed from FORMAT table-number-alignment = center, table-figures-integer = 1, table-figures-decimal = 4, } \centering \begin{tabular}{l S[table-format=1.3] S[table-format=1.1] S[table-format=1.0] S[table-format=3.1]} \toprule {Transistor} & {W/L} & {W} & {L} & {g\textsubscript{m}} \ \cmidrule(lr){3-4}\cmidrule(lr){5-5} & & \multicolumn{2}{c}{(\unit{\micro\metre})} & {(\unit{\micro\siemens})} \ \midrule Mn\textsubscript{3} & 2.696 & 8.7 & 1 & 200 \ Mn\textsubscript{4} & 2.899 & 2.9 & 1 & 66.7 \ \bottomrule
\end{tabular} \end{table} \end{document}

Celdor
  • 9,058
4

You should not repeat the unit in every cell, but write it in the header in parentheses.

I recommend using newtx with IEEEtran so you get math symbols compatible with Times. A further bit has to be added, since the LaTeX kernel doesn't (yet) know about the full set of TS1 symbols in newtx.

Now you can get precise alignment of the figures by specifying the format for each column.

There is the abbreviation \um for \micro\meter, but there isn't one for the siemens, better spelling it out and not mixing \micro S.

I guess that the headers in the last four columns should be in math mode.

\documentclass{IEEEtran}
\usepackage[T1]{fontenc}
\usepackage{newtxtext,newtxmath}
\usepackage{booktabs,siunitx}

% newtx has the full set \DeclareEncodingSubset{TS1}{ntxtlf}{0}

\begin{document}

\begin{table}[!ht] \centering

\caption{Parameters of Mn\textsubscript{3} and Mn\textsubscript{4}} \label{tab:CM-1}

\begin{tabular}{ @{} l S[table-format=1.3] S[table-format=1.1] S[table-format=1.0] S[table-format=3.1] @{} } \toprule Transistor & {$W/L$} & {$W$} & {$L$} & {$g_{m}$} \ & & {(\unit{\um})} & {(\unit{\um})} & {(\unit{\micro\siemens})} \ \midrule Mn\textsubscript{3} & 2.696 & 8.7 & 1 & 200 \ Mn\textsubscript{4} & 2.899 & 2.9 & 1 & 66.7 \ \bottomrule \end{tabular}

\end{table}

\end{document}

enter image description here

egreg
  • 1,121,712
  • Thanks for your reply @egreg, I lazyly just copied and did some light modification to fit my needs, of the first table in the document, a tabular environment {llSl} that had all the specification for the project, with many different units, put in the las coloumn. So to look consistently, I used the prefix, but not the unit \siemens. If it's stupid and it works, ..... – Fr3d Apr 19 '23 at 14:48