Debian Codegraph @

texmf-dist/source/latex/cals/colsep.dtx

raw
1 % \subsection{Column separation (colsep) and cell background}
2
3 % In-row decorations are the vertical borders between the cells
4 % and also the background color of the cells.
5
6 % \begin{macro}{\cals@cs@outOne}
7 % Typesets the background and the left border of a cell.
8 % Decorations have zero depth and undefined height.
9 % Parameters:
10 % \begin{enumerate}
11 % \item Width of the cell. The use of |\relax| avoids typesetting
12 % the cell itself, which is used when creating the right frame
13 % of a table.
14 % \item Width of the border. 0pt is no border.
15 % \item Color of the background. Empty macro is no color.
16 % \end{enumerate}
17 % If some arguments are undefined (through |\relax|), global
18 % variables are used: |\cals@bgcolor| and |\cals@cs@width|.
19 %
20 % Corrupts |dimen0|.
21 % \begin{macrocode}
22 \newcommand\cals@cs@outOne[3]{%
23 % \end{macrocode}
24 % Create the full-width background
25 % \begin{macrocode}
26 \ifx \relax#1%
27 \else
28 \cals@withColorII\cals@bgcolor{#3}\iftrue
29 \textcolor{\cals@color}{\vrule depth0pt width#1 }%
30 \hskip -#1\relax
31 \fi
32 \fi
33 % \end{macrocode}
34 % The border. I feel that overprinting the background is good,
35 % but I don't know why I think so.
36 % \begin{macrocode}
37 \cals@withWidthII\cals@cs@width{#2}\iftrue
38 \cals@halfWidthToDimen0 \cals@width %
39 \hskip -\dimen0 %
40 \vrule depth0pt width\cals@width\relax
41 \hskip -\dimen0 %
42 \fi
43 % \end{macrocode}
44 % We will need the actual width of the left border in
45 % a grand-grand-...-caller, when constructing a rowsep specification.
46 % \begin{macrocode}
47 \let\cals@lastLeftWidth=\cals@width
48 % \end{macrocode}
49 % Add width to skip to the next cell.
50 % \begin{macrocode}
51 \ifx \relax#1\else \hskip#1 \fi
52 }
53 % \end{macrocode}
54 % \end{macro}
55
56 % \begin{macro}{\cals@current@cs}
57 % The box to store column separation.
58 % \begin{macrocode}
59 \newbox\cals@current@cs
60 % \end{macrocode}
61 % \end{macro}
62
63 % \begin{macro}{\cals@csrow@begin}
64 % \begin{macro}{\cals@csrow@nextcell}
65 % \begin{macro}{\cals@csrow@end}
66 % Constructs an hbox with colsep decorations. Call to the begin-macro
67 % re-initializes |\cals@current@cs| and makes that the left table frame border
68 % is of the correct width. The end-macro creates the right border for
69 % the right table frame. The most work is performed in the nextcell-macro.
70 % Arguments:
71 % \begin{enumerate}
72 % \item Width of the cell
73 % \item Width of the left border
74 % \item Width of the right border, \emph{must be a macro name}
75 % \item Background color of the cell
76 % \end{enumerate}
77 % For the special conditions (|\relax|, 0pt, empty name) see
78 % the description of |\cals@cs@outOne|.
79 % The right border is not typeset immediately. Instead, it is saved
80 % to |\cals@lastWidth| (as |\relax| if no overrides)
81 % and is handled by the next call to |nextcell|.
82 % \begin{macrocode}
83 \newcommand\cals@csrow@begin{%
84 \setbox\cals@current@cs=\box\voidb@x %
85 \let\cals@lastWidth=\relax}
86
87 \newcommand\cals@csrow@nextcell[4]{%
88 % \end{macrocode}
89 % For the first cell, temporarily re-define the default border width
90 % to the frame border. Macro |\next| will restore it back.
91 % \begin{macrocode}
92 \ifvoid\cals@current@cs
93 \toks0=\expandafter{\cals@cs@width}%
94 \def\next{\edef\cals@cs@width{\the\toks0}}%
95 \edef\cals@cs@width{\cals@framecs@width}%
96 \else \let\next=\relax \fi
97 % \end{macrocode}
98 % Create the decorations, remember the right border.
99 % Restore the value |lastLeftWidth| after the end of the hbox-group.
100 % \begin{macrocode}
101 \cals@maxWidth\cals@lastWidth{#2}%
102 \setbox\cals@current@cs=\hbox{\unhbox\cals@current@cs
103 \cals@cs@outOne{#1}\cals@width{#4}%
104 \global\let\cals@tmp=\cals@lastLeftWidth}%
105 \let\cals@lastLeftWidth=\cals@tmp
106 \let\cals@lastWidth=#3%
107 % \end{macrocode}
108 % Restore the old value of the default border width.
109 % \begin{macrocode}
110 \next}
111
112 % \end{macrocode}
113 % User-specified width (initially by |borderR|, now located in
114 % |lastWidth|) must override the frame width.
115 % \begin{macrocode}
116 \newcommand\cals@csrow@end{%
117 \ifx \relax\cals@lastWidth
118 \let\cals@width=\cals@framecs@width
119 \else
120 \let\cals@width=\cals@lastWidth
121 \fi
122 \cals@csrow@nextcell\relax\cals@width\relax\relax}
123 % \end{macrocode}
124 % \end{macro}
125 % \end{macro}
126 % \end{macro}