5

Is there a way to align numbers in a TikZ matrix at the decimal points, as is possible in normal tables (Aligning numbers by decimal points in table columns)?

http://www.texample.net/tikz/builds/ says that a feature that "Added '/pgf/number format/assume math mode' to disable math checks. This allows to assemble tabulars, apply pgfmathprintnumber to each cell and use the dcolumn package to align at decimal separators (no documentation for that feature yet)" was made in June of 2008, but nothing else.

1 Answers1

2

This is a really, really, hackish and verbose and ugly idea, where pretty much the only bright side is that you get decimal point alignment given that each and every piece of input includes the decimals. I used commas, you might prefer periods. Also you might need to tweak the column sep -setting.

\def\decsp #1,#2 {\llap{#1},\rlap{#2}}
\usetikzlibrary{matrix}
\tikzpicture
  \matrix[matrix of nodes, column sep=2cm] {
    \decsp 0,015 & \decsp 52,432 \\
    \decsp 10,2  & \decsp 1084,85 \\
    \decsp 104,8 & \decsp 0,345 \\
  };
\endtikzpicture

I hope it helps, though!

David Carlisle
  • 757,742
morbusg
  • 25,490
  • 4
  • 81
  • 162