source: GTP/trunk/Lib/Vis/Preprocessing/manual/multirow.sty @ 2066

Revision 2066, 7.2 KB checked in by mattausch, 18 years ago (diff)

worked on integration manual

Line 
1%%
2%% multirow.sty  V1.6 version (5-May-2004)
3%%
4%% Author:  Jerry Leichter <jerrold.leichter@smarts.com>
5%%          Piet van Oostrum <piet@cs.uu.nl>
6%%
7%% This file may be distributed under the terms of the LaTeX Project Public
8%% License, as described in lppl.txt in the base LaTeX distribution.
9%% Either version 1 or, at your option, any later version.
10%%
11%% V1.0 was distributed anonymously, based on a Usenet posting that was
12%%      not intended for stand-alone use.
13%% V1.1 was modified by Piet van Oostrum <piet@cs.uu.nl> to allow it to
14%%      work without bigstrut.sty.
15%% V1.2 was modified by Jerry Leichter for the same goal, but using a
16%%      different approach which will work properly in conjunction with
17%%      bigstrut.sty.
18%% V1.2a was modified by Piet van Oostrum <piet@cs.uu.nl> to use \vskip
19%%    instead of \raise in positioning, avoiding making rows too high
20%%    when the adjustment is large.
21%% V1.3 was modified by Piet van Oostrum to work properly in a p{} column
22%%      (\leavevmode added)
23%% V1.4 was modified by Piet van Oostrum to check for the special case that
24%%      the width is given as an *. In this case the natural
25%%      width of the text argument will be used and the argument
26%%      is processed in LR-mode.
27%% V1.5 was modified by Piet van Oostrum: Added a % after \hbox{#5}\vfill}.
28%%      Added \struts around #5 for better vertical positioning.
29%%      Additional coding for negative value of nrows.
30%% V1.6 was modified by Piet van Oostrum: Replace a space by \relax after
31%%      \advance\@tempdima#4.
32%%
33% Make an entry that will span multiple rows of a table.
34%
35% \multirow{nrows}[bigstruts]{width}[fixup]{text}
36%
37% nrows is the number of rows to span.  It's up to you to leave the other
38%       rows empty, or the stuff created by \multirow will over-write it.
39%       With a positive value of nrows the spanned colomns are this row and
40%       (nrows-1) rows below it. With a negative value of nrows they are
41%       this row and (1-nrows) above it.
42%
43% bigstruts is mainly used if you've used bigstrut.sty.  In that case it
44%       is the total number of uses of \bigstrut within the rows being
45%       spanned.  Count 2 uses for each \bigstrut, 1 for each \bigstrut[x]
46%       where x is either t or b.  The default is 0.
47% width is the width to which the text is to be set, or * to indicate that
48%       the text argument's natural width is to be used.
49%
50% text is the actual text.  If the width was set explicitly, the text will
51%       be set in a parbox of that width; you can use \\ to force linebreaks
52%       where you like.
53%
54%       If the width was given as * the text will be set in LR mode.  If you
55%       want a multiline entry in this case you should use a tabular or array
56%       in the text parameter.
57%
58%       The text is centered vertically within the range spanned by nrows.
59%
60% fixup is a length used for fine tuning:  The text will be raised (or
61%       lowered, if fixup is negative) by that length above (below) wherever
62%       it would otherwise have gone.
63%
64% For example (using both multirow and bigstrut)
65%
66% \newcommand{\minitab}[2][l]{\begin{tabular}{#1}#2\end{tabular}}
67% \begin{tabular}{|c|c|}
68% \hline
69% \multirow{4}{1in}{Common g text} & Column g2a\\
70%       & Column g2b \\
71%       & Column g2c \\
72%       & Column g2d \\
73% \hline
74% \multirow{3}[6]*{Common g text} & Column g2a\bigstrut\\\cline{2-2}
75%       & Column g2b \bigstrut\\\cline{2-2}
76%       & Column g2c \bigstrut\\
77% \hline
78% \multirow{4}[8]{1in}{Common g text} & Column g2a\bigstrut\\\cline{2-2}
79%       & Column g2b \bigstrut\\\cline{2-2}
80%       & Column g2c \bigstrut\\\cline{2-2}
81%       & Column g2d \bigstrut\\
82% \hline
83% \multirow{4}*{\minitab[c]{Common \\ g text}} & Column g2a\\
84%       & Column g2b \\
85%       & Column g2c \\
86%       & Column g2d \\
87% \hline
88% \end{tabular}
89%
90% If any of the spanned rows are unusually large, or if you're using
91% bigstrut.sty and \bigstrut's are used assymetrically about the centerline of
92% the spanned rows, the vertical centering may not come out right.  Use the
93% fixup argument in this case.
94%
95% Just before "text" is expanded, the \multirowsetup macro is expanded to
96% set up any special environment.  Initially, \multirowsetup contains just
97% \raggedright.  It can be redefined with \renewcommand.
98%
99% Bugs:  It's just about impossible to deal correctly with descenders.  The
100% text will be set up centered, but it may then have a baseline that doesn't
101% match the baseline of the stuff beside it, in particular if the stuff
102% beside it has descenders and "text" does not.  This may result in a small
103% missalignment.  About all that can be done is to do a final touchup on
104% "text", using the fixup optional argument.  (Hint:  If you use a measure
105% like .1ex, there's a reasonable chance that the fixup will still be correct
106% if you change the point size.)
107%
108% \multirow is mainly designed for use with table, as opposed to array,
109% environments.  It will not work well in an array environment since the lines
110% have an extra \jot of space between them which it won't account for.  Fixing
111% this is difficult in general, and doesn't seem worth it.  The bigstruts
112% argument can be used to provide a semi-automatic fix:  First set
113% \bigstrutjot to .5\jot.  Then simply repeat nrows as the bigstruts argument.
114% This will be close, but probably not exact; you can use the fixup argument
115% to refine the result.  (If you do this repeatedly, you'll probably want to
116% wrap these steps up in a simple macro.  Note that the modified \bigstrutjot
117% value will not give reasonable results if you have bigstruts and use this
118% argument for its intended purpose elsewhere.  In that case, you might want
119% to set it locally.)
120%
121% If you use \multirow with the colortbl package you have to take
122% precautions if you want to color the column that has the \multirow in it.
123% colortbl works by coloring each cell separately. So if you use \multirow
124% with a positive nrows value, colortbl will first color the top cell, then
125% \multirow will typeset nrows cells starting with this cell, and later
126% colortbl will color the other cells, effectively hiding the text in that
127% area. This can be solved by putting the \multirow is the last row with a
128% negative nrows value.
129% Example:
130
131%  \begin{tabular}{l>{\columncolor{yellow}}l}
132%    aaaa & \\
133%    cccc & \\
134%    dddd & \multirow{-3}*{bbbb}\\
135%  \end{tabular}
136%
137\def\multirowsetup{\raggedright}
138\def\multirow#1{\relax\@ifnextchar
139  [{\@multirow{#1}}{\@multirow{#1}[0]}}
140\def\@multirow#1[#2]#3{\@ifnextchar [{\@xmultirow{#1}[#2]{#3}}%
141  {\@xmultirow{#1}[#2]{#3}[0pt]}}
142\def\@xmultirow#1[#2]#3[#4]#5{\@tempcnta=#1%
143  \@tempdima\@tempcnta\ht\@arstrutbox
144  \advance\@tempdima\@tempcnta\dp\@arstrutbox
145  \ifnum\@tempcnta<0\@tempdima=-\@tempdima\fi
146  \advance\@tempdima#2\bigstrutjot
147  \if*#3\setbox0\vtop to \@tempdima{\vfill\multirowsetup
148    \hbox{\strut#5\strut}\vfill}%
149  \else
150      \setbox0\vtop to \@tempdima{\hsize#3\@parboxrestore
151                \vfill \multirowsetup \strut#5\strut\par\vfill}%
152  \fi
153  \ht0\z@\dp0\z@
154  \ifnum\@tempcnta<0\advance\@tempdima-\dp\@arstrutbox
155  \else\@tempdima=\ht\@arstrutbox
156     \ifnum#2>0 \advance\@tempdima\bigstrutjot \fi
157  \fi
158  \advance\@tempdima#4\relax\leavevmode\vtop{\vskip-\@tempdima\box0\vss}}
159\@ifundefined{bigstrutjot}{\newdimen\bigstrutjot \bigstrutjot\jot}{}
Note: See TracBrowser for help on using the repository browser.