]> git.lyx.org Git - lyx.git/blob - lib/examples/decimal.lyx
update all lyx documents to the latest file format
[lyx.git] / lib / examples / decimal.lyx
1 #LyX 1.4.0cvs created this file. For more info see http://www.lyx.org/
2 \lyxformat 243
3 \begin_document
4 \begin_header
5 \textclass article
6 \begin_preamble
7 \usepackage{dcolumn}
8 \newcolumntype{d}[1]{D{.}{.}{#1}}
9 \end_preamble
10 \language english
11 \inputencoding latin1
12 \fontscheme default
13 \graphics default
14 \paperfontsize default
15 \spacing single
16 \papersize default
17 \use_geometry false
18 \use_amsmath 0
19 \cite_engine basic
20 \use_bibtopic false
21 \paperorientation portrait
22 \secnumdepth 3
23 \tocdepth 3
24 \paragraph_separation indent
25 \defskip medskip
26 \quotes_language english
27 \quotes_times 2
28 \papercolumns 1
29 \papersides 1
30 \paperpagestyle default
31 \tracking_changes false
32 \output_changes true
33 \end_header
34
35 \begin_body
36
37 \begin_layout Title
38
39 A Better Decimal-Alignment Solution
40 \end_layout
41
42 \begin_layout Standard
43
44 An alternative way to have decimal alignment in tables is through the dcolumn
45  package.
46  Add the following to the LateX preamble:
47 \end_layout
48
49 \begin_layout LyX-Code
50
51
52 \backslash
53 usepackage{dcolumn} 
54 \end_layout
55
56 \begin_layout LyX-Code
57
58
59 \backslash
60 newcolumntype{d}[1]{D{.}{.}{#1}}
61 \end_layout
62
63 \begin_layout Standard
64
65 To have a column decimally aligned, enter in the 
66 \family sans
67 Special Column Alignment
68 \family default
69  box of the 
70 \family sans
71 Table extra
72 \family default
73  form the following:
74 \end_layout
75
76 \begin_layout LyX-Code
77
78 d{number of decimals of the data}
79 \end_layout
80
81 \begin_layout Standard
82
83 In the following table we entered 
84 \family typewriter
85 d{4}
86 \family default
87 :
88 \end_layout
89
90
91 \begin_layout Standard
92
93
94 \begin_inset VSpace 0.3cm
95 \end_inset
96
97
98 \end_layout
99
100 \begin_layout Standard
101 \align center
102
103 \begin_inset  Tabular
104 <lyxtabular version="3" rows="5" columns="2">
105 <features>
106 <column alignment="center" valignment="top" width="0pt">
107 <column alignment="right" valignment="top" leftline="true" width="0pt" special="d{4}">
108 <row bottomline="true">
109 <cell alignment="center" valignment="top" topline="true" usebox="none">
110 \begin_inset Text
111
112 \begin_layout Standard
113
114 Expression
115 \end_layout
116
117 \end_inset
118 </cell>
119 <cell multicolumn="1" alignment="center" valignment="top" bottomline="true" leftline="true" usebox="none">
120 \begin_inset Text
121
122 \begin_layout Standard
123
124 Value 
125 \end_layout
126
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 \begin_layout Standard
135
136 \end_layout
137
138 \end_inset
139 </cell>
140 <cell multicolumn="1" alignment="right" valignment="top" leftline="true" usebox="none">
141 \begin_inset Text
142
143 \begin_layout Standard
144
145 3.1416
146 \end_layout
147
148 \end_inset
149 </cell>
150 </row>
151 <row>
152 <cell alignment="center" valignment="top" topline="true" usebox="none">
153 \begin_inset Text
154
155 \begin_layout Standard
156
157 \end_layout
158
159 \end_inset
160 </cell>
161 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
162 \begin_inset Text
163
164 \begin_layout Standard
165
166 36.462
167 \end_layout
168
169 \end_inset
170 </cell>
171 </row>
172 <row>
173 <cell alignment="center" valignment="top" topline="true" usebox="none">
174 \begin_inset Text
175
176 \begin_layout Standard
177
178 \end_layout
179
180 \end_inset
181 </cell>
182 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
183 \begin_inset Text
184
185 \begin_layout Standard
186
187 80663.
188 \end_layout
189
190 \end_inset
191 </cell>
192 </row>
193 <row>
194 <cell alignment="center" valignment="top" topline="true" usebox="none">
195 \begin_inset Text
196
197 \begin_layout Standard
198
199 \end_layout
200
201 \end_inset
202 </cell>
203 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
204 \begin_inset Text
205
206 \begin_layout Standard
207
208 1.3402e18
209 \end_layout
210
211 \end_inset
212 </cell>
213 </row>
214 </lyxtabular>
215
216 \end_inset
217
218
219 \end_layout
220
221 \begin_layout Standard
222
223
224 \begin_inset VSpace 0.3cm
225 \end_inset
226
227
228 \end_layout
229
230
231 \begin_layout Standard
232
233 To create extra column space just increase the number of decimals in 
234 \family typewriter
235 d{}
236 \family default
237 .
238  Setting the multicolumn attribute for a single cell makes it insensitive
239  to the decimal alignment which comes in handy as well.
240  A drawback of this method is that math mode is not allowed in a column
241  with decimal alignment except if the multicolumn attribute is set.
242 \end_layout
243
244 \begin_layout Standard
245
246 This method offers the same flexibility as the 
247 \family typewriter
248 dcolumn
249 \family default
250  package.
251  One could, for example, change the alignment separator, and have different
252  alignment separators for different columns by defining multiple column
253  types in the preamble.
254  The syntax is as follows: 
255 \end_layout
256
257 \begin_layout LyX-Code
258
259 D{inputsep}{outputsep}{decimal places}
260 \end_layout
261
262 \begin_layout Standard
263
264 The interested reader is directed towards the 
265 \family typewriter
266 dcolumn
267 \family default
268  package documentation for more details.
269 \end_layout
270
271 \end_body
272 \end_document