开发者

LaTeX column alignment

I have a LaTeX document that is part of an automated system. So I cannot use fixed widths for the table as the inputs are uncertain.

\begin{tabular}[t]{|l|@{\hfill}r@{ }|c|@{ }l|}
\textbf{\langComponent} & \multicolumn{3}{c}{
\textbf{\shortstack{\leftresultsheader}}
} 
\DTLforeach{resultstableA}{\colA=componentA,\colB=amountfracA,\colC=pmsymbolA,\colD=uncertA}{\\{\colA}&{\colB}&{\colC}&{\colD}}
\DTLforeach{resultstableB}{\colE=componentB,\colF=amountfracB,\colG=pmsymbolB,\colH=uncertB}{\\{\colE}&{\colF}&{\colG}&{\colH}}
\end{tabular}

How can I have the last 3 columns (rcl, which display as a result, a plusminus symbol, and an uncertainty) be all centrally aligned as a group underneath the multicoumn header that spans those 3 colu开发者_Go百科mns?


You could take a look at the packages dcolumn or siunitx (of which I'm the author). I think in either case you'll need to first loop through the database to find the size of the largest number (i.e. how many digits before and after the decimal place). A simple hard-coded siunitx example would be

\documentclass{article}
\usepackage{booktabs,siunitx}
\begin{document}
\begin{tabular}{S[separate-uncertainty,table-format=4.2(2)]}
  {A header} \\
  1.23(45)   \\
  6789.10(1) \\
\end{tabular}
\end{document}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜