Debian Codegraph @

texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.coltype.code.tex

raw
1 %--------------------------------------------
2 %
3 % Package numtable.
4 %
5 % This file provides support for column types in LaTeX tabular
6 % environments, i.e.
7 %
8 %\begin{tabular}{>{\pgfplotstablecoltype}c<{\endpgfplotstablecoltype}}
9 % 1 \\
10 % 2 \\
11 % 3 \\
12 %\end{tabular}
13 %
14 %
15 %
16 % Copyright 2007/2008 by Christian Feuersänger.
17 %
18 % This program is free software: you can redistribute it and/or modify
19 % it under the terms of the GNU General Public License as published by
20 % the Free Software Foundation, either version 3 of the License, or
21 % (at your option) any later version.
22 %
23 % This program is distributed in the hope that it will be useful,
24 % but WITHOUT ANY WARRANTY; without even the implied warranty of
25 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 % GNU General Public License for more details.
27 %
28 % You should have received a copy of the GNU General Public License
29 % along with this program. If not, see <http://www.gnu.org/licenses/>.
30 %
31 %--------------------------------------------
32
33
34
35 % If I did not get it wrong, the tabular package, initialised with a
36 % column type like
37 % >{\pgfplotstablecoltype}c<{\endpgfplotstablecoltype}
38 % yields
39 %
40 % \pgfplotstablecoltype \ignorespaces <content> \unskip \endpgfplotstablecoltype
41 % OR
42 % \pgfplotstablecoltype \ignorespaces <content> \textonly@unskip \endpgfplotstablecoltype
43 % OR
44 % \pgfplotstablecoltype \ignorespaces <content> \\ \endpgfplotstablecoltype
45 %
46 % So, I define \pgfplotstablecoltype to skip \ignorespaces, \unskip, and
47 % \textonly@unskip and simply get <content>.
48 \def\pgfplotstablecoltype{%
49 \begingroup
50 \let\pgfplotstablecoltype@content=\empty
51 \pgfutil@ifnextchar[{%
52 \pgfplotstablecoltype@
53 }{%
54 \pgfplotstablecoltype@until@end@start
55 }%
56 }%
57 \def\pgfplotstablecoltype@[#1]{%
58 \pgfqkeys{/pgf/number format}{#1}%
59 \pgfplotstablecoltype@until@end@start
60 }%
61
62 \def\pgfplotstablecoltype@until@end@start\ignorespaces{%
63 \pgfplotstablecoltype@until@end
64 }%
65 \def\pgfplotstablecoltype@until@end{%
66 \pgfutil@ifnextchar\\{%
67 \pgfplotstablecoltype@finish%
68 }{%
69 \pgfutil@ifnextchar{\unskip}{%
70 \pgfplotstablecoltype@finish%
71 }{%
72 \pgfutil@ifnextchar{\textonly@unskip}{%
73 \pgfplotstablecoltype@finish
74 }{%
75 \pgfplotstablecoltype@next
76 }%
77 }%
78 }%
79 }
80 \def\pgfplotstablecoltype@next#1{%
81 \expandafter\def\expandafter\pgfplotstablecoltype@content\expandafter{\pgfplotstablecoltype@content#1}%
82 \pgfplotstablecoltype@until@end
83 }
84 \def\pgfplotstablecoltype@finish{%
85 %\message{COLLECTED \meaning\pgfplotstablecoltype@content}%
86 \edef\pgfplotstablecoltype@content{\pgfplotstablecoltype@content}%
87 %
88 % trim white space:
89 \expandafter\pgfkeys@spdef\expandafter\pgfplotstablecoltype@content\expandafter{\pgfplotstablecoltype@content}%
90 %
91 \ifx\pgfplotstablecoltype@content\pgfutil@empty
92 \else
93 \pgfmathprintnumber{\pgfplotstablecoltype@content}%
94 \fi
95 \endgroup
96 }%
97
98 %\def\pgfplotstablecoltype{\message{COLLECT}}%
99 \def\endpgfplotstablecoltype{}%