aboutsummaryrefslogtreecommitdiffstats
path: root/doc/user/tbl_alig
blob: 24b6864cd8ba93830e69df07341ead2c7ac4afb2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
@Section
    @Title { Aligned columns }
    @Tag { tbl_alig }
@Begin
@PP
Columns of numbers are often presented with decimal points aligned:
aligned.columns @Index { aligned columns in tables }
@CD @OneRow @Tbl
    marginvertical { 0.5vx }
    aformat { @Cell A }
{
@Rowa A { 5^.46 } marginabove { 0i }
@Rowa A { 3^.4159 }
@Rowa A { 5772^ } marginbelow { 0i }
}
You can produce this by placing a @Code "^" symbol, which is used
generally throughout Lout for alignment, just before the alignment point in
each entry:
@ID @OneRow @Code @Verbatim {
@Tbl
    marginvertical { 0.5vx }
    aformat { @Cell A }
{
@Rowa A { 5^.46 }
@Rowa A { 3^.4159 }
@Rowa A { 5772^ }
}
}
The equals signs of equations can be aligned in the same way (see the
example at the start of this chapter).  Aligned cells should have no
@Code indent option.
@PP
Owing to problems behind the scenes, getting a heading over the top
of an aligned column is a problem with no ideal solution.  What most
people want is for the heading to be centred in the column, and the
aligned entries to be centred in the column as a block, but Lout cannot
do this.  One approximation is to make the heading cell a spanning
cell with centring, like this:
@FootNote { Lout does not currently accept single-column tables
with {@Code "@StartHSpan"}, so we've had to add
an empty second column. }
@ID @OneRow @Code @Verbatim {
@Tbl
    marginvertical { 0.5vx }
    aformat { @StartHSpan @Cell indent { ctr } @B A | }
    bformat { @Cell A | }
{
@Rowa A { Heading }
@Rowb A { 5^.46 }
@Rowb A { 3^.4159 }
@Rowb A { 5772^ }
}
}
The spanning frees the heading from alignment, permitting
@Code "indent { ctr }" to work:
@CD @OneRow @Tbl
    marginvertical { 0.5vx }
    aformat { @StartHSpan @Cell indent { ctr } @B A | }
    bformat { @Cell A | }
{
@Rowa A { Heading } marginabove { 0i }
@Rowb A { 5^.46 }
@Rowb A { 3^.4159 }
@Rowb A { 5772^ } marginbelow { 0i }
}
But if the heading cell is wider than the aligned cells, you get this:
@CD @OneRow @Tbl
    marginvertical { 0.5vx }
    aformat { @StartHSpan @Cell indent { ctr } @B A | }
    bformat { @Cell A | }
{
@Rowa A { A Wider Heading } marginabove { 0i }
@Rowb A { 5^.46 }
@Rowb A { 3^.4159 }
@Rowb A { 5772^ } marginbelow { 0i }
}
In other words, this will centre a heading with respect
to aligned entries, but it will not centre aligned entries with
respect to a heading.  In these cases you could forget about
@Code "@StartHSpan" and treat the heading as an aligned entry,
either by placing a @Code "^" within it or by using
@ID @Code "@Cell 0.5w @HShift A"
which places the alignment point in the centre of the entry.
#@CD @OneRow @Tbl
#    marginvertical { 0.5vx }
#    aformat { @Cell 0.5w @HShift @B A }
#    bformat { @Cell A }
#{
#@Rowa A { A Wider Heading } marginabove { 0i }
#@Rowb A { 5^.46 }
#@Rowb A { 3^.4159 }
#@Rowb A { 5772^ } marginbelow { 0i }
#}
You can move the alignment point about by changing the 0.5.  Of course,
all this is a poor substitute for the real thing.
@End @Section