%% %% multirowii.sty V1.6 version (5-May-2004) %% %% Author: Jerry Leichter %% Piet van Oostrum %% %% This file may be distributed under the terms of the LaTeX Project Public %% License, as described in lppl.txt in the base LaTeX distribution. %% Either version 1 or, at your option, any later version. %% %% V1.0 was distributed anonymously, based on a Usenet posting that was %% not intended for stand-alone use. %% V1.1 was modified by Piet van Oostrum to allow it to %% work without bigstrut.sty. %% V1.2 was modified by Jerry Leichter for the same goal, but using a %% different approach which will work properly in conjunction with %% bigstrut.sty. %% V1.2a was modified by Piet van Oostrum to use \vskip %% instead of \raise in positioning, avoiding making rows too high %% when the adjustment is large. %% V1.3 was modified by Piet van Oostrum to work properly in a p{} column %% (\leavevmode added) %% V1.4 was modified by Piet van Oostrum to check for the special case that %% the width is given as an *. In this case the natural %% width of the text argument will be used and the argument %% is processed in LR-mode. %% V1.5 was modified by Piet van Oostrum: Added a % after \hbox{#5}\vfill}. %% Added \struts around #5 for better vertical positioning. %% Additional coding for negative value of nrows. %% V1.6 was modified by Piet van Oostrum: Replace a space by \relax after %% \advance\@tempdima#4. %% % Make an entry that will span multiple rows of a table. % % \multirowii[pos]{nrows}[bigstruts]{width}[fixup]{text} % % pos specifies the vertical position of text. 'p' at the top of the box, % 'm' in the middle (default), 'b' at the bottom. % % nrows is the number of rows to span. It's up to you to leave the other % rows empty, or the stuff created by \multirowii will over-write it. % With a positive value of nrows the spanned colomns are this row and % (nrows-1) rows below it. With a negative value of nrows they are % this row and (1-nrows) above it. % % bigstruts is mainly used if you've used bigstrut.sty. In that case it % is the total number of uses of \bigstrut within the rows being % spanned. Count 2 uses for each \bigstrut, 1 for each \bigstrut[x] % where x is either t or b. The default is 0. % % width is the width to which the text is to be set, or * to indicate that % the text argument's natural width is to be used. % % text is the actual text. If the width was set explicitly, the text will % be set in a parbox of that width; you can use \\ to force linebreaks % where you like. % % If the width was given as * the text will be set in LR mode. If you % want a multiline entry in this case you should use a tabular or array % in the text parameter. % % The text is centered vertically within the range spanned by nrows. % % fixup is a length used for fine tuning: The text will be raised (or % lowered, if fixup is negative) by that length above (below) wherever % it would otherwise have gone. % % For example (using both multirowii and bigstrut) % % \newcommand{\minitab}[2][l]{\begin{tabular}{#1}#2\end{tabular}} % \begin{tabular}{|c|c|} % \hline % \multirowii{4}{1in}{Common g text} & Column g2a\\ % & Column g2b \\ % & Column g2c \\ % & Column g2d \\ % \hline % \multirowii{3}[6]*{Common g text} & Column g2a\bigstrut\\\cline{2-2} % & Column g2b \bigstrut\\\cline{2-2} % & Column g2c \bigstrut\\ % \hline % \multirowii{4}[8]{1in}{Common g text} & Column g2a\bigstrut\\\cline{2-2} % & Column g2b \bigstrut\\\cline{2-2} % & Column g2c \bigstrut\\\cline{2-2} % & Column g2d \bigstrut\\ % \hline % \multirowii{4}*{\minitab[c]{Common \\ g text}} & Column g2a\\ % & Column g2b \\ % & Column g2c \\ % & Column g2d \\ % \hline % \end{tabular} % % If any of the spanned rows are unusually large, or if you're using % bigstrut.sty and \bigstrut's are used assymetrically about the centerline of % the spanned rows, the vertical centering may not come out right. Use the % fixup argument in this case. % % Just before "text" is expanded, the \multirowiisetup macro is expanded to % set up any special environment. Initially, \multirowiisetup contains just % \raggedright. It can be redefined with \renewcommand. % % Bugs: It's just about impossible to deal correctly with descenders. The % text will be set up centered, but it may then have a baseline that doesn't % match the baseline of the stuff beside it, in particular if the stuff % beside it has descenders and "text" does not. This may result in a small % missalignment. About all that can be done is to do a final touchup on % "text", using the fixup optional argument. (Hint: If you use a measure % like .1ex, there's a reasonable chance that the fixup will still be correct % if you change the point size.) % % \multirowii is mainly designed for use with table, as opposed to array, % environments. It will not work well in an array environment since the lines % have an extra \jot of space between them which it won't account for. Fixing % this is difficult in general, and doesn't seem worth it. The bigstruts % argument can be used to provide a semi-automatic fix: First set % \bigstrutjot to .5\jot. Then simply repeat nrows as the bigstruts argument. % This will be close, but probably not exact; you can use the fixup argument % to refine the result. (If you do this repeatedly, you'll probably want to % wrap these steps up in a simple macro. Note that the modified \bigstrutjot % value will not give reasonable results if you have bigstruts and use this % argument for its intended purpose elsewhere. In that case, you might want % to set it locally.) % % If you use \multirowii with the colortbl package you have to take % precautions if you want to color the column that has the \multirowii in it. % colortbl works by coloring each cell separately. So if you use \multirowii % with a positive nrows value, colortbl will first color the top cell, then % \multirowii will typeset nrows cells starting with this cell, and later % colortbl will color the other cells, effectively hiding the text in that % area. This can be solved by putting the \multirowii is the last row with a % negative nrows value. % Example: % % \begin{tabular}{l>{\columncolor{yellow}}l} % aaaa & \\ % cccc & \\ % dddd & \multirowii{-3}*{bbbb}\\ % \end{tabular} % \def\multirowiisetup{\raggedright\vskip1pt} \def\vfillsetup#1{% \if#1m\let\vfillup=\vfill\let\vfilldn=\vfill\else% \if#1p\let\vfillup=\relax\let\vfilldn=\vfill\else% \if#1b\let\vfillup=\vfill\let\vfilldn=\relax\else% \let\vfillup=\vfill\let\vfilldn=\vfill \fi\fi\fi} \def\multirowii{\@ifnextchar [{\@multirowiiv}{\vfillsetup{m}\@multirowiim}} \def\@multirowiiv[#1]{\vfillsetup{#1}\@multirowiim} \def\@multirowiim#1{\relax\@ifnextchar [{\@multirowii{#1}}{\@multirowii{#1}[0]}} \def\@multirowii#1[#2]#3{\@ifnextchar [{\@xmultirowii{#1}[#2]{#3}}% {\@xmultirowii{#1}[#2]{#3}[0pt]}} \long\def\@xmultirowii#1[#2]#3[#4]#5{\@tempcnta=#1% \@tempdima\@tempcnta\ht\@arstrutbox \advance\@tempdima\@tempcnta\dp\@arstrutbox \ifnum\@tempcnta<0\@tempdima=-\@tempdima\fi \advance\@tempdima#2\bigstrutjot \if*#3\setbox0\vtop to \@tempdima{\vfillup\multirowiisetup \hbox{\strut#5\strut}\vfilldn}% \ht0\z@\dp0\z@ \else \dimen0=#3\relax \ifdim\dimen0<\z@ \dimen0=-\dimen0 \let\footnotemark\relax \fi \setbox0\vbox{\hsize\dimen0\@parboxrestore\multirowiisetup\strut#5\strut}% \dimen0=\ht0 \advance\dimen0\dp0\relax \ifdim\dimen0>\@tempdima \divide\dimen0\@tempcnta \ifnum\dimen0<0% \dimen0=-\dimen0 \fi \ifdim#3<\z@ \setbox0\vbox{}% \fi \ht0\dimen0\dp0\z@ \else \ifdim#3<\z@ \setbox0\vbox{}% \fi \setbox0\vtop to \@tempdima{\vfillup\unvbox0\vfilldn}% \ht0\z@\dp0\z@ \fi \fi \ifnum\@tempcnta<0\advance\@tempdima-\dp\@arstrutbox \else\@tempdima=\ht\@arstrutbox \ifnum#2>0 \advance\@tempdima\bigstrutjot \fi \fi \advance\@tempdima#4\relax\leavevmode\vtop{\vskip-\@tempdima\box0\vss}} \@ifundefined{bigstrutjot}{\newdimen\bigstrutjot \bigstrutjot\jot}{}