Graphics, Figures & Tables ⇒ Changing decimal alignment within column
Changing decimal alignment within column
I would like to align on different decimals. My table uses two different decimal markers in the same column: the top part uses a period and the bottom part a comma. (The top is fractions, the bottom sample size).
I would like to align on *both* the period and comma. Using -dcolumn- allows aligning on the period, but that means that values with the comma separator stick out on the left.
I paste a table example below. Any suggestions much appreciated!
Thanks Bert
\begin{tabular}{ l c }
coeff1 & 2.213 \\
coeff2 & 5.213 \\
N & 7,123 \\
\end{tabular}
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Changing decimal alignment within column
one possible solution would be to define a new column type that aligns the cell contents according to a variable character (declared in the argument of the new type). You declare a decimal point in the table format specification and, with the help of \multicolumn, you can switch to a decimal comma; take a look at the following simple example:
Code: Select all
\documentclass{article}
\usepackage{dcolumn}
\newcolumntype{L}[1]{D{.}{#1}{1,3}}
\newcommand\CommaCell[1]{%
\multicolumn{1}{L{,}}{#1}%
}
\begin{document}
\begin{tabular}{ l L{.} }
coeff1 & 2.213 \\
coeff2 & 5.213 \\
N & \CommaCell{7.123} \\
O & \CommaCell{9.123} \\
\end{tabular}
\end{document}