summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/tablestyles/tablestyles.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-06-30 22:34:39 +0000
committerKarl Berry <karl@freefriends.org>2014-06-30 22:34:39 +0000
commit01df96665409d4a1c5997f16eca8d675fbecfd1d (patch)
tree26b2398727a4b1c82a11e7e14dc3b6515480a9b1 /Master/texmf-dist/tex/latex/tablestyles/tablestyles.sty
parent4c52f74e67221e5eb20878b68275669813751c9f (diff)
tablestyles (29jun14)
git-svn-id: svn://tug.org/texlive/trunk@34488 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/tablestyles/tablestyles.sty')
-rw-r--r--Master/texmf-dist/tex/latex/tablestyles/tablestyles.sty273
1 files changed, 273 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/tablestyles/tablestyles.sty b/Master/texmf-dist/tex/latex/tablestyles/tablestyles.sty
new file mode 100644
index 00000000000..be2ddd8cfc6
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/tablestyles/tablestyles.sty
@@ -0,0 +1,273 @@
+
+%%
+\NeedsTeXFormat{LaTeX2e}[1994/12/01]
+\ProvidesPackage{tablestyles}
+ [2011/10/01 v0.1 tablestyles]
+\RequirePackage{array}
+\RequirePackage{etoolbox}
+%% check that xcolor is not loaded
+\@ifpackageloaded{xcolor}{%
+ \ifcsdef{rowcolors}{}{%
+ \PackageError{tablestyles}%
+ {%
+\MessageBreak%
+Package 'xcolor' must be loaded with the option\MessageBreak%
+'tables'. Otherwise the command rowcolors\MessageBreak%
+is not available. \MessageBreak%
+ }{}%
+ \endinput%
+ }%
+}{%
+ % xcolor not loaded
+ \PassOptionsToPackage{table}{xcolor}
+ \RequirePackage{xcolor}
+}
+\RequirePackage{ragged2e}
+\AtBeginDocument{%
+\@ifpackageloaded{tabularx}{}{
+ \PackageError{tablestyles}%
+ {%
+\MessageBreak%
+Package 'tabularx' must be loaded, otherwise tablestyles will not
+work.
+ }%
+}% end of ifpackageloaded
+}% end of AtBeginDocument
+%% define table styles (save the code)
+\newcommand{\setuptablestyle}[2]{%
+ \ifcsdef{tsty@style@#1}
+ {
+ \PackageWarning{tablestyles}{
+ \MessageBreak
+ table style `#1' is already defined.
+ }{}
+ }{}
+ \csdef{tsty@style@#1}{#2}
+}
+%% apply table styles (use the code)
+\newcommand{\tablestyle}[1][default]{%
+ \ifcsdef{tsty@style@#1}{}{
+ \PackageError{tablestyles}{
+ \MessageBreak
+ table style `#1' is not defined.
+ \endinput%
+ }{}
+ }
+ \csuse{tsty@style@#1}
+}
+%% save font size with name
+\newcommand{\setuptablefontsize}[2]{
+ \csdef{tsty@font@#1@size}{#2}
+}
+%% apply font size with name
+\newcommand{\tablefontsize}[1]{
+ \ifcsdef{tsty@font@#1@size}%
+ {\csuse{tsty@font@#1@size}%
+ }{ % not defined
+ \PackageError{tablestyles}{
+ \MessageBreak
+ table font size `#1' is not defined.
+ \endinput%
+ }{}%
+ }%
+}%
+%% define default font sizes
+\setuptablefontsize{body}{\small}
+\setuptablefontsize{head}{\small}
+%% save color with name
+\newcommand{\setuptablecolor}[2]{%
+ \colorlet{tsty@color@#1}{#2}%
+}
+%% apply colorwith name
+\newcommand{\tablecolor}[1]{tsty@color@#1}
+%% default colors
+\newcommand{\tsty@defaultcolors}{
+ \setuptablecolor{body}{white!100}
+ \setuptablecolor{row}{gray!10}
+ \setuptablecolor{head}{gray!25}
+ \setuptablecolor{subhead}{gray!30}
+}
+%% exectuted default colors
+\tsty@defaultcolors
+%% shortcut for alternating rowcolors
+\newcommand\tablealtcolored{%
+\rowcolors{1}{\tablecolor{row}}{\tablecolor{body}}%
+}
+%% disable alternating rowcolors by changing the colors
+\newcommand{\disablealternatecolors}{%
+ \setuptablecolor{row}{\tablecolor{body}}%
+}
+%% colored horizontal lines (hlines)
+\providecommand{\coloredhline}[1]{%
+ \arrayrulecolor{#1}\hline
+ \arrayrulecolor{black}
+}%
+%% colored vertical lines (vlines)
+\providecommand{\coloredvline}[1]{%
+ \color{#1}\vline
+}%
+%% commands for the style of the lines
+\newcommand{\tlinetop}{\coloredhline{black}}
+\newcommand{\tlinemid}{\coloredhline{black}}
+\newcommand{\tlinebottom}{\coloredhline{black}}
+%% commands for the seperations (includes the lines)
+\newcommand{\tbegin}{\tlinetop}
+\newcommand{\tbody}{\tlinemid}
+\newcommand{\tend}{\tlinebottom}
+%% default head style (only fontsize)
+\newcommand\thead{%
+ \tablefontsize{head}
+}
+%% default subhead style (only fontsize)
+\newcommand{\tsubhead}{%
+ \tablefontsize{head}
+}
+%% style of header start (line and row color)
+\newcommand\theadstart{%
+ \tlinetop%
+ \rowcolor{\tablecolor{head}}%
+}
+%% style of header end - empty
+\newcommand\theadend{}
+%% style of subheader start (row color)
+\newcommand{\tsubheadstart}{%
+ \rowcolor{\tablecolor{subhead}}
+}
+%% style of subheader end - empty
+\newcommand\tsubheadend{}
+%% shortcut for multi column row in header
+\newcommand{\theadrow}[2]{%
+ \multicolumn{#1}{>{\columncolor{\tablecolor{head}}}l}{%
+ \thead #2%
+ }%
+ \tabularnewline%
+}%
+%% shortcut for multi column row in subheader
+\newcommand{\tsubheadrow}[2]{%
+ \multicolumn{#1}{>{\columncolor{\tablecolor{subhead}}}l}{%
+ \tsubhead #2%
+ }%
+ \tabularnewline%
+}%
+%% reset to default styles
+\newcommand{\resettablestyle}{%
+ \normalcolor\normalfont\normalsize%
+ \renewcommand{\arraystretch}{1}%
+ \rmfamily%
+ \tsty@defaultcolors%
+ \renewcommand{\tlinetop}{\coloredhline{black}}
+ \renewcommand{\tlinemid}{\coloredhline{black}}
+ \renewcommand{\tlinebottom}{\coloredhline{black}}
+ \renewcommand{\theadstart}{\tlinetop\rowcolor{\tablecolor{head}}}
+ \renewcommand{\tbegin}{\tlinetop}
+ \renewcommand{\tbody}{\tlinemid}
+ \renewcommand{\tend}{\tlinebottom}
+}
+%% style: default
+\setuptablestyle{default}{%
+ \resettablestyle
+ \renewcommand{\arraystretch}{1.4}
+ \centering
+ \sffamily
+ \upshape%
+ \tablefontsize{body}
+ \tablealtcolored%
+ \renewcommand{\thead}{%
+\tablefontsize{head}%
+\ignorespaces%
+ }
+ \renewcommand{\tsubhead}{%
+\tablefontsize{head}%
+\ignorespaces%
+ }
+}
+%% style: roman
+\setuptablestyle{roman}{%
+ \resettablestyle
+ \renewcommand{\arraystretch}{1.4}
+ \centering
+ \rmfamily
+ \upshape%
+ \tablefontsize{body}
+ \tablealtcolored%
+ \renewcommand{\thead}{%
+\tablefontsize{head}%
+\ignorespaces%
+ }
+ \renewcommand{\tsubhead}{%
+\tablefontsize{head}%
+\ignorespaces%
+ }
+}
+%% style: sansbold
+\setuptablestyle{sansbold}{%
+ \resettablestyle
+ \renewcommand{\arraystretch}{1.4}
+ \centering
+ \sffamily
+ \upshape%
+ \tablefontsize{body}
+ \tablealtcolored%
+ \renewcommand{\thead}{%
+\tablefontsize{head}%
+\bfseries
+\upshape%
+\ignorespaces%
+ }
+ \renewcommand{\tsubhead}{%
+\tablefontsize{head}%
+\upshape%
+\ignorespaces%
+ }
+}
+%% style: sansboldbw
+\setuptablestyle{sansboldbw}{%
+ \resettablestyle
+ \setuptablecolor{body}{white!100}
+ \setuptablecolor{row}{gray!15}
+ \setuptablecolor{head}{black!60}
+ \setuptablecolor{subhead}{gray!40}
+ \renewcommand{\arraystretch}{1.4}
+ \centering
+ \sffamily
+ \upshape%
+ \tablefontsize{body}
+ \tablealtcolored%
+ \renewcommand{\thead}{%
+\leavevmode\color{white}
+\tablefontsize{head}%
+\bfseries
+\slshape
+\ignorespaces%
+ }
+ \renewcommand{\tsubhead}{%
+\tablefontsize{head}%
+\bfseries
+\ignorespaces%
+ }
+}
+%% bugfix code for lists in tables
+\newcommand{\tsty@removeindentation}{%
+\leftmargini=\labelsep%
+\advance\leftmargini by \labelsep%
+}
+\newcommand\tableitemize{
+\@minipagetrue%
+\tsty@removeindentation
+}
+%% New columntype definitions:
+%% centered (X):
+\newcolumntype{Z}{>{\centering\arraybackslash\hspace{0pt}}X}
+%% right (X):
+\newcolumntype{Y}{>{\RaggedLeft\arraybackslash\hspace{0pt}}X}
+%% left (X):
+\newcolumntype{W}{>{\RaggedRight\arraybackslash\hspace{0pt}}X}
+%% left (p):
+\newcolumntype{L}[1]{>{\RaggedRight\arraybackslash\hspace{0pt}}p{#1}}
+%% right (p):
+\newcolumntype{R}[1]{>{\RaggedLeft\arraybackslash\hspace{0pt}}p{#1}}
+%% centered (p):
+\newcolumntype{C}[1]{>{\Centering\arraybackslash\hspace{0pt}}p{#1}}
+\endinput
+%%
+%% End of file `tablestyles.sty'.