-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample.tex
133 lines (120 loc) · 4.56 KB
/
sample.tex
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% File:
% vilatac/sample.tex
%
% Maintainer:
% Sepp Tannhuber
%
% Version:
% 1
%
% Usage:
% -> Put the following key mapping into ~/.vimrc:
% cmap TAB !vilatac<CR><C-j>
% -> Create table (see sample below):
% 1. Use & without whitespace as field
% separator
% 2. For the midrules between header and body
% use [startcol]-[endcol], where [startcol]
% and [endcol] are the first and last columns
% to underline
% 3. Use [cellcontent]:[colnumber] for
% multicolumns, where [colnumber] is the
% number of columns to combine
% 4. Use line break to start a new line
% -> Mark table in VISUAL mode
% -> In normal mode type :TAB to convert table to
% LaTeX syntax
% -> Enter floating position parameter
% -> Type <C-j> to jump to caption placeholder
% -> Write a caption
% -> Type <C-j> to jump to label field
% -> Enter label name
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[]{scrartcl}
\usepackage{booktabs, colortbl, multirow, dcolumn}
\newcolumntype{.}{D{.}{.}{2}}
\newcolumntype{,}{D{,}{,}{2}}
\begin{document}
\section*{ViLaTaC, a very flexible, easy to use table creator}
Try out the following examples. Mark the lines between \verb|BEGIN TABLE| and
\verb|END TABLE| in visual mode. Change to normal mode and type \verb|:TAB|. See
what happens. Write a caption, change to the label field typing \verb|<C-j>|
and give it a label name. You must convert all tables before running \LaTeX.
\paragraph{One header line, continuous midrule, three body lines, three columns}
The first line defines the header. The font is fixed in the vilatac script. It
can be changed there. The columns are separated by \verb|&|~signs.
The second line is a midrule. It is defined by the \verb|-|~sign and goes from the
first to the third column. The lines below the midrule are table body lines.
Their font is also fixed in the vilatac script.
% --- BEGIN TABLE 1 ---
animal&weight&appetite
1-3
dog&25&hoggish
cat&303&gourmet
pig&80&eats everything
% --- END TABLE 1 ---
\paragraph{Two header lines, midrules for each column, two columns in math mode}
Now there are two header lines. The second line has a multicolumn definition. The
\verb|:2| tells, that it should cover the next two columns. They are in math mode,
see the \verb|$| sign at the end. \textbf{The column format must be defined in
the first line.}
The last two columns of the second header line are defined as multicolumns as
well in order to protect them from math mode. This is important to know.
\textbf{If a header is in math mode it must be protected by a multicolumn.}
Columns in math mode are right aligned, while text columns are left aligned.
Header lines are always left aligned. The midrule is interrupted between the
first and the second column.
% --- BEGIN TABLE 2 ---
animal&characteristics:2$
&weight:1&appetite:1
1-1&2-3
dog&25&\infty
cat&303&\lim_{\textrm{delicious}\rightarrow\textrm{saturated}}
pig&80&\int\textrm{food}
% --- END TABLE 2 ---
\paragraph{Individual column formatting}
You can define other column types with the dcolumn package, see the newcolumn
commands above. Each column can be formatted individually independend of the
first header line. E.g.\ in the example above the first two columns are formatted
in math mode. In the following table the columns are defined before the first
header line. If the first line starts with a colon, ViLaTaC recognizes it as
command line to format the columns. In this case the first column uses the
decimal point separator while the last two lines use a comma separator.
% --- BEGIN TABLE 3 ---
:.&:2,
Decimal separators:2&Decimal separator:1
point:1&comma:1&comma:1
1-2&3-3
1&2&3
1.1&,2&3,3
1.11&,22&3,33
% --- END TABLE 3 ---
\paragraph{Conclusion}
That was easy! Wasn't it? You see, ViLaTaC is very flexible although its syntax
is absolutely minimalistic. Of course, this minimalism has some constraints.
Nevertheless, ViLaTaC can be used in many cases, even for tables that exceed
ViLaTaC's limitations. Let's look at the table~4.
% --- BEGIN TABLE 4 ---
First headerline:2&
1-2
Subheader 1&Subheader 2&Subheader 3
1-3
1&2&3
1&2&3
1&2&3
% --- END TABLE 4 ---
The subheaders are recognized as body lines, although they are headerlines.
ViLaTaC does not know that. But you use define the midrules like in table~5
and move the cmidrule line after conversion. This is still a big
simplification.
% --- BEGIN TABLE 5 ---
First headerline:2&
Subheader 1&Subheader 2&Subheader 3
1-2
1-3
1&2&3
1&2&3
1&2&3
% --- END TABLE 5 ---
\end{document}