src.dualinventive.com/tools/template-latex/di/table.sty

72 lines
1.5 KiB
TeX

\ProvidesPackage{di/table}
\RequirePackage{booktabs}
\RequirePackage{caption}
\RequirePackage{etoolbox}
\RequirePackage{longtable}
\RequirePackage{xparse}
% define pdtable environment
\ExplSyntaxOn
\NewDocumentEnvironment{pdtable}{O{!ht} O{raggedright}mm}
{
\table[#1]
\captionsetup{format=plain, font=it, justification=#2, singlelinecheck=off, skip=6pt}
\ifstrequal{#2}{centering}{\centering}{}
\caption{#4}
\label{#3}
}
{
\endtable
}
\ExplSyntaxOff
\renewcommand{\thetable}{\arabic{chapter}.\arabic{table}}
% Thick vrule macro
\newcommand{\pdoutline}{\vrule width 1.5pt}
% Rule macros
\newcommand{\pdtoprule}{\specialrule{1.5pt}{0pt}{0pt}}
\newcommand{\pdmidrule}{\specialrule{0.4pt}{0pt}{0pt}}
\newcommand{\pdbottomrule}{\specialrule{1.1pt}{0pt}{0pt}} %1.5pt - 0.4pt (\pdtablerow) = 1.1pt
% Table header macro
\newcommand{\pdtablehead}[1]
{%
#1\\%
\pdtoprule%
}
% Table row macro
\newcommand{\pdtablerow}[1]
{%
#1 \\%
\pdmidrule%
}
% Table row macro that spans all columns in the table.
\newcommand{\pdtablerowspan}[3]
{
\multicolumn{#1}{!{\pdoutline}#2!{\pdoutline}}{#3} \\
\pdmidrule
}
% Table row macro that spans selected columns in the table.
\newcommand{\pdmulticolumn}[3]
{
\multicolumn{#1}{#2|}{#3}
}
% Table row macro that spans selected columns in the table.
\newcommand{\pdmulticolumnright}[3]
{
\multicolumn{#1}{#2!{\pdoutline}}{#3}
}
% Table row macro that spans selected columns in the table.
\newcommand{\pdmulticolumnleft}[3]
{
\multicolumn{#1}{!{\pdoutline}#2|}{#3}
}