带有 S 说明符的列中的“e+08”(不抑制 0)符号

带有 S 说明符的列中的“e+08”(不抑制 0)符号

出于对称原因,在大型表格中我希望采用 2 位数字的科学计数法格式(即 e+08)。默认情况下,它会隐藏 0。

这是我的做法:

 \documentclass[]{article}

 \usepackage{siunitx}


 \begin{document}

 \begin{table}[htbp]
 \begin{center}
 \footnotesize
 \def\fix#1{\sisetup{output-exponent-marker=\mathrm{e+}}#1}
 \sisetup{output-exponent-marker = \mathrm{e},exponent-product = {},retain-explicit-plus,retain-zero-exponent,table-format=+1.4e+2}
 \begin{tabular}{lSS}
 Sample & {$\mu_1 [Pa]$} & {$\alpha_1 [-]$} \\ \hline
 {Isotropic $10\%$ MREs} & 1.5030e+09 & \fix{4.2384e+00} \\ 
 & 6.7175e+10 & 8.4376e-01 \\
 & 6.7175e+08 & 8.4376e-01  \\ \hline 
 \end{tabular}
 \end{center}
 \caption[]{Scientific notation $e+9$, but for symmetry reasons I would like $e+09$}
 \label{tab:example}
 \end{table}

 \end{document}

这就是输出: 在此处输入图片描述

非常感谢你的帮助!Gerlind

答案1

如果您不介意使用,pgfplotstable您可以使用尾数和指数表达式来获得一些乐趣,并且非常接近。作为奖励,表格输入稍微容易一些,并且对齐显然是自动发生的(没有进行广泛检查)。

\documentclass[]{article}
\usepackage{siunitx,pgfplotstable,booktabs}
\pgfplotsset{compat=1.10}% put your installed version no.
\pgfplotstableset{mycol/.style={
        sci,
        sci zerofill,
        sci precision=4,
        sci generic={
            mantissa sep={e\pgfmathparse{####1<0?"-":"+"}{\pgfmathresult}},
            exponent={%
            \pgfmathparse{abs(####1)<10?0:}\pgfmathresult%
            \pgfmathparse{int(abs(####1)}%
            \pgfmathprintnumber[int detect]{\pgfmathresult}%
            }
        }
    }
}
\begin{document}
\pgfplotstabletypeset[
columns/sample/.style={string type,column name=Sample},
columns/mu/.style={mycol,column name={$\mu_1$ [\si{\pascal}]}},
columns/a/.style={mycol,column name={$\alpha_1 [-]$}},
every head row/.style={before row=\toprule,after row=\midrule},
every last row/.style={after row=\bottomrule},
]{
sample mu a
{Isotropic $10\%$ MREs} 1.5030e9  4.2384
{}                      6.7173e10 8.4376e-1
{}                      6.7173e8  8.4376e-1
{}                      5.1232154654e7 0.0000124564e-12
{}                      1 2
}
\end{document}

在此处输入图片描述

答案2

回答 1 之后我想补充一下我最后做的事情。最终的表格比问题中建议的表格更复杂,并且使用了更多的功能pgfplotstable

\documentclass[]{article}
\usepackage{siunitx,pgfplotstable}
\usepackage{rotating}   
\usepackage[bf,footnotesize]{caption}   
\usepackage{multirow}   
% To increase space of some rows in tables, especially needed before and after \hline
\newcommand\T{\rule{0pt}{2.6ex}}         % Top strut
\newcommand\B{\rule[-1.2ex]{0pt}{0pt}} % Bottom strut
% pgfplot setup
\pgfplotsset{compat=1.8}% put your installed version no.
\pgfplotstableset{
mysci/.style={sci,sci zerofill,sci precision=4,sci sep align,sci generic={mantissa sep={e\pgfmathparse{##1<0?"-":"+"}{\pgfmathresult}},exponent={\pgfmathparse{abs(##1)<10?0:}\pgfmathresult\pgfmathparse{int(abs(##1)}\pgfmathprintnumber[int detect]{\pgfmathresult}}}},
myfixed/.style={fixed,precision=4,dec sep align,fixed zerofill}
}       
\begin{document}
\begin{sidewaystable}[htbp]
\centering
\footnotesize
\pgfplotstabletypeset[
columns/sample/.style={string type,column type = l,column name=Sample},
columns/strain/.style={int detect,column type/.add={|}{},column name={$\varepsilon [\%]$}},
columns/mu1/.style={mysci,column type/.add={|}{},column name={$\mu_1$ [\si{\pascal}]}},
columns/a1/.style={mysci,column name={$\alpha_1 [-]$}},
columns/mu2/.style={mysci,column name={$\mu_2$ [\si{\pascal}]}},
columns/a2/.style={mysci,column name={$\alpha_2 [-]$}},
columns/mu3/.style={mysci,column name={$\mu_3$ [\si{\pascal}]}},
columns/a3/.style={mysci,column name={$\alpha_3 [-]$}},
columns/mu/.style={myfixed,column type/.add={|}{},column name={$\mu$ [\si{\MPa}]}},
columns/r2/.style={myfixed,column type/.add={|}{},column name={$R_2$}},
columns/norm2/.style={myfixed,column name={$||\cdot ||_2$}},
every head row/.style={after row=\B, after row=\hline},
every last row/.style={after row=\B, after row=\hline},
every row no 0/.style={before row=\T},
every nth row={4[-1]}{after row=\B, after row=\hline},
every nth row={4}{before row=\T},
]{
sample strain mu1 a1 mu2 a2 mu3 a3 mu r2 norm2
\multirow{4}{1.5cm}{Pure Rubber}    40  3.0648e+05  1.5311e+00    7.5072e+02        1.5310e+00  -1.6977e+02  -8.8141e+00    0.2359   0.999986       0.011948
{}                                                  25  3.5423e+05  1.3275e+00      1.5690e+00      3.1398e-10  3.6224e-14          9.8203e-01      0.2351   0.999921   0.010659
{}                                                  15  3.4674e+05  1.3299e+00      7.6212e+02      1.2622e+01  1.4052e+00      9.7551e-01      0.2354  0.999660    0.008762
{}                                                  10  3.0004e+05  1.2792e+00  -6.3089e+04 -1.8889e-07 5.3477e+03      1.8277e+01      0.2408  0.998891        0.008090
\multirow{4}{1.5cm}{Isotropic $10\%$ MREs}  36      9.6811e+05      5.8200e-01          -1.3654e-02 -3.0302e+01  8.3622e-11  4.9200e+00  0.2817  0.999868  0.037122
{}                                                                  25      1.2535e+06      4.4717e-01          1.2331e+02  1.2547e-10      3.9909e-13      3.9848e+00  0.2803  0.999500  0.033976  
{}                                                                  15      -3.6086e+05     -1.4653e+00 9.8794e-07      3.5771e-09      1.2296e-09  1.7867e-07      0.2644  0.998287  0.025398 
{}                                                                  10      -8.2465e+04     -5.7995e+00     7.9359e+01  2.2204e-14  8.9302e-01      3.7158e-09  0.2391  0.996939    0.017356 
}
\captionsetup{width=0.9\textwidth}
\caption{Identified model parameters of \textit{Ogden Model}}
\label{ogden}
\end{sidewaystable}
\end{document}

最终输出: 在此处输入图片描述

相关内容