mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-06 00:10:59 +00:00
970386d4a8
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5970 a592a061-630c-0410-9148-cb99ea01b6c8
202 lines
4.0 KiB
Plaintext
202 lines
4.0 KiB
Plaintext
#LyX 1.3 created this file. For more info see http://www.lyx.org/
|
|
\lyxformat 221
|
|
\textclass article
|
|
\begin_preamble
|
|
\usepackage{dcolumn}
|
|
\newcolumntype{d}[1]{D{.}{.}{#1}}
|
|
\end_preamble
|
|
\language english
|
|
\inputencoding latin1
|
|
\fontscheme default
|
|
\graphics default
|
|
\paperfontsize default
|
|
\spacing single
|
|
\papersize Default
|
|
\paperpackage a4
|
|
\use_geometry 0
|
|
\use_amsmath 0
|
|
\use_natbib 0
|
|
\use_numerical_citations 0
|
|
\paperorientation portrait
|
|
\secnumdepth 3
|
|
\tocdepth 3
|
|
\paragraph_separation indent
|
|
\defskip medskip
|
|
\quotes_language english
|
|
\quotes_times 2
|
|
\papercolumns 1
|
|
\papersides 1
|
|
\paperpagestyle default
|
|
|
|
\layout Title
|
|
|
|
A Better Decimal-Alignment Solution
|
|
\layout Standard
|
|
|
|
An alternative way to have decimal alignment in tables is through the dcolumn
|
|
package.
|
|
Add the following to the LateX preamble:
|
|
\layout LyX-Code
|
|
|
|
|
|
\backslash
|
|
usepackage{dcolumn}
|
|
\layout LyX-Code
|
|
|
|
|
|
\backslash
|
|
newcolumntype{d}[1]{D{.}{.}{#1}}
|
|
\layout Standard
|
|
|
|
To have a column decimally aligned, enter in the
|
|
\family sans
|
|
Special Column Alignment
|
|
\family default
|
|
box of the
|
|
\family sans
|
|
Table extra
|
|
\family default
|
|
form the following:
|
|
\layout LyX-Code
|
|
|
|
d{number of decimals of the data}
|
|
\layout Standard
|
|
|
|
In the following table we entered
|
|
\family typewriter
|
|
d{4}
|
|
\family default
|
|
:
|
|
\layout Standard
|
|
\added_space_top 0.3cm \added_space_bottom 0.3cm \align center
|
|
|
|
\begin_inset Tabular
|
|
<lyxtabular version="3" rows="5" columns="2">
|
|
<features>
|
|
<column alignment="center" valignment="top" width="0pt">
|
|
<column alignment="right" valignment="top" leftline="true" width="0pt" special="d{4}">
|
|
<row bottomline="true">
|
|
<cell alignment="center" valignment="top" topline="true" usebox="none">
|
|
\begin_inset Text
|
|
|
|
\layout Standard
|
|
|
|
Expression
|
|
\end_inset
|
|
</cell>
|
|
<cell multicolumn="1" alignment="center" valignment="top" bottomline="true" leftline="true" usebox="none">
|
|
\begin_inset Text
|
|
|
|
\layout Standard
|
|
|
|
Value
|
|
\end_inset
|
|
</cell>
|
|
</row>
|
|
<row>
|
|
<cell alignment="center" valignment="top" topline="true" usebox="none">
|
|
\begin_inset Text
|
|
|
|
\layout Standard
|
|
|
|
\end_inset
|
|
</cell>
|
|
<cell multicolumn="1" alignment="right" valignment="top" leftline="true" usebox="none">
|
|
\begin_inset Text
|
|
|
|
\layout Standard
|
|
|
|
3.1416
|
|
\end_inset
|
|
</cell>
|
|
</row>
|
|
<row>
|
|
<cell alignment="center" valignment="top" topline="true" usebox="none">
|
|
\begin_inset Text
|
|
|
|
\layout Standard
|
|
|
|
\end_inset
|
|
</cell>
|
|
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
|
|
\begin_inset Text
|
|
|
|
\layout Standard
|
|
|
|
36.462
|
|
\end_inset
|
|
</cell>
|
|
</row>
|
|
<row>
|
|
<cell alignment="center" valignment="top" topline="true" usebox="none">
|
|
\begin_inset Text
|
|
|
|
\layout Standard
|
|
|
|
\end_inset
|
|
</cell>
|
|
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
|
|
\begin_inset Text
|
|
|
|
\layout Standard
|
|
|
|
80663.
|
|
\end_inset
|
|
</cell>
|
|
</row>
|
|
<row>
|
|
<cell alignment="center" valignment="top" topline="true" usebox="none">
|
|
\begin_inset Text
|
|
|
|
\layout Standard
|
|
|
|
\end_inset
|
|
</cell>
|
|
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
|
|
\begin_inset Text
|
|
|
|
\layout Standard
|
|
|
|
1.3402e18
|
|
\end_inset
|
|
</cell>
|
|
</row>
|
|
</lyxtabular>
|
|
|
|
\end_inset
|
|
|
|
|
|
\layout Standard
|
|
|
|
To create extra column space just increase the number of decimals in
|
|
\family typewriter
|
|
d{}
|
|
\family default
|
|
.
|
|
Setting the multicolumn attribute for a single cell makes it insensitive
|
|
to the decimal alignment which comes in handy as well.
|
|
A drawback of this method is that math mode is not allowed in a column
|
|
with decimal alignment except if the multicolumn attribute is set.
|
|
\layout Standard
|
|
|
|
This method offers the same flexibility as the
|
|
\family typewriter
|
|
dcolumn
|
|
\family default
|
|
package.
|
|
One could, for example, change the alignment separator, and have different
|
|
alignment separators for different columns by defining multiple column
|
|
types in the preamble.
|
|
The syntax is as follows:
|
|
\layout LyX-Code
|
|
|
|
D{inputsep}{outputsep}{decimal places}
|
|
\layout Standard
|
|
|
|
The interested reader is directed towards the
|
|
\family typewriter
|
|
dcolumn
|
|
\family default
|
|
package documentation for more details.
|
|
\the_end
|