| 1 |
% Copyright (c) 2015-2019 Robert Ryszard Paciorek <[email protected]> |
| 2 |
% |
| 3 |
% MIT License |
| 4 |
% |
| 5 |
% Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 |
% of this software and associated documentation files (the "Software"), to deal |
| 7 |
% in the Software without restriction, including without limitation the rights |
| 8 |
% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 |
% copies of the Software, and to permit persons to whom the Software is |
| 10 |
% furnished to do so, subject to the following conditions: |
| 11 |
% |
| 12 |
% The above copyright notice and this permission notice shall be included in all |
| 13 |
% copies or substantial portions of the Software. |
| 14 |
% |
| 15 |
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 |
% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 |
% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 |
% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 |
% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 |
% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 |
% SOFTWARE. |
| 22 |
|
| 23 |
\documentclass[a4paper]{article} |
| 24 |
|
| 25 |
\usepackage{vtable,hhline,xcolor} |
| 26 |
\usepackage{fvextra,geometry,lipsum} |
| 27 |
\fvset{breaklines=true, breakafter={/\}\{}, breakaftersymbolpre={}, breakaftersymbolpost={\tiny\ensuremath{\ \hookrightarrow\ }}} |
| 28 |
\geometry{tmargin=20mm, bmargin=27mm, lmargin=21mm, rmargin=21mm} |
| 29 |
|
| 30 |
\begin{document} |
| 31 |
|
| 32 |
\title{The \texttt{vtable} package} |
| 33 |
\author{Robert Ryszard Paciorek <[email protected]>} |
| 34 |
\date{2019-05-13} |
| 35 |
\maketitle |
| 36 |
|
| 37 |
\section{Introduction} |
| 38 |
|
| 39 |
This package allow vertical alignement of table cell |
| 40 |
by providing \texttt{Z}, \texttt{L}, \texttt{C}, \texttt{R}, \texttt{J} and \texttt{I} column types |
| 41 |
and \Verb$\nextRow$, \Verb$\lb$, \Verb$\setMultiColRow$, \Verb$\setMultiColumn$, \Verb$\setMultiRow$ and \Verb$\tableFormatedCell$ commands |
| 42 |
for \texttt{tabular} and similar environment. |
| 43 |
|
| 44 |
\section{Column types} |
| 45 |
|
| 46 |
\subsection{\texttt{Z}} |
| 47 |
|
| 48 |
\texttt{Z} column type have 6 arguments: |
| 49 |
\begin{enumerate} |
| 50 |
\item max width of cell |
| 51 |
\item min width of cell (optional – can be empty) |
| 52 |
\item horizontal align mode, supported values: |
| 53 |
\begin{description} |
| 54 |
\item[l] left |
| 55 |
\item[c] center |
| 56 |
\item[r] right |
| 57 |
\item[j] justify |
| 58 |
\end{description} |
| 59 |
\item number of columns to span this cell |
| 60 |
\item vertical align mode, supported values: |
| 61 |
\begin{description} |
| 62 |
\item[t] top |
| 63 |
\item[m] middle |
| 64 |
\item[b] bottom |
| 65 |
\end{description} |
| 66 |
\item number of rows to span this cell |
| 67 |
\end{enumerate} |
| 68 |
|
| 69 |
\subsection{\texttt{L}, \texttt{C}, \texttt{R} and \texttt{J}} |
| 70 |
|
| 71 |
\texttt{L}, \texttt{C}, \texttt{R} and \texttt{J} column types are shortcuts for Z column type and have 3 arguments: |
| 72 |
\begin{enumerate} |
| 73 |
\item max width of cell |
| 74 |
\item min width of cell (optional – can be empty) |
| 75 |
\item vertical align mode, supported values: |
| 76 |
\begin{description} |
| 77 |
\item[t] top |
| 78 |
\item[m] middle |
| 79 |
\item[b] bottom |
| 80 |
\end{description} |
| 81 |
\end{enumerate} |
| 82 |
\texttt{L} is left ragged column, \texttt{C} is center ragged column, \texttt{R} is right ragged column and \texttt{J} is justifying column. |
| 83 |
|
| 84 |
\subsection{\texttt{I}} |
| 85 |
|
| 86 |
\texttt{I} column type insert vertical frame line and have 3 arguments: |
| 87 |
\begin{enumerate} |
| 88 |
\item formatting command (eg. \Verb$\color$) |
| 89 |
\item line width, second argument of \Verb$\hdashrule$ |
| 90 |
\item line style, third argument of \Verb$\hdashrule$ |
| 91 |
\end{enumerate} |
| 92 |
|
| 93 |
|
| 94 |
\section{Commands} |
| 95 |
|
| 96 |
\subsection{nextRow an lb} |
| 97 |
{\bfseries Each row (even last) MUST be ended with \Verb$\nextRow$ command} (insted of \Verb$\\$ or \Verb$\tabularnewline$). |
| 98 |
Line break in table cell can be do with \Verb$\lb$ (shortcut for \Verb$\linebreak$), \Verb$\linebreak$ or \Verb$\newline$. |
| 99 |
|
| 100 |
\subsection{setMultiColRow} |
| 101 |
\Verb$\setMultiColRow{col num}{row num}{max width}{min width}{hmode}{vmode}{left sep}{right sep}{text}$ command allow span cells on rows and columns create multi column at the same time. |
| 102 |
It have 9 arguments: |
| 103 |
\begin{description} |
| 104 |
\item[col num] number of columns to span this cell |
| 105 |
\item[row num] number of rows to span this cell |
| 106 |
\item[max width] max width of cell |
| 107 |
\item[min width] min width of cell (optional – can be empty) |
| 108 |
\item[hmode] horizontal align mode, supported values: |
| 109 |
\begin{description} |
| 110 |
\item[l] left |
| 111 |
\item[c] center |
| 112 |
\item[r] right |
| 113 |
\item[j] justify |
| 114 |
\end{description} |
| 115 |
\item[vmode] vertical align mode, supported values: |
| 116 |
\begin{description} |
| 117 |
\item[t] top |
| 118 |
\item[m] middle |
| 119 |
\item[b] bottom |
| 120 |
\end{description} |
| 121 |
\item[left sep] left cell frame element |
| 122 |
\item[right sep] right cell frame element |
| 123 |
\item[text] cell content |
| 124 |
\end{description} |
| 125 |
|
| 126 |
\Verb$\setMultiColRow$ command MUST be repeated in each row of multirow set. |
| 127 |
Only first call CAN (and MUST) have not empty last argument (cell content). |
| 128 |
Every next call of \Verb$\setMultiColRow$ in single multirow set MUST have empty last argument (cell content). |
| 129 |
|
| 130 |
\subsection{setMultiColumn} |
| 131 |
\Verb$\setMultiColumn{col num}{max width}{min width}{hmode}{vmode}{left sep}{right sep}{text}$ command allow create multi column cell. |
| 132 |
It have 8 arguments meaningful as corresponding args in \Verb$\setMultiColRow$ command. |
| 133 |
|
| 134 |
\subsection{setMultiRow} |
| 135 |
\Verb$\setMultiRow{col num}[minimal height]{text}$ command allow create multi row cell. |
| 136 |
Next cells in multirow set should be empty. |
| 137 |
Horizontal lines between cells in multirow set should be manualy removed (via setting \Verb$\hhline$ parametrs). |
| 138 |
|
| 139 |
\subsection{tableFormatedCell} |
| 140 |
\Verb$\tableFormatedCell{max width}[min width]{hmode}{vmode}$ command allow change formatting for single cell. |
| 141 |
It have 4 arguments meaningful as corresponding args in \Verb$\setMultiColRow$ command. |
| 142 |
|
| 143 |
\subsection{forceRowHeight} |
| 144 |
\Verb$\forceRowHeight{value}$ enforce current row minimum height to value. |
| 145 |
|
| 146 |
|
| 147 |
\section{Examples} |
| 148 |
|
| 149 |
\begin{center} |
| 150 |
\begin{tabular}{ |
| 151 |
| C{2cm}{}{t} | C{2cm}{1.5cm}{m} | C{2cm}{}{b} | L{2cm}{}{m} | |
| 152 |
R{2cm}{}{t} | J{2cm}{}{t} I{\color{red}}{1pt}{0.5mm 0.5mm 0.5mm 0mm} |
| 153 |
} |
| 154 |
\hline |
| 155 |
top & middle & bottom & middle left & top right & top justify |
| 156 |
\nextRow \hline |
| 157 |
A \lb xxx \lb X & B & C & |
| 158 |
\setMultiRow{3}{ -- \lipsum[1][1] -- \lb -- \lipsum[1][2] -- } & |
| 159 |
q & q |
| 160 |
\nextRow \hhline{---~--} |
| 161 |
D \lb d & E \lb xxx xx \lb X \lb X & F \lb f & & q & q |
| 162 |
\nextRow \hhline{---~--} |
| 163 |
G & H & I \lb xxx \lb Xj & & q & q |
| 164 |
\nextRow \hline |
| 165 |
G & |
| 166 |
\setMultiColumn{2}{4cm}{3cm}{c}{t}{}{|} {top, center: \lb \lipsum[1][3]} & |
| 167 |
xx & q & q |
| 168 |
\nextRow \hline |
| 169 |
G & |
| 170 |
\multicolumn{2}{Z{4cm}{3cm}{l}{2}{t}{1}|} {top, left: \lb \lb \lipsum[1][4]} & |
| 171 |
LL LL\lb xxx\lb X\lb X & RR RR\lb xxx\lb X\lb X & BB BB\lb xxx\lb X\lb X |
| 172 |
\nextRow \hline |
| 173 |
G & |
| 174 |
\tableFormatedCell{3.5cm}[3cm]{r}{b}I I \lb xxxxxxx \lb a a Xj & |
| 175 |
y & \lipsum[1][1] & \lipsum[1][1] & \lipsum[1][1] |
| 176 |
\nextRow \hline |
| 177 |
\end{tabular} |
| 178 |
\end{center} |
| 179 |
|
| 180 |
\begin{Verbatim} |
| 181 |
\begin{tabular}{ |
| 182 |
| C{2cm}{}{t} | C{2cm}{1.5cm}{m} | C{2cm}{}{b} | L{2cm}{}{m} | |
| 183 |
R{2cm}{}{t} | J{2cm}{}{t} I{\color{red}}{1pt}{0.5mm 0.5mm 0.5mm 0mm} |
| 184 |
} |
| 185 |
\hline |
| 186 |
top & middle & bottom & middle left & top right & top justify |
| 187 |
\nextRow \hline |
| 188 |
A \lb xxx \lb X & B & C & |
| 189 |
\setMultiRow{3}{ -- \lipsum[1][1] -- \lb -- \lipsum[1][2] -- } & |
| 190 |
q & q |
| 191 |
\nextRow \hhline{---~--} |
| 192 |
D \lb d & E \lb xxx xx \lb X \lb X & F \lb f & & q & q |
| 193 |
\nextRow \hhline{---~--} |
| 194 |
G & H & I \lb xxx \lb Xj & & q & q |
| 195 |
\nextRow \hline |
| 196 |
G & |
| 197 |
\setMultiColumn{2}{4cm}{3cm}{c}{t}{}{|} {top, center: \lb \lipsum[1][3]} & |
| 198 |
xx & q & q |
| 199 |
\nextRow \hline |
| 200 |
G & |
| 201 |
\multicolumn{2}{Z{4cm}{3cm}{l}{2}{t}{1}|} {top, left: \lb \lb \lipsum[1][4]} & |
| 202 |
LL LL\lb xxx\lb X\lb X & RR RR\lb xxx\lb X\lb X & BB BB\lb xxx\lb X\lb X |
| 203 |
\nextRow \hline |
| 204 |
G & |
| 205 |
\tableFormatedCell{3.5cm}[3cm]{r}{b}I I \lb xxxxxxx \lb a a Xj & |
| 206 |
y & \lipsum[1][1] & \lipsum[1][1] & \lipsum[1][1] |
| 207 |
\nextRow \hline |
| 208 |
\end{tabular} |
| 209 |
\end{Verbatim} |
| 210 |
|
| 211 |
\subsection{multicolumn, multirow} |
| 212 |
|
| 213 |
\begin{center} |
| 214 |
\begin{tabular}{| C{2cm}{}{t} | C{2cm}{}{m} | C{2cm}{}{b} | L{2cm}{}{m} |} |
| 215 |
\hline |
| 216 |
\setMultiColRow{2}{3}{4cm}{3cm}{c}{m}{|}{|}{ multi multi multi multi multi multi multi multi multi } & c1 & d1 |
| 217 |
\nextRow\hhline{~~--} |
| 218 |
\setMultiColRow{2}{3}{4cm}{3cm}{c}{m}{|}{|}{} & c2 & d2 |
| 219 |
\nextRow\hhline{~~--} |
| 220 |
\setMultiColRow{2}{3}{4cm}{3cm}{c}{m}{|}{|}{} & c3 & d3 |
| 221 |
\nextRow\hline |
| 222 |
a4 & b4 & c4 & d4 |
| 223 |
\nextRow\hline |
| 224 |
\end{tabular} |
| 225 |
\end{center} |
| 226 |
|
| 227 |
\begin{Verbatim} |
| 228 |
\begin{tabular}{| C{2cm}{}{t} | C{2cm}{}{m} | C{2cm}{}{b} | L{2cm}{}{m} |} |
| 229 |
\hline |
| 230 |
\setMultiColRow{2}{3}{4cm}{3cm}{c}{m}{|}{|}{ multi multi multi multi multi multi multi multi multi } & c1 & d1 |
| 231 |
\nextRow\hhline{~~--} |
| 232 |
\setMultiColRow{2}{3}{4cm}{3cm}{c}{m}{|}{|}{} & c2 & d2 |
| 233 |
\nextRow\hhline{~~--} |
| 234 |
\setMultiColRow{2}{3}{4cm}{3cm}{c}{m}{|}{|}{} & c3 & d3 |
| 235 |
\nextRow\hline |
| 236 |
a4 & b4 & c4 & d4 |
| 237 |
\nextRow\hline |
| 238 |
\end{tabular} |
| 239 |
\end{Verbatim} |
| 240 |
\end{document} |