blob: ac1f9e6df066dcae817c8fd60e6b9aa17afc93f4 (
plain)
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
|
%
% vcell.sty V1.0.2 version (15-April-2021)
%
% Author: Xavier Dionne <info@latex-tables.com>
%
% Licence :
%
% The contents of this package are distributed under the LaTeX Project
% Public License, version 1.3c or later.
% https://www.latex-project.org/lppl/lppl-1-3c/
%
% Changelog :
% [v 1.0.2] - Fixed a compatibility issue with `calc`
% [v 1.0.1] - Fixed an issue where the height was calculated
% twice if the cell had a depth
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{vcell}[2021/04/30 v1.0.2]
\def\@cell@setlength#1#2{#1 #2\relax}
\newdimen\rowheight
\newdimen\rowht
\newdimen\rowdp
\newcount\@cellcount
\newcount\@cellusecount
\newbox\@celltemp
\def\resetcellcount{%
\global\@cellusecount 1\relax\global\@cellcount 1\relax%
\global\@cell@setlength\rowht{\arraystretch\ht\strutbox}%
\global\@cell@setlength\rowdp{\arraystretch\dp\strutbox}%
\global\@cell@setlength\rowheight{\dimexpr\rowht+\rowdp}%
}
\resetcellcount
\def\savecellheight{%
\ifdim\ht\@celltemp>\rowht\global\@cell@setlength{\rowht}{\ht\@celltemp}\fi%
\ifdim\dp\@celltemp>\rowdp\global\@cell@setlength{\rowdp}{\dp\@celltemp}\fi%
\ifdim\dimexpr\dp\@celltemp+\ht\@celltemp>\rowheight{\global\@cell@setlength{\rowheight}{\dimexpr\dp\@celltemp+\ht\@celltemp}}\fi
}
\long\def\savecellbox#1{%
\global\sbox\@celltemp{\hbox{\ifdim\hsize=\textwidth #1\else \vbox{#1}\fi}}%
\savecellheight%
\parbox{0pt}{\vrule height \ht\@celltemp depth \dp\@celltemp width 0pt}%
\global\expandafter\newbox\csname @cellbox\the\@cellcount\endcsname%
\global\expandafter\sbox\csname @cellbox\the\@cellcount\endcsname{\hbox{\usebox\@celltemp}}%
\global\advance\@cellcount 1\relax%
}
\let\vcell\savecellbox
\def\printcelltop{%
\leavevmode\vbox to \dimexpr\rowht{%
\hbox to \expandafter\wd\csname @cellbox\the\@cellusecount\endcsname{%
\vrule height \arraystretch\ht\strutbox depth \arraystretch\dp\strutbox width 0pt%
\expandafter\usebox\csname @cellbox\the\@cellusecount\endcsname%
}%
\vss%
}%
\global\advance\@cellusecount 1\relax%
\ifnum\@cellusecount=\@cellcount\resetcellcount\fi%
}
\def\printcellmiddle{%
\leavevmode\vbox to \dimexpr\rowht{%
\vfill\hbox to \expandafter\wd\csname @cellbox\the\@cellusecount\endcsname{%
\vrule height \arraystretch\ht\strutbox depth 0pt width 0pt%
\expandafter\usebox\csname @cellbox\the\@cellusecount\endcsname%
}%
\vfill%
}%
\global\advance\@cellusecount 1\relax%
\ifnum\@cellusecount=\@cellcount\resetcellcount\fi
}
\def\printcellbottom{%
\leavevmode\vbox to \dimexpr\rowht{%
\vss\hbox to \expandafter\wd\csname @cellbox\the\@cellusecount\endcsname{%
\vrule height \rowht depth \rowdp width 0pt%
\expandafter\usebox\csname @cellbox\the\@cellusecount\endcsname
}%
}%
\global\advance\@cellusecount 1\relax%
\ifnum\@cellusecount=\@cellcount\resetcellcount\fi
}
\endinput
|