]> git.lyx.org Git - lyx.git/blob - lib/examples/decimal.lyx
fix typo that put too many include paths for most people
[lyx.git] / lib / examples / decimal.lyx
1 #LyX 1.2 created this file. For more info see http://www.lyx.org/
2 \lyxformat 220
3 \textclass article
4 \begin_preamble
5 \usepackage{dcolumn}
6 \newcolumntype{d}[1]{D{.}{.}{#1}}
7 \end_preamble
8 \language english
9 \inputencoding latin1
10 \fontscheme default
11 \graphics default
12 \paperfontsize default
13 \spacing single 
14 \papersize Default
15 \paperpackage a4
16 \use_geometry 0
17 \use_amsmath 0
18 \use_natbib 0
19 \use_numerical_citations 0
20 \paperorientation portrait
21 \secnumdepth 3
22 \tocdepth 3
23 \paragraph_separation indent
24 \defskip medskip
25 \quotes_language english
26 \quotes_times 2
27 \papercolumns 1
28 \papersides 1
29 \paperpagestyle default
30
31 \layout Title
32
33 A Better Decimal-Alignment Solution
34 \layout Standard
35
36 An alternative way to have decimal alignment in tables is through the dcolumn
37  package.
38  Add the following to the LateX preamble:
39 \layout LyX-Code
40
41
42 \backslash 
43 usepackage{dcolumn} 
44 \layout LyX-Code
45
46
47 \backslash 
48 newcolumntype{d}[1]{D{.}{.}{#1}}
49 \layout Standard
50
51 To have a column decimally aligned, enter in the 
52 \family sans 
53 Special Column Alignment
54 \family default 
55  box of the 
56 \family sans 
57 Table extra
58 \family default 
59  form the following:
60 \layout LyX-Code
61
62 d{number of decimals of the data}
63 \layout Standard
64
65 In the following table we entered 
66 \family typewriter 
67 d{4}
68 \family default 
69 :
70 \layout Standard
71 \added_space_top 0.3cm \added_space_bottom 0.3cm \align center 
72
73 \begin_inset  Tabular
74 <lyxtabular version="3" rows="5" columns="2">
75 <features>
76 <column alignment="center" valignment="top" width="0pt">
77 <column alignment="right" valignment="top" leftline="true" width="0pt" special="d{4}">
78 <row bottomline="true">
79 <cell alignment="center" valignment="top" topline="true" usebox="none">
80 \begin_inset Text
81
82 \layout Standard
83
84 Expression
85 \end_inset 
86 </cell>
87 <cell multicolumn="1" alignment="center" valignment="top" bottomline="true" leftline="true" usebox="none">
88 \begin_inset Text
89
90 \layout Standard
91
92 Value 
93 \end_inset 
94 </cell>
95 </row>
96 <row>
97 <cell alignment="center" valignment="top" topline="true" usebox="none">
98 \begin_inset Text
99
100 \layout Standard
101
102 \end_inset 
103 </cell>
104 <cell multicolumn="1" alignment="right" valignment="top" leftline="true" usebox="none">
105 \begin_inset Text
106
107 \layout Standard
108
109 3.1416
110 \end_inset 
111 </cell>
112 </row>
113 <row>
114 <cell alignment="center" valignment="top" topline="true" usebox="none">
115 \begin_inset Text
116
117 \layout Standard
118
119 \end_inset 
120 </cell>
121 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
122 \begin_inset Text
123
124 \layout Standard
125
126 36.462
127 \end_inset 
128 </cell>
129 </row>
130 <row>
131 <cell alignment="center" valignment="top" topline="true" usebox="none">
132 \begin_inset Text
133
134 \layout Standard
135
136 \end_inset 
137 </cell>
138 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
139 \begin_inset Text
140
141 \layout Standard
142
143 80663.
144 \end_inset 
145 </cell>
146 </row>
147 <row>
148 <cell alignment="center" valignment="top" topline="true" usebox="none">
149 \begin_inset Text
150
151 \layout Standard
152
153 \end_inset 
154 </cell>
155 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
156 \begin_inset Text
157
158 \layout Standard
159
160 1.3402e18
161 \end_inset 
162 </cell>
163 </row>
164 </lyxtabular>
165
166 \end_inset 
167
168
169 \layout Standard
170
171 To create extra column space just increase the number of decimals in 
172 \family typewriter 
173 d{}
174 \family default 
175 .
176  Setting the multicolumn attribute for a single cell makes it insensitive
177  to the decimal alignment which comes in handy as well.
178  A drawback of this method is that math mode is not allowed in a column
179  with decimal alignment except if the multicolumn attribute is set.
180 \layout Standard
181
182 This method offers the same flexibility as the 
183 \family typewriter 
184 dcolumn
185 \family default 
186  package.
187  One could, for example, change the alignment separator, and have different
188  alignment separators for different columns by defining multiple column
189  types in the preamble.
190  The syntax is as follows: 
191 \layout LyX-Code
192
193 D{inputsep}{outputsep}{decimal places}
194 \layout Standard
195
196 The interested reader is directed towards the 
197 \family typewriter 
198 dcolumn
199 \family default 
200  package documentation for more details.
201 \the_end