diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/makecell/makecell.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/makecell/makecell.dtx | 1109 |
1 files changed, 1109 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/makecell/makecell.dtx b/Master/texmf-dist/source/latex/makecell/makecell.dtx new file mode 100644 index 00000000000..0cf9df93053 --- /dev/null +++ b/Master/texmf-dist/source/latex/makecell/makecell.dtx @@ -0,0 +1,1109 @@ +% \iffalse +% +% makecell.dtx - tabular column heads and multilined cells. +% (c) 2005 Olga Lapko (Lapko.O@g23.relcom.ru) +% +% This program is provided under the terms of the +% LaTeX Project Public License distributed from CTAN +% archives in directory macros/latex/base/lppl.txt. +% +% \fi +% +% \iffalse +%<*driver> +\ProvidesFile{makecell.dtx} +%</driver> +%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] +%<package>\ProvidesPackage{makecell} +%<*package> + [2005/07/02 v0.1a Multilined Cells and Tabular Heads] +%</package> +% +%<*batchfile> +\begingroup + +\input docstrip.tex + +\keepsilent +\askforoverwritefalse + +\generate{\file{makecell.sty}{\from{makecell.dtx}{package}}} + +\endgroup +%</batchfile> +% +%<*driver> +\documentclass{ltxdoc} +\usepackage{makecell} +\IfFileExists{rotating.sty}{\usepackage{rotating}}{} +\IfFileExists{footmisc.sty}{\usepackage[perpage]{footmisc}}{} +\IfFileExists{multirow.sty}{\usepackage{multirow}}{} +\IfFileExists{hyperref.sty}{\usepackage{hyperref}}{} +\IfFileExists{hypcap.sty}{\usepackage{hypcap}}{} +\IfFileExists{caption.sty}{\usepackage[font=small,labelfont=bf,labelsep=period]{caption}[2004/11/28] +\IfFileExists{floatrow.sty}{\usepackage[font=small,style=plaintop,captionskip=5pt]{floatrow}}{\let\ttabbox\relax}}{} +\usepackage{tabularx} +\EnableCrossrefs +\CodelineIndex +\RecordChanges +\makeatletter +\@beginparpenalty10000 +\widowpenalty10000 +\clubpenalty10000 +\makeatother +\providecommand*{\file}[1]{\texttt{#1}} +\providecommand*{\pkg}[1]{\textsf{#1}} +\providecommand*{\cls}[1]{\textsf{#1}} +\providecommand*{\env}[1]{\texttt{#1}} + +%\OnlyDescription +\begin{document} + \DocInput{makecell.dtx} + \PrintChanges +\end{document} +%</driver> +% \fi +% +% \CheckSum{664} +% +% \GetFileInfo{makecell.dtx} +% +% \DoNotIndex{\newcommand,\newenvironment} +% +% +% \title{The \textsf{makecell} package\thanks{This +% file has version number \fileversion, +% last revised \filedate.}} +% \author{% +% Olga Lapko\\ +% {\tt Lapko.O@g23.relcom.ru} } +% \date{\filedate} +% \maketitle +% \begin{abstract} +% This package offers command |\thead|, based on one-column tabular +% environment for tabular column heads. This macro allows to support +% common layout for tabular column heads in documentation. Another command, +% |\makecell|, is offered for creation of multilined tabular cells. +% +% Package also offers: \quad 1)\nobreak\enskip macro |\makegapedcells|, which +% changes vertical spaces around all cells (like in \pkg{tabls} package) in +% tabular; \quad 2)\nobreak\enskip macros |\multirowhead| and |\multirowcell|, +% which use |\multirow| macro from \pkg{multirow} package.\smallskip +% +% Current package calls \pkg{array} package. (Macro |\makegapedcells| also +% temporarily redefines macro |\@classz| from this package.) +% \end{abstract} +% +% \section{Tabular Cells and Column Heads} +% +% \subsection{Building Commands} +% +% \DescribeMacro{\makecell} +% Macro creates one-column tabular with predefined common settings of +% alignment, spacing and vertical spaces around (see section~\ref{sec:sets}). This will be useful for +% creation of multilined cells. This macro allows optional alignment settings. +% \begin{quote} +% |\makecell|\oarg{vertical or/and horizontal alignment}\marg{cell text} +% \end{quote} +% For vertical alignment you use \texttt{t}, \texttt{b}, or \texttt{c}---%^^A +% this letters you usually put in optional argument of \env{tabular} or \texttt{array} +% environments. For horizontal alignment you may use alignment settings +% like \texttt{r}, \texttt{l}, or \texttt{c}, or more complex, like +% |{p{3cm}}|. Since this package loads \pkg{array} package, you may +% use such alignment settings like |{>{\parindent1cm}p{3cm}}|. +%\begin{verbatim} +%\begin{tabular}{|c|c|} +%\hline +%Cell text & 28--31\\ +%\hline +%\makecell{Multilined \\ cell text} & 28--31\\ +%\hline +%\makecell[l]{Left aligned \\ cell text} & 37--43\\ +%\hline +%\makecell*[r]{Right aligned \\ cell text} & 37--43\\ +%\hline +%\makecell[b]{Bottom aligned \\ cell text} & 52--58\\ +%\hline +%\makecell*[{{p{3cm}}}]{Cell long text with predefined width} & 52--58\\ +%\hline +%\makecell[{{>{\parindent1em}p{3cm}}}]{Cell long...} & 52--58\\ +%\hline +%\end{tabular} +%\end{verbatim} +% \begin{table}[h] +% \ttabbox +% {\caption{Example of multilined cells}\label{tab:cells}}% +% {\begin{tabular}{|c|c|} +% \hline +% Cell text & 28--31\\ +% \hline +% \makecell{Multilined \\ cell text} & 28--31\\ +% \hline +% \makecell[l]{Left aligned \\ cell text} & 37--43\\ +% \hline +% \makecell*[r]{Right aligned \\ cell text} & 37--43\\ +% \hline +% \makecell[b]{Bottom aligned\\ cell text} & 52--58\\ +% \hline +% \makecell*[{{p{3cm}}}]{Cell long text with predefined width} & 52--58\\ +% \hline +% \makecell[{{>{\parindent1em}p{3cm}}}]{Cell long text with predefined width} & 52--58\\ +% \hline +% \end{tabular}} +% \end{table} +% +% Starred form of command, |\makecell*|, creates vertical |\jot| spaces around. +% +% \emph{Note}. When you define column alignment like |p{3cm}| in optional argument of +% |\makecell| (or |\thead|, see below), please follow these rules: \quad 1)\nobreak\enskip if +% vertical alignment defined, write column alignment in group, e.g. |[c{p{3cm}}]|; \quad +% 2)\nobreak\enskip if it is absent, write column alignment in double group---%^^A +% |[{{p{3cm}}}]|, or add empty group---|[{}{p{3cm}}]|. Be also careful with vertical +% alignment when you define column alignment as paragraph block: e.g., use |{{b{3cm}}}| for +% bottom alignment. +% +% \DescribeMacro{\thead} +% Macro creates one-column tabular for column heads with predefined +% common settings (see table~\ref{tab:thead}). This macro uses common layout for column heads: +% font, alignment, spacing, and vertical spaces around (see section~\ref{sec:sets}). +%\begin{verbatim} +%\renewcommand\theadset{\def\arraystretch{.85}}% +%\begin{tabular}{|l|c|} +%\hline +%\thead{First column head}& +% \thead{Second \\multlined \\ column head}\\ +%\hline +%Left column text & 28--31\\ +%\hline +%\end{tabular} +%\end{verbatim} +% \begin{table}[h] +% \ttabbox +% {\caption{Example of column heads}\label{tab:thead}} +% {\renewcommand\theadset{\def\arraystretch{.85}} +% \begin{tabular}{|l|c|} +% \hline +% \thead{First column head}& +% \thead{Second \\multlined \\ column head}\\ +% \hline +% Long left column text & 28--31\\ +% \hline +% \end{tabular}} +% \end{table} +% +% Starred form of command, |\thead*|, creates vertical |\jot| spaces around. +% +% \DescribeMacro{\rothead} +% Creates table heads rotated by 90$^\circ$ counterclockwise. +% Macro uses the same font and spacing settings as previous +% one, but column alignment changed to |p{\rotheadsize}| with |\raggedright| +% justification: in this case left side of all text lines ``lie'' on one base line. +% +% \DescribeMacro{\rotheadsize} +% This parameter defines the width of rotated tabular heads. You may define that like: +% \begin{quote} +% |\setlength\rotheadsize{3cm}| +% \end{quote} +% or +% \begin{quote} +% |\settowidth\rotheadsize{\theadfont |\meta{Widest head text}|}| +% \end{quote} +% like in following example: +%\begin{verbatim} +%\settowidth\rotheadsize{\theadfont Second multilined} +%\begin{tabular}{|l|c|} +%\hline +%\thead{First column head}& +% \rothead{Second multilined \\ column head}\\ +%\hline +%Left column text & 28--31\\ +%\hline +%\end{tabular} +%\end{verbatim} +% \begin{table}[h] +% \ttabbox +% {\caption{Example of rotated column heads}}% +% {\settowidth\rotheadsize{\theadfont Second multilined}%^^A +% \begin{tabular}{l|l} +% \hline +% \thead{First column head}& +% \rothead{Second multilined \\ column head}\\ +% \hline +% Long left column text & 28--31\\ +% \hline +% \end{tabular}} +% \end{table} +% +% \subsection{Settings For Tabular Cells}\label{sec:sets} +% +% This section describes macros, which make layout tuning for multilined cells, +% created by |\makecell| macro. The |\cellset| macro also is used by |\thead| macro. +% +% \DescribeMacro{\cellset} +% Spacing settings for cells. Here you could use commands like: +% \begin{quote} +% |\renewcommand\theadcell{\renewcommand\arraytretch{1}%|\\ +% | \setlength\extrarowheight{0pt}}| +% \end{quote} +% as was defined in current package. +% These settings used by both |\makecell| and |\thead| (|\rothead|) commands. +% +% \DescribeMacro{\cellalign} +% Default align for cells. Package offers vertical and horizontal centering alignment, it defined like: +% \begin{quote} +% |\renewcommand\cellalign{cc}| +% \end{quote} +% +% \DescribeMacro{\cellgape} +% Define vertical spaces around |\makecell|, using |\gape| command if necessary. It defined like: +% \begin{quote} +% |\renewcommand\cellgape{}| +% \end{quote} +% You may define this command like +% \begin{quote} +% |\renewcommand\cellgape{\gape*{1pt}}| +% \end{quote} +% or +% \begin{quote} +% |\renewcommand\cellgape{\gape[t]}| +% \end{quote} +% (See also section~\ref{sec:gape} about |\gape| command.) +% +% \subsection{Settings For Column Heads} +% +% This section describes macros, which make layout tuning for tabular column heads, +% created by |\thead| (|\rothead|) macro. +% +% \DescribeMacro{\theadfont} +% Sets a special font for column heads. It could be smaller size +% \begin{quote} +% |\renewcommand\theadfont{\foonotesize}| +% \end{quote} +% as was defined in current package. +% Next example defines italic shape +% \begin{quote} +% |\renewcommand\theadfont{\itshape}| +% \end{quote} +% +% \DescribeMacro{\theadset} +% Spacing settings for column heads. Here you could use commands like: +% \begin{quote} +% |\renewcommand\theadcell{\renewcommand\arraytretch{1}%|\\ +% | \setlength\extrarowheight{0pt}}| +% \end{quote} +% +% \DescribeMacro{\theadalign} +% Default align for tabular column heads. Here also offered centering alignment: +% \begin{quote} +% |\renewcommand\theadalign{cc}| +% \end{quote} +% +% \DescribeMacro{\theadgape} +% Define vertical spaces around, using |\gape| command if necessary. It defined like: +% \begin{quote} +% |\renewcommand\theadgape{\gape}| +% \end{quote} +% +% \DescribeMacro{\rotheadgape} +% Analogous definition for rotated column heads. Default is absent: +% \begin{quote} +% |\renewcommand\rotheadgape{}| +% \end{quote} +% +% \section{Changing of Height and Depth of Boxes}\label{sec:gape} +% +% Sometimes \env{tabular} or \env{array} cells, or some elements in text need a +% height/depth correction. The |\raisebox| command could help for it, but usage +% of that macro in these cases, especially inside math, is rather complex. +% Current package offers the |\gape| macro, which usage is similar to |\smash| macro. +% The |\gape| macro allows to change height and/or depth of included +% box with necessary dimension. +% +% \DescribeMacro{\gape} +% This macro changes included box by |\jot| value (usually 3\,pt). It is defined with optional +% and mandatory arguments, like |\smash| macro, which (re)defined by \pkg{amsmath} package. +% Optional argument sets change of height only (\texttt{t}) or depth only~(\texttt{b}). +% Mandatory argument includes text. +% \begin{quote} +% |\gape|\oarg{\texttt{t} or \texttt{b}}\marg{text} +% \end{quote} +% Examples of usage: +% \begin{quote} +% \noindent +% \vbox{\halign{#\cr +% \noalign{\hrule} +% \gape{\cmd{\gape}\texttt{\{text\}}}\cr +% \noalign{\hrule} +% \crcr}}\qquad +% \vbox{\halign{#\cr +% \noalign{\hrule} +% \gape[t]{\cmd{\gape}\texttt{[t]\{text\}}}\cr +% \noalign{\hrule\vskip\jot} +% \crcr}}\qquad +% \vbox{\halign{#\cr +% \noalign{\hrule} +% \gape[b]{\cmd{\gape}\texttt{[b]\{text\}}}\cr +% \noalign{\hrule} +% \crcr}} +% \end{quote} +% +% \DescribeMacro{\Gape} +% Another way of height/depth modification. This macro allows different correction for +% height and depth of box: +% \begin{quote} +% |\Gape|\oarg{height corr}\oarg{depth corr}\marg{text} +% \end{quote} +% +% If both arguments absent, |\Gape| command works like |\gape|\marg{text}, in other +% words, command uses |\jot| as correction value for height and depth of box. +% +% If only one optional argument exists, |\Gape| command uses value +% from this argument for both height and depth box corrections. +% \begin{quote} +% \noindent +% \vbox{\halign{#\cr +% \noalign{\hrule} +% \Gape{\cmd{\Gape}\texttt{\{text\}}}\cr +% \noalign{\hrule} +% \crcr}}\texttt{\phantom{xxxxx}}\qquad +% \vbox{\halign{#\cr +% \noalign{\hrule} +% \Gape[\jot]{\cmd{\Gape}\texttt{[\cmd{\jot}]\{text\}}}\cr +% \noalign{\hrule} +% \crcr}}\\[2ex] +% \vbox{\halign{#\cr +% \noalign{\hrule} +% \Gape[6pt]{\cmd{\Gape}\texttt{[6pt]\{text\}}}\cr +% \noalign{\hrule} +% \crcr}}\qquad +% \vbox{\halign{#\cr +% \noalign{\hrule} +% \Gape[6pt][-2pt]{\cmd{\Gape}\texttt{[6pt][-2pt]\{text\}}}\cr +% \noalign{\hrule\vskip8pt} +% \crcr}} +% \end{quote} +% +% \DescribeMacro{\bottopstrut} +% \DescribeMacro{\topstrut} +% \DescribeMacro{\botstrut} +% These three macros modify standard |\strut| by |\jot| value: +% |\bottopstrut| changes both height and depth; +% |\topstrut| changes only height; +% |\botstrut| changes only depth. +% These commands could be useful, for example, in first and last table rows. +% +% \emph{Note}. If you use +% \pkg{bigstrut} package note that these macros duplicate \cmd{\bigstrut}, +% \cmd{\bigstrut[t]}, and \cmd{\bigstrut[b]} commands consequently. Please note that value, +% which increases strut in \cmd{\topstrut} etc. equals to \cmd{\jot}, but \cmd{\bigstrut} +% and others use a special dimension \cmd{\bigstrutjot}. +% +% \section{How to Change Vertical Spaces Around in Whole Table}\label{sec:beta} +% +% This section describes macros which try to emulate one of possibilities of \pkg{tabls} +% package: to get necessary vertical spacing around cells. +% +% \DescribeMacro{\setcellgapes} +% Sets the parameters for vertical spaces. It looks like |\gape*| command without +% \marg{text} argument: +% \begin{quote} +% |\setcellgapes|\oarg{\texttt{t} or \texttt{b}}\marg{value} +% \end{quote} +% The next examples with array and tabular use following settings: +% \begin{quote} +% |\setcellgapes{5pt}| +% \end{quote} +% You may also try to load negative values if you wish. This macro you may put in the +% preamble as common settings. +% +% \DescribeMacro{\makegapedcells} +% \DescribeMacro{\nomakegapedcells} +% The first macro switches on vertical spacing settings. The second cancels first~one. +% +% The \cmd{\makegapedcells} macro temporarily redefines macro +% |\@classz| of \pkg{array} package, so use this mechanism carefully. +% Load |\makegapedcells| inside group or inside environment (see table~\ref{tab:gaped}): +%\begin{verbatim} +%\begin{table}[h] +%\makegapedcells +%... +%\end{table} +%\end{verbatim} +% \setcellgapes{5pt} +% \begin{table} +% \makegapedcells +% \ttabbox +% {\caption{Example of multilined cells with additional vertical spaces}\label{tab:gaped}}% +% {\begin{tabular}{|c|c|} +% \hline +% Cell text & 28--31\\ +% \hline +% \makecell{Multilined \\ cell text} & 28--31\\ +% \hline +% \makecell[l]{Left aligned \\ cell text} & 37--43\\ +% \hline +% \makecell*[r]{Right aligned \\ cell text} & 37--43\\ +% \hline +% \makecell[b]{Bottom aligned \\ cell text} & 52--58\\ +% \hline +% \makecell*[{{p{3cm}}}]{Cell long text with predefined width} & 52--58\\ +% \hline +% \makecell[{{>{\parindent1em}p{3cm}}}]{Cell long text with predefined width} & 52--58\\ +% \hline +% \end{tabular}} +% \end{table} +% +% Please note that space defined in |\setcellgapes| and space which creates |\gape| mechanism +% in commands for tabular cells (usually |\thead| or |\makecell*|) are summarized. +% +% \section{Multirow Table Heads and Cells} +% +% The next examples show usage of macros which use |\multirow| command from \pkg{multirow} +% package.\nopagebreak +% +% At first goes short repetition of arguments of |\multirow| macro itself: +% \begin{quote} +% |\multirow|\marg{nrow}\oarg{njot}\marg{width}\oarg{vmove}\marg{contents} +% \end{quote} +% \marg{nrow} sets number of rows (i.e. text lines); +% \oarg{njot} is mainly used if you've used \pkg{bigstrut} package: it makes additional +% tuning of vertical position (see comments in \pkg{multirow} package); +% \marg{width} defines width of contents, the |*| sign used to indicate that +% the text argument's natural width is to be used; +% \oarg{vmove} is a length used for fine tuning: the text will be raised (or +% lowered, if \meta{vmove} is negative) by that length; +% \marg{contents} includes ``|\multirow|'ed'' text.\smallskip +% +% \DescribeMacro{\multirowcell} +% \DescribeMacro{\multirowthead} +% These two macros use following arguments (example uses |\multirowcell| command): +% \begin{quote} +% |\multirowcell|\marg{nrow}\oarg{vmove}\oarg{hor alignment}\marg{contents} +% \end{quote} +% in these macros were skipped \oarg{njot} and \marg{width}. Instead of tuning optional +% argument \oarg{njot} for vertical +% correction used \oarg{vmove} optional argument. +% For the \marg{width} argument both |\multirowcell| and |\multirowthead| macros +% use natural width of contents (i.e. the |*| argument used). +% +% First example (table~\ref{tab:mrowI}) with ``|\multirow|'ed'' column heads and cells: +%\begin{verbatim} +%\renewcommand\theadset{\def\arraystretch{.85}}% +%\begin{tabular}{|l|c|c|} +% \multirowthead{4}{First ...}& +% \multicolumn{2}{c|}{\thead{Multicolumn head}}\\ \cline{2-3} +% & \thead{Second ...} & \thead{Third ...}\\ \hline +% Cell text & A &\multirowcell{3}{28--31}\\ \cline{1-2} +% \makecell{Multilined\\Cell text} & B& \\ \hline +% \makecell[l]{Left ...} & C & \multirowcell{4}[1ex][l]{37--43}\\ \cline{1-2} +% \makecell[r]{Right ...} & D & \\ \hline +% \makecell[b]{Bottom ...} & E & \multirowcell{5}[1ex][r]{37--43\\52--58}\\ +% \cline{1-2} +% \makecell[{{p{5cm}}}]{Cell ...} & F & \\ \cline{1-2} +% \makecell[{{>{\parindent1em}p{5cm}}}]{Cell ...} & G & \\ \hline +% \end{tabular} +%\end{verbatim} +% +% \begin{table}[p] +%\renewcommand\theadset{\def\arraystretch{.85}}% +% \ttabbox +% {\caption{Example of ``\cmd{\multirow}'ed'' cells}\label{tab:mrowI}}% +% {\begin{tabular}{|l|c|c|} +% \hline +% \multirowthead{4}{First Column head}& +% \multicolumn{2}{c|}{\thead{Multicolumn head}}\\ +% \cline{2-3} +% & \thead{Second \\multlined \\ column head} & +% \thead{Third \\ column head}\\ +% \hline +% Cell text & A &\multirowcell{3}{28--31}\\ +% \cline{1-2} +% \makecell{Multilined\\Cell text} & B& \\ +% \hline +% \makecell[l]{Left aligned\\ cell text} & C & \multirowcell{4}[1ex][l]{37--43}\\ +% \cline{1-2} +% \makecell[r]{Right aligned\\ cell text} & D & \\ +% \hline +% \makecell[b]{Bottom aligned\\ cell text} & E & \multirowcell{5}[1ex][r]{37--43\\52--58}\\ +% \cline{1-2} +% \makecell[{{p{5cm}}}]{Cell long long long long text with predefined width} & F & \\ +% \cline{1-2} +% \makecell[{{>{\parindent1em}p{5cm}}}]{Cell long long long long text with predefined width} & G & \\ +% \hline +% \end{tabular}} +% \end{table} +% +% Second example (table~\ref{tab:mrowII}) with ``multirow'ed'' column heads and cells +% uses |\makegapedcells| command. The |\theadgape| command does nothing: +%\begin{verbatim} +%\makegapedcells +%\renewcommand\theadset{\def\arraystretch{.85}}% +%\renewcommand\theadgape{} +%... +%\end{verbatim} +% \begin{table}[p]\makegapedcells +%\renewcommand\theadset{\def\arraystretch{.85}}% +%\renewcommand\theadgape{} +% \ttabbox +% {\caption{Example of ``\cmd{\multirow}'ed'' cells and additional vertical spaces}\label{tab:mrowII}}% +% {\begin{tabular}{|l|c|c|} +% \hline +% \multirowthead{4}{First Column head}& +% \multicolumn{2}{c|}{\thead{Multicolumn head}}\\ +% \cline{2-3} +% & \thead{Second \\multlined \\ column head} & +% \thead{Third \\ column head}\\ +% \hline +% Cell text & A &\multirowcell{4}{28--31}\\ +% \cline{1-2} +% \makecell{Multilined \\Cell text} & B& \\ +% \hline +% \makecell[l]{Left aligned \\ cell text} & C & \multirowcell{4}[0ex][l]{37--43}\\ +% \cline{1-2} +% \makecell[r]{Right aligned \\ cell text} & D & \\ +% \hline +% \makecell[b]{Bottom aligned \\ cell text} & E & \multirowcell{6}[0ex][r]{37--43\\52--58}\\ +% \cline{1-2} +% \makecell[{{p{5cm}}}]{Cell long long long long text with predefined width} & F & \\ +% \cline{1-2} +% \makecell[{{>{\parindent1em}p{5cm}}}]{Cell long long long long text with predefined width} & G & \\ +% \hline +% \end{tabular}} +% \end{table} +% \bigskip +% +% The last example (table~\ref{tab:mrowIII}) uses \env{tabularx} environment with |\hsize| +% in the width argument. +%\begin{verbatim} +%\makegapedcells +%\renewcommand\theadset{\def\arraystretch{.85}}% +%\renewcommand\theadgape{} +%\begin{tabularx}\hsize{|X|c|c|} +%... +%\cline{1-2} +%\makecell[{{p{\hsize}}}]{Cell ...} & F & \\ +%\cline{1-2} +%\makecell[{{>{\parindent1em}p{\hsize}}}]{Cell ...} & G & \\ +%\hline +%\end{tabularx} +%\end{verbatim} +% As you may see the |\makecell|'s in last two rows defined as +% \begin{quote} +% |\makecell[{{p{\hsize}}}]{...}| +% \end{quote} +% and +% \begin{quote} +% |\makecell[{{>{\parindent1em}p{\hsize}}}]{...}| +% \end{quote} +% consequently. +% \begin{table}\makegapedcells +%\renewcommand\theadset{\def\arraystretch{.85}}% +%\renewcommand\theadgape{} +% \ttabbox +% {\caption{Example of \env{tabularx} environment}\label{tab:mrowIII}}% +% {\begin{tabularx}\hsize{|X|c|c|} +% \hline +% \multirowthead{4}{First Column head}& +% \multicolumn{2}{c|}{\thead{Multicolumn head}}\\ +% \cline{2-3} +% & \thead{Second \\multlined \\ column head} & +% \thead{Third \\ column head}\\ +% \hline +% Cell text & A &\multirowcell{4}{28--31}\\ +% \cline{1-2} +% \makecell{Multilined \\Cell text} & B& \\ +% \hline +% \makecell[l]{Left aligned \\ cell text} & C & \multirowcell{4}[0ex][l]{37--43}\\ +% \cline{1-2} +% \makecell[r]{Right aligned \\ cell text} & D & \\ +% \hline +% \makecell[b]{Bottom aligned \\ cell text} & E & \multirowcell{6}[0ex][r]{37--43\\52--58}\\ +% \cline{1-2} +% \makecell[{{p{\hsize}}}]{Cell long long long long long long text with predefined width} & F & \\ +% \cline{1-2} +% \makecell[{{>{\parindent1em}p{\hsize}}}]{Cell long long long long long long text with predefined width} & G & \\ +% \hline +% \end{tabularx}} +% \end{table} +% +% \StopEventually{}\clearpage +% +% \section{Code of package} +% +% \subsection{Multilined cells} +% +% First goes request of \pkg{array} package. +% \begin{macrocode} +\RequirePackage{array} +% \end{macrocode} +% +% \begin{macro}{\makecell} +% The definition of command for multilined cells. At first defined |\gape| stuff. +% Non-star from loads special setting for vertical space around (if it used). +% Star form always creates additional vertical |\jot|-spaces. +% \begin{macrocode} +\newcommand\makecell{\@ifstar{\let\tabg@pe\gape\makecell@}% + {\let\tabg@pe\cellgape\makecell@}} +% \end{macrocode} +% Next macro loads vertical and horizontal common alignment for cells and +% defines spacing parameters |\arraystretch| and |\extrarowheight| if necessary. +% \begin{macrocode} +\newcommand\makecell@{\def\t@bset{\cellset}% + \let\mcell@align\cellalign + \@ifnextchar[\mcell@tabular + {\expandafter\mcell@@tabular\cellalign\@nil}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\thead} +% The macro for tabular column heads. At first defined |\gape| stuff. +% Non-star from loads special setting for vertical space around (if it used). +% Star form always creates additional vertical |\jot|-spaces. +% \begin{macrocode} +\newcommand\thead{\@ifstar{\let\tabg@pe\gape\thead@}% + {\let\tabg@pe\theadgape\thead@}} +% \end{macrocode} +% Next macro loads vertical and horizontal common alignment for column heads and +% defines spacing parameters |\arraystretch| and |\extrarowheight| if necessary. +% (First go settings for cells then special settings for column heads.) +% +% For column heads also loaded font settings. +% \begin{macrocode} +\newcommand\thead@{\def\t@bset{\cellset\theadfont\theadset}% + \let\mcell@align\theadalign + \@ifnextchar[\mcell@tabular + {\expandafter\mcell@@tabular\theadalign\@nil}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\rotheadsize} +% The width dimension for rotated cells. +% \begin{macrocode} +\@ifdefinable\rotheadsize{\newdimen\rotheadsize} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\rotcell} +% The macro for rotated cell. If no \pkg{rotating} package loaded +% this macro works like |\makecell|. +% \begin{macrocode} +\newcommand\rotcell{\@ifundefined{turn}% + {\PackageWarning{makecell}% + {\string\rotcell\space needs rotating package}% + \let\tabg@pe\empty\let\t@bset\cellset\makecell@} + {\@ifnextchar[{\@rotcell}{\@@rotcell}}} +% \end{macrocode} +% For rotated cell default column setting is similar to |p{\rotheadsize}| (plus some +% additional justification settings) +% \begin{macrocode} +\@ifdefinable\@rotcell{} +\def\@rotcell[#1]#2{\\[-.65\normalbaselineskip] + \turn{\cellrotangle}\makecell[#1]{#2}\endturn} +\newcommand\@@rotcell[1]{\makecell{\\[-.65\normalbaselineskip] + \turn{\cellrotangle}\makecell[c{>{\rightskip0explus + \rotheadsize\hyphenpenalty0\pretolerance-1% + \noindent\hskip\z@}p{\rotheadsize} + }]{#1}\endturn}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\rothead} +% The macro for rotated tabular column heads. If no \pkg{rotating} package loaded +% this macro works like |\thead|. +% \begin{macrocode} +\newcommand\rothead{\@ifundefined{turn}% + {\PackageWarning{makecell}{\string\rothead\space + needs rotating package}% + \let\tabg@pe\theadgape + \def\t@bset{\cellset\theadfont\theadset}\thead@}% + {\let\theadgape\rotheadgape + \@ifnextchar[{\@rothead}{\@@rothead}}} +% \end{macrocode} +% For rotated column head default column setting is similar to |p{\rotheadsize}| (plus some +% additional justification settings) +% \begin{macrocode} +\@ifdefinable\@rothead{} +\def\@rothead[#1]#2{\thead{\\[-.65\normalbaselineskip] + \turn{\cellrotangle}\thead[#1]{#2@{}}\endturn}} +\newcommand\@@rothead[1]{\thead{\\[-.65\normalbaselineskip] + \turn{\cellrotangle}\thead[c{>{\rightskip0explus + \rotheadsize\hyphenpenalty0\pretolerance-1% + \noindent\hskip\z@}p{\rotheadsize} + @{}}]{#1}\endturn}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\multirowcell} +% The macro for multirow cells. If no \pkg{multirow} package loaded +% this macro works like |\makecell|. +% \begin{macrocode} +\newcommand\multirowcell{\@ifundefined{multirow}% + {\PackageWarning{makecell}{\string\multirowcell\space + needs multirow package}}% + {\let\mcell@multirow\multirow}\mcell@mrowcell@} +% \end{macrocode} +% These macros define settings for |\multirow| arguments. +% \begin{macrocode} +\newcommand\mcell@mrowcell@[1]{\@ifnextchar + [{\mcell@mrowcell@@{#1}}{\mcell@mrowcell@@{#1}[0pt]}} +\@ifdefinable\mcell@mrowcell@@{} +\def\mcell@mrowcell@@#1[#2]{\edef\mcell@nrows{#1}\edef\mcell@fixup{#2}% + \let\tabg@pe\cellgape\makecell@} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\multirowthead} +% The macro for multirow column heads. If no \pkg{multirow} package loaded +% this macro works like |\thead|. +% \begin{macrocode} +\newcommand\multirowthead{\@ifundefined{multirow}% + {\PackageWarning{makecell}{\string\multirowthead\space + needs multirow package}}% + {\let\mcell@multirow\multirow}\mcell@mrowhead@} +% \end{macrocode} +% These macros define settings for |\multirow| arguments. +% \begin{macrocode} +\newcommand\mcell@mrowhead@[1]{\@ifnextchar + [{\mcell@mrowhead@@{#1}}{\mcell@mrowhead@@{#1}[0pt]}} +\@ifdefinable\mcell@mrowhead@@{} +\def\mcell@mrowhead@@#1[#2]{\edef\mcell@nrows{#1}\edef\mcell@fixup{#2}% + \let\tabg@pe\theadgape\thead@} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\mcell@multirow} +% By default |\mcell@multirow| macro gobbles |\multirow|'s arguments. +% \begin{macrocode} +\@ifdefinable\mcell@multirow{} +\def\mcell@multirow#1#2[#3]{}% +% \end{macrocode} +% \end{macro} +% +% Definitions for horizontal and vertical alignments, which use by \env{tabular} +% and \env{array} environments. +% +% For \texttt{l}, \texttt{r}, \texttt{t}, and \texttt{b} alignments commands +% set |c|-argument as vertical or horizontal centering alignment if necessary. +% For \texttt{l} and \texttt{r} alignments also redefined alignment +% settings for |\makecell| (|\thead|) blocks. +% \begin{macrocode} +\newcommand\mcell@l{\def\mcell@ii{l}\let\mcell@c\mcell@ic + \global\let\mcell@left\empty} +\newcommand\mcell@r{\def\mcell@ii{r}\let\mcell@c\mcell@ic + \global\let\mcell@right\empty} +\newcommand\mcell@t{\def\mcell@i{t}\let\mcell@c\mcell@iic} +\newcommand\mcell@b{\def\mcell@i{b}\let\mcell@c\mcell@iic} +\newcommand\mcell@{} +% \end{macrocode} +% If alone |c|-argument loaded it is used for horizontal alignment. +% \begin{macrocode} +\newcommand\mcell@c{\def\mcell@ii{c}} +\newcommand\mcell@ic{\def\mcell@i{c}} +\newcommand\mcell@iic{\def\mcell@ii{c}} +% \end{macrocode} +% Default vertical and horizontal alignment is centered. +% \begin{macrocode} +\newcommand\mcell@i{c} +\newcommand\mcell@ii{c} +% \end{macrocode} +% +% Default horizontal alignment of |\makecell| (|\thead|) blocks is centered. +% \begin{macrocode} +\@ifdefinable\mcell@left{\let\mcell@left\hfill} +\@ifdefinable\mcell@right{\let\mcell@right\hfill} +% \end{macrocode} +% +% \begin{macro}{\mcell@tabular} +% \begin{macro}{\mcell@@tabular} +% \begin{macro}{\mcell@@@tabular} +% The core macros for tabular building. +% +% Next few macros for sorting of |\makecell| (|\thead|) arguments. +% \begin{macrocode} +\@ifdefinable\mcell@tabular{}\@ifdefinable\mcell@@tabular{} +\@ifdefinable\mcell@@@tabular{} +\def\mcell@tabular[#1]#2{\mcell@@tabular#1\@nil{#2}} +% \end{macrocode} +% The code for this macro borrowed from \pkg{caption} 3.x package (AS). +% \begin{macrocode} +\newcommand\mcell@ifinlist[2]{% + \let\next\@secondoftwo + \edef\mcell@tmp{#1}% + \@for\mcell@Tmp:={#2}\do{% + \ifx\mcell@tmp\mcell@Tmp + \let\next\@firstoftwo + \fi}\next} +% \end{macrocode} +% +% The |\mcell@@tabular| macro at first calls |\mcell@setalign| macro for sorting of +% alignment arguments, +% then calls |\mcell@@@tabular| macro, which created tabular cell or column head. +% \begin{macrocode} +\def\mcell@@tabular#1#2\@nil#3{% + \expandafter\mcell@setalign\mcell@align\@nil + \mcell@setalign{#1}{#2}\@nil + \expandafter\mcell@@@tabular\expandafter\mcell@i\mcell@ii\@nil{#3}} +% \end{macrocode} +% +% \begin{macro}{\mcell@setalign} +% This macro sorts arguments for vertical and horizontal alignment. +% +% First argument has second check at the end of macro for the case if +% it is |c|-argument. +% \begin{macrocode} +\@ifdefinable\mcell@setalign{} +\def\mcell@setalign#1#2\@nil{\def\@tempa{#1}\def\@tempc{c}% +% \end{macrocode} +% Restore default alignment for |\makecell| and |\thead| blocks. +% \begin{macrocode} + \global\let\mcell@left\hfill\global\let\mcell@right\hfill +% \end{macrocode} +% If in optional argument appears alone |c|-argument it defines +% horizontal centering only. +% \begin{macrocode} + \def\mcell@c{\def\mcell@ii{c}}% + \mcell@ifinlist{#1}{l,r,t,b,c,}{\@nameuse{mcell@#1}}% +% \end{macrocode} +% If argument is not \texttt{l}, \texttt{r}, \texttt{c}, \texttt{t}, or \texttt{b} +% it could define horizontal alignment only. +% \begin{macrocode} + {\def\mcell@ii{#1}\let\mcell@c\mcell@ic + \let\mcell@left\empty\let\mcell@right\empty}% + \mcell@ifinlist{#2}{l,r,t,b,c,}{\@nameuse{mcell@#2}}% +% \end{macrocode} +% If argument is not \texttt{l}, \texttt{r}, \texttt{c}, \texttt{t}, or \texttt{b} +% it could define horizontal alignment only. +% \begin{macrocode} + {\def\mcell@ii{#2}\let\mcell@c\mcell@ic + \let\mcell@left\empty\let\mcell@right\empty}% +% \end{macrocode} +% Here goes repeated check for first argument, if it is |c|-argument +% we call |\mcell@c| command, which can be now redefined. +% \begin{macrocode} + \ifx\@tempa\@tempc\mcell@c\fi +} +% \end{macrocode} +% \end{macro} +% +% This macro builds tabular itself. +% First (and last) go commands which align |\makecell| and |\thead| +% blocks like \texttt{l}, \texttt{r}, or \texttt{c} (if they loaded). +% Then goes check whether math mode exists. +% The |\mcell@multirow| emulation macro transforms to |\multirow| when necessary. +% \begin{macrocode} +\def\mcell@@@tabular#1#2\@nil#3{%\mcell@mstyle + \ifdim\parindent<\z@\leavevmode\else\noindent\fi + \null\mcell@left + \ifmmode + \mcell@multirow\mcell@nrows*[\mcell@fixup]{\tabg@pe + {\hbox{\t@bset$\array[#1]{@{}#2@{}}#3\endarray$}}}% + \else + \mcell@multirow\mcell@nrows*[\mcell@fixup]{\tabg@pe + {\hbox{\t@bset\tabular[#1]{@{}#2@{}}#3\endtabular}}}% + \fi\mcell@right\null} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\cellset} +% \begin{macro}{\cellgape} +% \begin{macro}{\cellalign} +% \begin{macro}{\cellrotangle} +% \begin{macro}{\theadfont} +% \begin{macro}{\theadset} +% \begin{macro}{\theadgape} +% \begin{macro}{\rotheadgape} +% \begin{macro}{\theadalign} +% The layout macros for tabular building settings.\nopagebreak +% +% Spacing settings for tabular spacing inside cells (like |\arraystretch| or |\extrarowheight|).\nopagebreak +% \begin{macrocode} +\newcommand\cellset{\def\arraystretch{1}\extrarowheight\z@ + \nomakegapedcells} +% \end{macrocode} +% Vertical space around cells (created by |\gape| stuff). +% \begin{macrocode} +\newcommand\cellgape{} +% \end{macrocode} +% Vertical and horizontal alignment of cell text. +% \begin{macrocode} +\newcommand\cellalign{cc} +% \end{macrocode} +% Angle for rotated column heads and cells. +% \begin{macrocode} +\newcommand\cellrotangle{90} +% \end{macrocode} +% +% Font for column heads +% \begin{macrocode} +\newcommand\theadfont{\footnotesize} +% \end{macrocode} +% Special spacing settings for tabular spacing in column heads (like |\arraystretch| or/and |\extrarowheight|). +% \begin{macrocode} +\newcommand\theadset{} +% \end{macrocode} +% Vertical space around column heads (created by |\gape| stuff). +% \begin{macrocode} +\newcommand\theadgape{\gape} +% \end{macrocode} +% Vertical space around rotated column heads. +% \begin{macrocode} +\newcommand\rotheadgape{} +% \end{macrocode} +% Vertical and horizontal alignment of column head text. +% \begin{macrocode} +\newcommand\theadalign{cc} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \subsection{Gape commands} +% +% \begin{macro}{\gape} +% \begin{macro}{\setcellgapes} +% The macro itself. It uses analogous to |\smash| macro from \pkg{amsmath} package. +% Starred form has additional mandatory argument for value of |\gape|. +% \begin{macrocode} +\newcommand\gape{\@ifnextchar[\@gape{\@gape[tb]}} +% \end{macrocode} +% +% The |\setcellgapes| defines settings used by |\makegapedcells| command. +% +% First goes check for optional argument. +% \begin{macrocode} +\newcommand\setcellgapes{\@ifnextchar[%] + {\mcell@setgapes{MB}}{\mcell@setgapes{MB}[tb]}} +% \end{macrocode} +% Then body of settings. +% \begin{macrocode} +\@ifdefinable\@setcellgapes{} +\def\mcell@setgapes#1[#2]#3{\expandafter\let\csname + mcell@#1@\expandafter\endcsname\csname mcell@mb@#2\endcsname + \@namedef{mcell@#1jot}{#3}} +% \end{macrocode} +% +% The macros which count advanced height and depth of boxes. +% \begin{macrocode} +\newcommand\mcell@mb@t[2]{\@tempdima\ht#1\advance\@tempdima#2% + \ht#1\@tempdima} +\newcommand\mcell@mb@b[2]{\@tempdimb\dp#1\advance\@tempdimb#2% + \dp#1\@tempdimb} +\newcommand\mcell@mb@tb[2]{\mcell@mb@t{#1}{#2}\mcell@mb@b{#1}{#2}} +% \end{macrocode} +% +% The body of |\gape| macros. +% \begin{macrocode} +\@ifdefinable\@gape{}\@ifdefinable\@@gape{} +\def\@gape[#1]{\mcell@setgapes{mb}[#1]{\jot}\@@gape} +\def\@@gape{% + \ifmmode \expandafter\mathpalette\expandafter\mathg@pe + \else \expandafter\makeg@pe + \fi} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\makeg@pe} +% The macros which put box with necessary parameters in text and math mode. +% \begin{macrocode} +\newcommand\makeg@pe[1]{\setbox\z@ + \hbox{\color@begingroup#1\color@endgroup}\mcell@mb@\z@\mcell@mbjot\box\z@} +\newcommand\mathg@pe[2]{\setbox\z@ + \hbox{$\m@th#1{#2}$}\mcell@mb@\z@\mcell@mbjot\box\z@} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\Gape} +% The macros which put box with necessary parameters in text and math mode. +% \begin{macrocode} +\newcommand\Gape{\@ifnextchar[\@Gape{\@Gape[\jot]}} +\@ifdefinable\@Gape{}\@ifdefinable\@@Gape{} +\def\@Gape[#1]{\@ifnextchar[{\@@Gape[#1]}{\@@Gape[#1][#1]}} +\def\@@Gape[#1][#2]{\def\depth{\dp\z@}\def\height{\ht\z@}% + \edef\mcell@mb@##1##2{% + \@tempdima\ht\z@\advance\@tempdima#1\ht\z@\@tempdima + \@tempdimb\dp\z@\advance\@tempdimb#2\dp\z@\@tempdimb}% + \@@gape} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\topstrut} +% \begin{macro}{\botstrut} +% \begin{macro}{\bottopstrut} +% The macros abbreviations for |\strut| which changed by value of |\jot|. +% First enlarges both depth and height. +% \begin{macrocode} +\newcommand\bottopstrut{\gape{\strut}} +% \end{macrocode} +% Second enlarges only height. +% \begin{macrocode} +\newcommand\topstrut{\gape[t]{\strut}} +% \end{macrocode} +% Third enlarges only depth. +% \begin{macrocode} +\newcommand\botstrut{\gape[b]{\strut}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \subsection{Modification of command from \pkg{array} package} +% +% \begin{macro}{\makegapedcells} +% \begin{macro}{\nomakegapedcells} +% At first is saved |\@classz| macro. +% \begin{macrocode} +\@ifdefinable\mcell@oriclassz{\let\mcell@oriclassz\@classz} +% \end{macrocode} +% This macros redefine and restore the |\@classz| macro from \pkg{array} package. +% \begin{macrocode} +\newcommand\makegapedcells{\let\@classz\mcell@classz} +\newcommand\nomakegapedcells{\let\@classz\mcell@oriclassz} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\mcell@agape} +% Following macro creates tabular/array cells with changed vertical spaces. +% \begin{macrocode} +\newcommand\mcell@agape[1]{\setbox\z@\hbox{#1}\mcell@MB@\z@\mcell@MBjot + \null\mcell@left\box\z@\mcell@right\null} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\mcell@classz} +% Redefined |\@classz| macro from \pkg{array} package. +% \begin{macrocode} +\newcommand\mcell@classz{\@classx + \@tempcnta \count@ + \prepnext@tok + \@addtopreamble{%\mcell@mstyle + \ifcase\@chnum + \hfil + \mcell@agape{\d@llarbegin\insert@column\d@llarend}\hfil \or + \hskip1sp + \mcell@agape{\d@llarbegin\insert@column\d@llarend}\hfil \or + \hfil\hskip1sp + \mcell@agape{\d@llarbegin \insert@column\d@llarend}\or + $\mcell@agape{\vcenter + \@startpbox{\@nextchar}\insert@column\@endpbox}$\or + \mcell@agape{\vtop + \@startpbox{\@nextchar}\insert@column\@endpbox}\or + \mcell@agape{\vbox + \@startpbox{\@nextchar}\insert@column\@endpbox}% + \fi + \global\let\mcell@left\relax\global\let\mcell@right\relax + }\prepnext@tok} +% \end{macrocode} +% \end{macro} +% +% \Finale +\endinput |