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