How can I align the negative decimal numbers in a matrix which is in a table as siunitx
do with numbers in a table (I am using the class elsarticle option:twocolumn)
\documentclass[5p,twocolumn]{elsarticle}
\usepackage{booktabs,tabularx}
\usepackage{amsmath}
\begin{document}
\begin{table}
\caption{Algorithm 3 Illustrative calculation for Numerical Example 2}
\label{tab:Example 2.2}
% \centering
\footnotesize%scriptsize
\setlength\tabcolsep{1pt}
\setlength\arraycolsep{2pt}
\begin{tabular}{ll}
\toprule
\normalfont Algorithm steps
& Numerical computation\\
\midrule
Input & Given\\
& $ \mathbf{U}|_{\theta=0.5} = \begin{bmatrix} -1 & 1 & 0.2298 & 0.5000 & 0.7702 & 0.1250 \end{bmatrix}^T$\\
& $\mathbf{U}'_{\theta}|_{\theta =0.5} = \begin{bmatrix} -2 & 2 & 0.8415 & 1 & -0.8415 & 0.7500 \end{bmatrix}^T$\\
& $ \mathbf{v} = \begin{bmatrix} -2.7063 & 1.0000 & 0.2298 & 0.5000 & 0.7702 & 0.1250 \end{bmatrix}^T$\\
& $ \mathbf{u} = \begin{bmatrix} -0.8905 & 0.3290 & 0.0756 & 0.1645 & 0.2534 & 0.0411 \end{bmatrix}^T$\\
\midrule
Step 1: & Compute $\|\mathbf{U}\|'_{\theta} = 2.4257$\\
Step 3: & Compute $\mathbf{v}'_{\theta} =$ \\
& $\begin {bmatrix}
-4.4257 & 2.0000 & 0.8415 & 1.0000 & -0.8415 & 0.7500
\end{bmatrix}^T$\\
Step 7: & Compute $\|\mathbf{v}'_{\theta}\| = 4.6451$\\
Step 8: & Compute $\mathbf{u}'_{\theta} = $ \\
& $\begin {bmatrix}
-0.0952 & 0.1552 & 0.1613 & 0.0776 & -0.6642 & 0.1839
\end{bmatrix}^T$\\
Step 9: & Compute $ \mathbf{Q}'_{\theta} = $\\
& $\begin{bmatrix}
-0.3390 & 0.3390 & 0.3017 & 0.1695 & -1.1348 & 0.3354\\
0.3390 & 0.2042 & -0.1296 & -0.1021 & 0.3585 & -0.1338\\
0.3017 & -0.1296 & -0.0488 & -0.0648 & 0.0178 & -0.0411\\
0.1695 & -0.1021 & -0.0648 & -0.0511 & 0.1792 & -0.0669\\
-1.1348 & 0.3585 & 0.0187 & 0.1792 & 0.6733 & -0.0386\\
0.3354 & -0.1338 & -0.0411 & -0.0669 & -0.0386 & -0.0303
\end{bmatrix}$\\
Step 10: & Extract $\mathbf{Q}'_{\theta} = \mathbf{Q}'_{\theta}(1,1:6)= $\\
&$\begin{bmatrix} -0.3390 & 0.3390 & 0.3017 & 0.1695 & -1.1348 & 0.3354 \end{bmatrix}^T$\\
Step 11: & $\mathbf{R}'_{\theta} = \begin{bmatrix} 2.4257 \end{bmatrix}$ \\
\midrule
Output & $\mathbf{R}'|_{\theta = 0.5} = \begin{bmatrix} 2.4257 \end{bmatrix}$\\
\midrule
Test & Accuracy of the computations:\\
& $\|(\mathbf{U}^T\mathbf{U})'_{\theta}|_{\theta=0.5} - (\mathbf{R}^T\mathbf{R})'_{\theta}|_{\theta=0.5}\|=1.7764\cdot10^{-15}$\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
Best Answer
Since all your numbers have the exact same number of digits but only differ by having a minus sign or not, the easiest thing to do is to right-align the columns of the matrix, using the
bmatrix*
environment from themathtools
package. See the answers to this question for more ways of aligning matrix elements.