I'm trying to align complex numbers in the middle of a table column using the siunitx
package for nicer alignment, but the numbers are centring based on where the decimal point would be on the real parts.
Here's my MWE:
\documentclass[a4paper]{article}
\usepackage{booktabs}
\usepackage{array}
\usepackage{siunitx}
\sisetup{
output-complex-root = \ensuremath{\mathrm{j}},
complex-root-position = before-number
}
\begin{document}
\begin{table}[h!]
\caption{Bus Loads}
\label{fig:figurename}
\centering
\begin{tabular}{l|S[]}
\toprule
\textbf{Bus} & \multicolumn{1}{c}{\textbf{Bus Load (MVA)}} \\
\midrule
b1 & 50 + j30.99 \\
b2 & 170 + j105.35\\
b3 & 200 + j123.94 \\
b4 & 150 + j49.58 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
And here's the output:
I'd like the complex numbers to be more aligned in the centre of the column. Any idea how to do this?
I've tried passing the option table-number-alignment=left
to the column, but then the imaginary part disappears:
Best Answer
Now that we know that complex numbers are not fully supported by the
siunitx
package, here is a workaround that adapts DrJay's solution and uses thecollcell
package to automate the formatting of the number in that the integer real part is right aligned so that the+
sign is aligned:Notes:
Code: