diff options
author | Karl Berry <karl@freefriends.org> | 2014-06-30 22:34:39 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-06-30 22:34:39 +0000 |
commit | 01df96665409d4a1c5997f16eca8d675fbecfd1d (patch) | |
tree | 26b2398727a4b1c82a11e7e14dc3b6515480a9b1 /Master/texmf-dist | |
parent | 4c52f74e67221e5eb20878b68275669813751c9f (diff) |
tablestyles (29jun14)
git-svn-id: svn://tug.org/texlive/trunk@34488 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/tablestyles/tablestyles.pdf | bin | 0 -> 456191 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/tablestyles/tablestyles.dtx | 1639 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/tablestyles/tablestyles.ins | 29 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tablestyles/tablestyles.sty | 273 |
4 files changed, 1941 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/tablestyles/tablestyles.pdf b/Master/texmf-dist/doc/latex/tablestyles/tablestyles.pdf Binary files differnew file mode 100644 index 00000000000..db636e76843 --- /dev/null +++ b/Master/texmf-dist/doc/latex/tablestyles/tablestyles.pdf diff --git a/Master/texmf-dist/source/latex/tablestyles/tablestyles.dtx b/Master/texmf-dist/source/latex/tablestyles/tablestyles.dtx new file mode 100644 index 00000000000..e3366c9f525 --- /dev/null +++ b/Master/texmf-dist/source/latex/tablestyles/tablestyles.dtx @@ -0,0 +1,1639 @@ +% \iffalse meta-comment +% +% File: tablestyles.sty +% Version: 2014/06/27 v0.1 +% Author: Matthias Pospiech +% Email: <matthias.pospiech@gmx.de> +% +% Copyright (C) 2014 by Matthias Pospiech (matthias@pospiech.eu) +% --------------------------------------------------------------------------- +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Matthias Pospiech. +% +% This work consists of the files tablestyles.dtx and tablestyles.ins +% and the derived filebase tablestyles.sty. +% +% +% \fi +% +% \iffalse +%<*driver> +\ProvidesFile{tablestyles.dtx} +%</driver> +%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] +%<package>\ProvidesPackage{tablestyles} +%<*package> + [2014/06/27 0.1 enhanced table commands for configurable table layout] +%</package> +% +%<*driver> +\documentclass{ltxdoc} +\usepackage{hypdoc} +\RequirePackage[% + loadHyperref=true, + createIndexEntries=false, + applyLayout=true] +{doctools} % +% +\usepackage{tablestyles}[2014/06/27] +\EnableCrossrefs +\CodelineIndex +\RecordChanges +% +%%% Additional packages +\usepackage{soulutf8} +\usepackage[table]{xcolor} +\usepackage{enumitem} +\usepackage{tabu} +\usepackage{float} +\usepackage{ltxtable} +% +\listfiles +\begin{document} + \DocInput{tablestyles.dtx} + \PrintChanges + \PrintIndex +\end{document} +%</driver> +% \fi +% +% +% +% \CharacterTable +% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +% Digits \0\1\2\3\4\5\6\7\8\9 +% Exclamation \! Double quote \" Hash (number) \# +% Dollar \$ Percent \% Ampersand \& +% Acute accent \' Left paren \( Right paren \) +% Asterisk \* Plus \+ Comma \, +% Minus \- Point \. Solidus \/ +% Colon \: Semicolon \; Less than \< +% Equals \= Greater than \> Question mark \? +% Commercial at \@ Left bracket \[ Backslash \\ +% Right bracket \] Circumflex \^ Underscore \_ +% Grave accent \` Left brace \{ Vertical bar \| +% Right brace \} Tilde \~} +% +% +% \changes{0.1}{2014/06/27}{Initial version.} +% +% \DoNotIndex{\newcommand,\newenvironment} +% +% \providecommand*{\url}{\texttt} +% \GetFileInfo{tablestyles.dtx} +% \title{The \textsf{tablestyles} package} +% \author{Matthias Pospiech \\ \url{matthias.pospiech@gmx.de}} +% \date{\fileversion~from \filedate} +% +% \maketitle +% \begin{abstract}\noindent +% LaTeX unfortunately does not include a good separation of text and style in +% tables. This package tries to solve this problem by defining reusable table +% commands and an interface to define a style for table. Furthermore the +% package defines common used column styles and a bugfix command for lists in +% tables. +% \end{abstract} +% \tableofcontents +% +% \section{Introduction} +% +% This package provides commands to be used inside a tabular environment, +% which allow the user to define the style of a table once but apply it to +% every table using the commands defined by this package. +% The styles are divided into the head, subhead and the body of the table. +% Further this package introduces new column types and enhancing the +% typesetting of lists inside tables. +% +% \section{Usage} +% +% The usage is first described using a brief review of the possibilities +% to change the layout of a table using the font size, font color, +% line appearance and the background colors of special and +% alternating cells. The latter is based on the xcolor/colortab package. +% Subsequent the commands provided by the package are explained in detail +% followed by a description of the creation of new styles. +% +% \subsection{Loading} +% The package is loaded with +% \iffalse +%<*example> +% \fi +\begin{lstlisting}[style=lstDemoStyleLaTeXCode]% +\usepackage{tablestyles} +\end{lstlisting} +% \iffalse +%</example> +% \fi +% \noindent It should be loaded after the xcolor package and before the +% hyperref package. +% +% \subsection{Tutorial} +% +% The code listing~\ref{code:manualtable} shows a tabular with all commands +% necessary to set up the style of the table displayed below +% (table~\ref{tab:examplenostyle}). In this code the commands of this package +% are \emph{not} used. The equivalent code with the commands of this package +% is provided in the following code listing~\ref{code:tablewithstyle}. +% \iffalse +%<*example> +% \fi + +\colorlet{colorbody}{white!100} +\colorlet{colorsubhead}{gray!30} +\colorlet{colorhead}{gray!25} +\colorlet{colorrow}{gray!15.0} + +\begin{lstlisting}[style=lstDemoStyleLaTeXCode , basicstyle=\small\ttfamily, + captionpos=b,caption={example code for a table with manual changes to the appereance.},label={code:manualtable}] +\begin{table} +% +\small % fontsize +\sffamily % font family = sans serif +\centering % alignment of tabular +\renewcommand{\arraystretch}{1.4} % larger cell height +\rowcolors{1}{colorrow}{colorbody}% +% +\begin{tabular}{*{2}{p{0.45\textwidth}}} + \hline + \rowcolor{colorhead} + \bfseries header & + \bfseries header \\ + \hline + % + content & content \\ + content & content \\ + content & content \\ + content & content \\ + content & content \\ + % + \rowcolor{colorsubhead} + subhead & subhead \\ + % + content & content \\ + content & content \\ + \hline +\end{tabular} +\caption{table with bold header font} +\end{table} +\end{lstlisting} + +% \iffalse +%</example> +% \fi +% +% \begin{table}[H] +% % +% \small +% \sffamily +% \centering +% \renewcommand{\arraystretch}{1.4} +% \rowcolors{1}{colorrow}{colorbody} +% +% \begin{tabular}{*{2}{p{0.45\textwidth}}} +% \hline +% \rowcolor{colorhead} +% \bfseries header & +% \bfseries header \\ +% \hline +% content & content \\ +% content & content \\ +% content & content \\ +% content & content \\ +% content & content \\ +% \rowcolor{colorsubhead} +% subhead & subhead \\ +% content & content \\ +% content & content \\ +% \hline +% \end{tabular} +% +% \caption{table with bold header font} +% \label{tab:examplenostyle} +% \end{table} +% +% The aim of this package is to generalize the generation of such tabular +% styles. The code listing~\ref{code:tablewithstyle} demonstrates the usage, +% with the result shown in table~\ref{tab:examplestyle}, +% which is identical with the previous one (table~\ref{tab:examplenostyle}). +% +% \iffalse +%<*example> +% \fi + +\begin{lstlisting}[style=lstDemoStyleLaTeXCode , captionpos=b,caption={example code for a table with style commands.}, label={code:tablewithstyle}] +\begin{table} +% +\tablestyle[sansbold] +% +\begin{tabular}{*{2}{p{0.45\textwidth}}} +\theadstart + \thead header & + \thead header \\ +\tbody + % + content & content \\ + content & content \\ + content & content \\ + content & content \\ + content & content \\ + % + \tsubheadstart + \tsubhead subhead & + \tsubhead subhead \\ + % + content & content \\ + content & content \\ + \tend +\end{tabular} +\caption{table with bold header font using the styles by this package} +\end{table} +\end{lstlisting} + +% \iffalse +%</example> +% \fi +% +% \begin{table}[H] +% % +% \tablestyle[sansbold] +% +% \begin{tabular}{*{2}{p{0.45\textwidth}}} +% \theadstart +% \thead header & +% \thead header \\ +% \tbody +% % +% content & content \\ +% content & content \\ +% content & content \\ +% content & content \\ +% content & content \\ +% % +% \tsubheadstart +% \tsubhead subhead & +% \tsubhead subhead \\ +% % +% content & content \\ +% content & content \\ +% \tend +% \end{tabular} +% \caption{table with bold header font using the styles by this package} +% \label{tab:examplestyle} +% \end{table} +% +% The following sections show the possibilities of applying a style in general +% and how to style a heading or subheading +% +% \subsubsection{applying styles} +% +% The command \DescribeMacro{\tablestyle}\cs{tablestyle}\oarg{style} is used +% to choose the style of the table. It redefines all commands that apply +% changes to font, colors, lines, etc. It is required before the tabular +% environment to apply the changes to the complete table. +% If not inserted the last chosen layout, or if never applied the standard +% layout is used. +% +% To apply lines or any other elements at the top and bottom of a table the +% commands \DescribeMacro{\tbegin}\cs{tbegin} at the beginning +% \DescribeMacro{\tend}\cs{tend} at the end of the table are used. +% +% \iffalse +%<*example> +% \fi + +\begin{lstlisting}[style=lstDemoStyleLaTeXCode , captionpos=b,caption={code example with table style applied.}, label={code:tablestylebasic}] +\begin{table} +% +\tablestyle[stylename] +% +\begin{tabular}{*{2}{p{0.45\textwidth}}} +\tbegin + % + content & content \\ + content & content \\ +\tend +\end{tabular} +\end{table} +\end{lstlisting} + +% \iffalse +%</example> +% \fi +% +% \subsubsection{headings and subheadings} +% +% If a table starts with a header \cs{tbegin} is replaced by \cs{theadstart} +% and the following main table content starts with +% \DescribeMacro{\tbody}\cs{tbody} (as shown in the previous code +% listing~\ref{code:tablestylebasic}). In general the commands +% \DescribeMacro{\theadstart}\cs{theadstart} and +% \DescribeMacro{\tsubheadstart}\cs{tsubheadstart} set up +% the color of the heading row and print out a line by default. +% \DescribeMacro{\theadend}\cs{theadend} and +% \DescribeMacro{\tsubheadend}\cs{tsubheadend} can be used to print out a +% line afterwards (or apply any other useful properties at the end), but are +% empty by default. The properties of each cell in the heading are applied with +% \DescribeMacro{\thead}\cs{thead} and \DescribeMacro{\tsubhead}\cs{tsubhead}. +% Unfortunately the cell property command must be applied to each cell. The +% code listing~\ref{code:headings} demonstrates the implementation of +% heading and subheading. +% +% \iffalse +%<*example> +% \fi + +\begin{lstlisting}[style=lstDemoStyleLaTeXCode , captionpos=b,caption={code for heading and subheading.}, label={code:headings}] +\theadstart + \thead header & + \thead header \\ +\theadend % not necessary in default styles +\tbody + % + content & content \\ +... + content & content \\ + % + \tsubheadstart + \tsubhead subhead & + \tsubhead subhead \\ + \tsubheadend % not necessary in default styles + % +\end{lstlisting} + +% \iffalse +%</example> +% \fi +% +% If a heading or subheading shall span all columns of a table this can be +% achieved with the simplified commands +% \DescribeMacro{\theadrow}\cs{theadrow}\marg{number of cells}\marg{text} +% and the equivalent \DescribeMacro{\tsubheadrow}\cs{tsubheadrow}\marg{number +% of cells}\marg{text}. +% Note that these automatically insert a \cs{tabularnewline}. The first +% parameter therefore must match the number of columns in the table. +% +% \iffalse +%<*example> +% \fi + +\begin{lstlisting}[style=lstDemoStyleLaTeXCode , captionpos=b,caption={example for multi column rows.}, label={code:headrows}] +\theadstart +\theadrow{2}{full width header} +\tbody + % + content & content \\ + % +\tsubheadrow{2}{full width subheader} % +% + content & content \\ +\end{lstlisting} + +% \iffalse +%</example> +% \fi +% +% +% \subsection{Setup of styles} +% +% Style are applied to the table with the following commands +% \begin{itemize}[noitemsep] +% \item \cs{tbegin} +% \item \cs{tbody} +% \item \cs{tend} +% \item \cs{thead} +% \item \cs{theadstart} +% \item \cs{theadend} +% \item \cs{tsubheadstart} +% \item \cs{tsubheadend} +% \item \cs{tsubhead} +% \item \cs{theadrow} +% \item \cs{tsubheadrow} +% \end{itemize} +% which were described in the previous section. To define the style the following +% commands are used which define the font, the color, and other settings. +% +% +% \subsubsection{fontsize} +% Font sizes can be set up using \DescribeMacro{\setuptablefontsize} +% \cs{setuptablefontsize}\marg{name}\marg{size definition} and be retrieved with +% \DescribeMacro{\tablefontsize}\cs{tablefontsize}\marg{name}. Predefined are sizes +% for \emph{body} and \emph{head} +% +% \iffalse +%<*example> +% \fi + +\begin{lstlisting}[style=lstDemoStyleLaTeXCode , captionpos=b,caption={configuration and selection of font sizes .}, label={code:fontsizes}] +% definition +\setuptablefontsize{body}{\small} +... +% request size +\tablefontsize{body} % outputs \small +\end{lstlisting} + +% \iffalse +%</example> +% \fi +% +% \subsubsection{colors} +% Colors are defined and requested similar to font sizes, here with the +% commands \DescribeMacro{\setuptablecolor} +% \cs{setuptablecolor}\marg{color name}\marg{color definition} and +% \DescribeMacro{\tablecolor}\cs{tablecolor}\marg{color name}. The color +% definition % must be in the notation of xcolor. +% Predefined are colors for \emph{body}, \emph{head}, \emph{subhead} and +% \emph{row}. +% +% \iffalse +%<*example> +% \fi + +\begin{lstlisting}[style=lstDemoStyleLaTeXCode , captionpos=b,caption={configuration and selection of colors.}, label={code:colors}] +% definition +\setuptablecolor{body}{white!100} +... +% request color +\tablecolor{body} % outputs white!100 +\end{lstlisting} + +% \iffalse +%</example> +% \fi + +% \subsubsection{alternating row colors} +% +% Alternating rows are implemented using the \cs{rowcolors} command of the +% colortbl package (should be loaded by xcolor). +% Here the colors \emph{body} and \emph{row} are alternated. They are +% introduced using \DescribeMacro{\tablealtcolored}\cs{tablealtcolored} and +% can be disabled (until the style of tables is reset using \cs{tablestyle}) +% with \DescribeMacro{\disablealternatecolors}\cs{disablealternatecolors}. +% The examples below show the effect. +% +% \iffalse +%<*example> +% \fi + +\begin{minipage}[t]{0.48\linewidth} +\begin{lstlisting}[style=lstDemoStyleLaTeXCode , captionpos=b,caption={automatic alternating row colors.}, label={code:rowcolors}] +\begin{table}[H] +\tablestyle % using \tablealtcolored +\begin{tabular}{*{2}{p{0.25\textwidth}}} +\tbegin + content & content \\ + content & content \\ + content & content \\ + content & content \\ + \tend +\end{tabular} +\end{table} \end{lstlisting} +\end{minipage} +\hfill +\begin{minipage}[t]{0.48\linewidth} +\begin{table}[H] +\tablestyle +\begin{tabular}{*{2}{p{0.25\textwidth}}} +\tbegin + content & content \\ + content & content \\ + content & content \\ + content & content \\ + \tend +\end{tabular} +\end{table} +\end{minipage} \newline + +\begin{minipage}[t]{0.48\linewidth} +\begin{lstlisting}[style=lstDemoStyleLaTeXCode , captionpos=b,caption={disabled alternating row colors.}, label={code:norowcolors}] +\begin{table}[H] +\tablestyle +\disablealternatecolors +\begin{tabular}{*{2}{p{0.25\textwidth}}} +\tbegin + content & content \\ + content & content \\ + content & content \\ + content & content \\ + \tend +\end{tabular} +\end{table} +\end{lstlisting} +\end{minipage} +\hfill +\begin{minipage}[t]{0.48\linewidth} +\begin{table}[H] +\tablestyle +\disablealternatecolors +\begin{tabular}{*{2}{p{0.25\textwidth}}} +\tbegin + content & content \\ + content & content \\ + content & content \\ + content & content \\ + \tend +\end{tabular} +\end{table} +\end{minipage} \newline + +% \iffalse +%</example> +% \fi +% +% \subsubsection{colored lines in tables} +% +% Horizontal lines are inserted with \cs{hline} and vertical lines with +% \cs{vline}. These can be changed in color with +% \lstinline!\arrayrulecolor{red}\hline! and \lstinline!\color{red}\vline!. +% This package provides the commands +% \DescribeMacro{\coloredhline}\cs{coloredhline}\marg{color} and +% \DescribeMacro{\coloredvline}\cs{coloredvline}\marg{color} in order to +% generalise the setting of line colors. +% The code listing~\ref{code:coloredlines} shows an example of their usage. +% Note that this example uses tabularx and makes use of the new columnstyle +% `C'. +% +% \iffalse +%<*example> +% \fi + +\begin{lstlisting}[style=lstDemoStyleLaTeXCode , captionpos=b,caption={disabled alternating row colors.}, label={code:coloredlines}] +\colorlet{grayline}{gray!70} +\definecolor{blueline}{rgb}{0,0.27,0.55} + +\begin{table} +\tablestyle + % Overwriting style, instead of defining a new one + \renewcommand{\tbegin}{\coloredhline{blueline}} + \renewcommand{\tbody}{\coloredhline{blueline}} + \renewcommand{\tend}{\coloredhline{blueline}} +\begin{tabularx}{0.8\textwidth}{% +l!{\coloredvline{grayline}} +CC!{\coloredvline{grayline}} +CC!{\coloredvline{grayline}} +C +} +\theadstart +\thead header & +\multicolumn{2}{>{\columncolor{\tablecolor{head}}\thead} + c!{\coloredvline{grayline}}}{header} & +\multicolumn{2}{>{\columncolor{\tablecolor{head}}\thead} + c!{\coloredvline{grayline}}}{header} & +\multicolumn{1}{>{\columncolor{\tablecolor{head}}\thead}c} + {header} +% +\tabularnewline +\tbody +% +description & 0,3 & 0,35 & 0,5 & 0,65 & 0,80 \\ +description & 0,3 & 0,35 & 0,5 & 0,65 & 0,80 \\ +description & 0,3 & 0,35 & 0,5 & 0,65 & 0,80 \\ +description & 0,3 & 0,35 & 0,5 & 0,65 & 0,80 \\ +\tend +\end{tabularx} +\end{table} +\end{lstlisting} + +\colorlet{grayline}{gray!70} +\definecolor{blueline}{rgb}{0,0.27,0.55} + +\begin{table}[H] +\tablestyle + \renewcommand{\tlinetop}{\coloredhline{blueline}} + \renewcommand{\tlinemid}{\coloredhline{blueline}} + \renewcommand{\tlinebottom}{\coloredhline{blueline}} +\begin{tabularx}{0.8\textwidth}{% +l!{\coloredvline{grayline}} +ZZ!{\coloredvline{grayline}} +ZZ!{\coloredvline{grayline}} +Z +} +\theadstart +header & +\multicolumn{2}{>{\columncolor{\tablecolor{head}}\thead}c +!{\coloredvline{grayline}}} +{header} & +\multicolumn{2}{>{\columncolor{\tablecolor{head}}\thead}c +!{\coloredvline{grayline}}} +{header} & +\multicolumn{1}{>{\columncolor{\tablecolor{head}}\thead}c} +{header} +% +\tabularnewline +\tbody +% +description & 0,3 & 0,35 & 0,5 & 0,65 & 0,80\\ +description & 0,3 & 0,35 & 0,5 & 0,65 & 0,80\\ +description & 0,3 & 0,35 & 0,5 & 0,65 & 0,80\\ +description & 0,3 & 0,35 & 0,5 & 0,65 & 0,80\\ +\tend +\end{tabularx} +\caption{table with colored vertical and horizontal lines} +\label{tab:coloredlines} +\end{table} + +% \iffalse +%</example> +% \fi +% +% \subsubsection{Table styles} +% +% Complete styles are applied using +% \DescribeMacro{\tablestyle}\cs{tablestyle}\oarg{style name} +% and defined with \DescribeMacro{\setuptablestyle}\cs{setuptablestyle} +% \marg{style name}\marg{style definition}. If no argument is given for the +% command \cs{tablestyle} the style with name \emph{default} is used. +% Within the definition of styles the command \DescribeMacro{\resettablestyle} +% \cs{resettablestyle} has a special meaning. Its purpose is to reset a style +% before the actual style definitions are applied. Any change to this command +% has thus an influence to all styles using this command. +% +% The default style for example is defined by the code +% listing~\ref{code:setupdefaultstyle}. +% It sets up font sizes for body and head (used in \cs{head} and +% \cs{subhead}), defines the font style using the sans serif font family, +% redefines the \cs{arraystretch} and introduces alternating row colors with +% \cs{tablealtcolored}. +% \iffalse +%<*example> +% \fi + +\begin{lstlisting}[style=lstDemoStyleLaTeXCode , captionpos=b,caption={definition of the default style.}, label={code:setupdefaultstyle}] + \setuptablestyle{default}{% + \resettablestyle + \renewcommand{\arraystretch}{1.4} + \centering + \sffamily + \upshape% + \tablefontsize{body} + \tablealtcolored% + \renewcommand{\thead}{% +\tablefontsize{head}% +\ignorespaces% + } + \renewcommand{\tsubhead}{% +\tablefontsize{head}% +\ignorespaces% + } +} +\end{lstlisting} + +% \iffalse +%</example> +% \fi +% +% The package defines the styles +% \begin{itemize}[noitemsep] +% \item default (sans serif fonts, alternating row colors, +% header with gray background color) +% \item roman (as default style, but with roman fonts) +% \item sansbold (as default style, but with bold heading font) +% \item sansboldbw (as sansbold style, but with darker heading background) +% \end{itemize} +% +% These styles are demonstrated by the following tables +% \ref{tab:style:default} - \ref{tab:style:sansboldbw}. +% +% \iffalse +%<*example> +% \fi + +\begin{table}[H] +% +\tablestyle[default] +% +\begin{tabular}{*{2}{p{0.45\textwidth}}} +\theadstart + \thead header & + \thead header \\ +\tbody + % + content & content \\ + content & content \\ + content & content \\ + % + \tsubheadstart + \tsubhead subhead & + \tsubhead subhead \\ + % + content & content \\ + content & content \\ + \tend +\end{tabular} +\caption{default style} +\label{tab:style:default} +\end{table} + +\begin{table}[H] +% +\tablestyle[roman] +% +\begin{tabular}{*{2}{p{0.45\textwidth}}} +\theadstart + \thead header & + \thead header \\ +\tbody + % + content & content \\ + content & content \\ + content & content \\ + % + \tsubheadstart + \tsubhead subhead & + \tsubhead subhead \\ + % + content & content \\ + content & content \\ + \tend +\end{tabular} +\caption{roman style} +\label{tab:style:roman} +\end{table} + +\begin{table}[H] +% +\tablestyle[sansbold] +% +\begin{tabular}{*{2}{p{0.45\textwidth}}} +\theadstart + \thead header & + \thead header \\ +\tbody + % + content & content \\ + content & content \\ + content & content \\ + % + \tsubheadstart + \tsubhead subhead & + \tsubhead subhead \\ + % + content & content \\ + content & content \\ + \tend +\end{tabular} +\caption{sansbold style} +\label{tab:style:sansbold} +\end{table} + +\begin{table}[H] +% +\tablestyle[sansboldbw] +% +\begin{tabular}{*{2}{p{0.45\textwidth}}} +\theadstart% +\thead header & +\thead header \\ +\tbody + % + content & content \\ + content & content \\ + content & content \\ + % + \tsubheadstart + \tsubhead subhead & + \tsubhead subhead \\ + % + content & content \\ + content & content \\ + \tend +\end{tabular} +\caption{sansboldbw style} +\label{tab:style:sansboldbw} +\end{table} + +% \iffalse +%</example> +% \fi +% +% \subsection{Column type definitions} +% \DescribeMacro{l}\DescribeMacro{c}\DescribeMacro{r}\DescribeMacro{p} +% \LaTeX{} defines itself only the columntypes left (l), right(c) and center +% (c). Unfortunatley these do not automatically wrap text in cells. +% even if the text overrungs the width of the page. For fixed width columns +% this can be solved using the p-columntype. These default +% columntypes are shown in listing~\ref{code:ct:default} and table +% \ref{tab:ct:standard}. However a combination of paragraph like columns and +% non-justified alignment requires the definition of new column types, which +% are shown hereafter. +% +% \iffalse +%<*example> +% \fi + +\begin{lstlisting}[style=lstDemoStyleLaTeXCode , captionpos=b,caption={example of default column types.}, label={code:ct:default}] +\begin{table} +\tablestyle +% +\begin{tabular}{|l|c|r|p{0.3\linewidth}|} +\theadstart + \thead \centering header l & + \thead \centering header c & + \thead \centering header r & + \thead \centering header p \tabularnewline +\tbody +% +left & center & right & +text which is considerably longer than the width of the column \\ +\tend +\end{tabular} +\caption{standard column types (lcrp)} +\end{table} +\end{lstlisting} + +% \iffalse +%</example> +% \fi +% +% \begin{table}[H] +% \tablestyle +% \begin{tabular}{|l|c|r|p{0.3\linewidth}|} +% \theadstart +% \thead \centering header l & +% \thead \centering header c & +% \thead \centering header r & +% \thead \centering header p \tabularnewline +% \tbody +% left & center & right & +% text which is considerably longer than the width of the column \\ +% \tend +% \end{tabular} +% \caption{standard column types (lcrp)} +% \label{tab:ct:standard} +% \end{table} +% +% \DescribeMacro{m}\DescribeMacro{b} +% The array package provides further the column types middle (m) and bottom +% (b), which act like the p-type, but provide a different vertical alignment +% as demonstrated in listing~\ref{code:ct:pmb} and table \ref{tab:ct:pmb}. +% +% \iffalse +%<*example> +% \fi + +\begin{lstlisting}[style=lstDemoStyleLaTeXCode , captionpos=b,caption={example of paragraph column types.}, label={code:ct:pmb}] +\begin{table} +\tablestyle +% +\begin{tabular}{|p{0.3\linewidth}|m{0.3\linewidth}|b{0.3\linewidth}|} +\theadstart + \thead \centering header p & + \thead \centering header m & + \thead \centering header b \tabularnewline +\tbody +% +text which is considerably longer than the width of the column & +text which is considerably longer than the width of the column & +text which is considerably longer than the width of the column \\ +\tend +\end{tabular} +\caption{column types (pmb)} +\end{table} +\end{lstlisting} + +% \iffalse +%</example> +% \fi +% +% \begin{table}[H] +% \tablestyle +% \begin{tabular}{|p{0.3\linewidth}|m{0.3\linewidth}|b{0.3\linewidth}|} +% \theadstart +% \thead \centering header p & +% \thead \centering header m & +% \thead \centering header b \tabularnewline +% \tbody +% % +% text which is considerably longer than the width of the column & +% text which is considerably longer than the width of the column & +% text which is considerably longer than the width of the column \\ +% \tend +% \end{tabular} +% \caption{column types (pmb)} +% \label{tab:ct:pmb} +% \end{table} +% +% \DescribeMacro{X}\DescribeMacro{Z}\DescribeMacro{Y} +% The tabularx-package provides a further column type (X), which uses +% automatically calculated column width. +% This package defines additional column types bases on X for centered (Z) and +% right (Y) aligned columns, shown +% table~\ref{tab:ct:XCY}, which is using the column definition: +% +% \iffalse +%<*example> +% \fi + +\begin{lstlisting}[style=lstDemoStyleLaTeXCode , captionpos=b,caption={example of tabularx type columns.}, label={code:ct:XZY}] +\begin{table} +\tablestyle +\begin{tabularx}{\textwidth}{|X|Z|Y|} +... +\end{lstlisting} + +% \iffalse +%</example> +% \fi +% +% \begin{table}[H] +% \tablestyle +% \begin{tabularx}{\textwidth}{|X|Z|Y|} +% \theadstart +% \thead \centering header X & +% \thead \centering header Z & +% \thead \centering header Y \tabularnewline +% \tbody +% text which is considerably longer than the width of the column & +% text which is considerably longer than the width of the column & +% text which is considerably longer than the width of the column \\ +% \tend +% \end{tabularx} +% \caption{column types (XZY)} +% \label{tab:ct:XZY} +% \end{table} +% +% +% \DescribeMacro{L}\DescribeMacro{C}\DescribeMacro{R} +% Furthermore, this package provides additional column types with fixed with +% and left (L), centered (C) and right (R) aligned column, each derived from +% the p-columntype. In the example (table~\ref{tab:ct:LZR}) the advantage of +% using ragged text alignment (L) in tables over the justified alignment (p) +% is clearly visible. +% +% \begin{table}[H] +% \tablestyle +% \begin{tabularx}{\textwidth}{|p{0.17\linewidth}|L{0.17\linewidth}|C{0.17\linewidth}|R{0.17\linewidth}|X|} +% \theadstart +% \thead \centering header p & +% \thead \centering header L & +% \thead \centering header C & +% \thead \centering header R & +% \thead \centering header X \tabularnewline +% \tbody +% text which is considerably longer than the width of the column & +% text which is considerably longer than the width of the column & +% text which is considerably longer than the width of the column & +% text which is considerably longer than the width of the column & +% text which is considerably longer than the width of the column \\ +% \tend +% \end{tabularx} +% \caption{column types (LCR)} +% \label{tab:ct:LCR} +% \end{table} +% +% The column definition for table~\ref{tab:ct:LCR} is shown in +% listing~\ref{code:ct:LCR}: +% +% \iffalse +%<*example> +% \fi + +\begin{lstlisting}[style=lstDemoStyleLaTeXCode , captionpos=b,caption={example of new p-type columns.}, label={code:ct:LCR}] +\begin{table} +\tablestyle +\begin{tabularx}{\textwidth}{|p{0.17\linewidth}|L{0.17\linewidth}|C{0.17\linewidth}|R{0.17\linewidth}|X|} +... +\end{lstlisting} + +% \iffalse +%</example> +% \fi +% +% Further column definitions can be defined similar to the definitions used +% here. The implementation is demonstrated in +% section~\ref{sec:impl:columntypes}. +% +% \subsection{Items in tables} +% +% +% Itemized, enumerated or other list typically introduce a horizontal +% indentation which should not appear within a tabular environment. Therefore +% the command \DescribeMacro{\tableitemize}\cs{tableitemize} is introduced +% to remove the indentation. +% +% +% \begin{table}[H] +% \tablestyle +% \begin{tabularx}{1\textwidth}{|X|X|X|} +% \theadstart +% \thead \centering header X & +% \thead \centering header items (X) & +% \thead \centering header enums (X) \tabularnewline +% \tbody +% The \LaTeX{} document preparation system is a special version of Donald +% Knuth's \TeX{} program. \TeX{} is a sophisticated program designed to +% produce high-quality typesetting, especially for mathematical text. +% & +% \tableitemize +% \begin{itemize} +% \item The \LaTeX{} document preparation system is a special version of Donald +% Knuth's \TeX{} program. +% \item \TeX{} is a sophisticated program designed to produce high-quality typesetting, +% \item especially for mathematical text. +% \end{itemize} +% & +% \tableitemize +% \begin{enumerate} +% \item The \LaTeX{} document preparation system is a special version of Donald +% Knuth's \TeX{} program. +% \item \TeX{} is a sophisticated program designed to produce high-quality typesetting, +% \item especially for mathematical text. +% \end{enumerate} +% \tabularnewline +% \tend +% \end{tabularx} +% \caption{table item list using \texttt{tableitemize}} +% \label{tab:tableitemize} +%\end{table} +% +% In table~\ref{tab:tableitemize} this is realized by inserting the command +% \cs{tableitemize} directly before the beginning of a list, +% as shown in listing~\ref{code:tableitemize}. +% +% \iffalse +%<*example> +% \fi + +\begin{lstlisting}[style=lstDemoStyleLaTeXCode , captionpos=b,caption={example of tableitemize.}, label={code:tableitemize}] +... +The ... +& +\tableitemize % <--- +\begin{itemize} +\item The ... +\item \TeX{} is a ... +\item especially ... +\end{itemize} +& +\tableitemize % <--- +\begin{enumerate} +\item The ... +\item \TeX{} is a ... +\item especially ... +\end{enumerate} +\tabularnewline +... +\end{lstlisting} + +% \iffalse +%</example> +% \fi +% +% \StopEventually{} +% \clearpage +% \section{Implementation} +% +% \iffalse +%<*tablestyles.sty> +% \fi +% +% \subsection{Setup and packages} +% +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e}[1994/12/01] +\ProvidesPackage{tablestyles} + [2011/10/01 v0.1 tablestyles] +% \end{macrocode} +% +% The following packages are loaded by this package. array is required for +% most of the tables anyway, xcolor with the option `table' is required for +% the color definitions (table loads colortbl for all commands of colors in +% tables. ragged2e is used for the new columntypes and etoolbox for the +% implementation of the code. +% +% \begin{macrocode} +\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 +% \end{macrocode} +% +% \subsection{Configuration commands} +% +% The heart of this package is the definition of the table styles, which are +% very simply only saved as a command sequence. +% An error are printed out if a style is requested, which has not been defined +% before. +% +% \begin{macro}{\setuptablestyle} +% \begin{macrocode} +%% 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} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\tablestyle} +% \begin{macrocode} +%% 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} +} +% \end{macrocode} +% \end{macro} +% +% Font sizes are save in a special command sequence, so that they can be +% reused, and identified using their names: +% +% \begin{macro}{\setuptablefontsize} +% \begin{macrocode} +%% save font size with name +\newcommand{\setuptablefontsize}[2]{ + \csdef{tsty@font@#1@size}{#2} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\tablefontsize} +% \begin{macrocode} +%% 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% + }{}% + }% +}% +% \end{macrocode} +% +% The default values for the predefined sizes \emph{body} and \emph{head} are +% set to \cs{small} since tables should +% always be printed slightly smaller than the normal text. +% +% \begin{macrocode} +%% define default font sizes +\setuptablefontsize{body}{\small} +\setuptablefontsize{head}{\small} +% \end{macrocode} +% \end{macro} +% +% The definition of colors is almost identical to the definition of font +% sizes. This definition is restricted to the xcolor way of defining colors. +% +% \begin{macro}{\setuptablecolor} +% \begin{macrocode} +%% save color with name +\newcommand{\setuptablecolor}[2]{% + \colorlet{tsty@color@#1}{#2}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\tablecolor} +% \begin{macrocode} +%% apply colorwith name +\newcommand{\tablecolor}[1]{tsty@color@#1} +% \end{macrocode} +% \end{macro} +% +% The default colors are defined as +% +% \begin{macro}{\tsty@defaultcolors} +% \begin{macrocode} +%% default colors +\newcommand{\tsty@defaultcolors}{ + \setuptablecolor{body}{white!100} + \setuptablecolor{row}{gray!10} + \setuptablecolor{head}{gray!25} + \setuptablecolor{subhead}{gray!30} +} +% \end{macrocode} +% \end{macro} +% +% and exectuted afterwards. +% +% \begin{macrocode} +%% exectuted default colors +\tsty@defaultcolors +% \end{macrocode} +% +% Alternating row colors are simplified with the command \cs{tablealtcolored}, +% which reuses the \cs{rowcolors} and the table color definitions for +% \emph{row} and \emph{body}. +% +% \begin{macro}{\tablealtcolored} +% \begin{macrocode} +%% shortcut for alternating rowcolors +\newcommand\tablealtcolored{% + \rowcolors{1}{\tablecolor{row}}{\tablecolor{body}}% +} +% \end{macrocode} +% \end{macro} +% +% The alternating rows are disabled by changing the row color identical to the +% body color. Since every tablestyle should load \cs{tsty@defaultcolors} this +% is reset at every applied tablestyle. +% +% \begin{macro}{\disablealternatecolors} +% \begin{macrocode} +%% disable alternating rowcolors by changing the colors +\newcommand{\disablealternatecolors}{% + \setuptablecolor{row}{\tablecolor{body}}% +} +% \end{macrocode} +% \end{macro} +% +% The \cs{coloredhline} uses the \cs{arrayrulecolor} of the colortlb-package. +% +% \begin{macro}{\coloredhline} +% \begin{macrocode} +%% colored horizontal lines (hlines) +\providecommand{\coloredhline}[1]{% + \arrayrulecolor{#1}\hline + \arrayrulecolor{black} +}% +% \end{macrocode} +% \end{macro} +% +% The \cs{coloredvline} applies the color to the \cs{vline} with a standard +% \cs{color} command. +% +% \begin{macro}{\coloredvline} +% \begin{macrocode} +%% colored vertical lines (vlines) +\providecommand{\coloredvline}[1]{% + \color{#1}\vline +}% +% \end{macrocode} +% \end{macro} +% \subsection{Style applying commands} +% +% The lines for the top (above the header), middle (below the header) and +% the bottom of the table (at the end) are defined with \cs{tlinetop}, +% \cs{tlinemid} and \cs{tlinebottom} +% +% \begin{macro}{\tlinetop} +% \begin{macrocode} +%% commands for the style of the lines +\newcommand{\tlinetop}{\coloredhline{black}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\tlinemid} +% \begin{macrocode} +\newcommand{\tlinemid}{\coloredhline{black}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\tlinebottom} +% \begin{macrocode} +\newcommand{\tlinebottom}{\coloredhline{black}} +% \end{macrocode} +% \end{macro} +% +% These are supposed to be inserted in the table with the commands +% \cs{tbegin}, % \cs{tbody} and % \cs{tend}, which prints out the last line +% and restores color, font and size. +% +% \begin{macro}{\tbegin} +% \begin{macrocode} +%% commands for the seperations (includes the lines) +\newcommand{\tbegin}{\tlinetop} +% \end{macrocode} +% \end{macro} +% \begin{macro}{tbody} +% \begin{macrocode} +\newcommand{\tbody}{\tlinemid} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\tend} +% \begin{macrocode} +\newcommand{\tend}{\tlinebottom} +% \end{macrocode} +% \end{macro} +% +% The predefined \cs{thead} includes only the +% font size. The same applies for \cs{tsubhead} +% \begin{macro}{\thead} +% \begin{macrocode} +%% default head style (only fontsize) +\newcommand\thead{% + \tablefontsize{head} +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\tsubhead} +% \begin{macrocode} +%% default subhead style (only fontsize) +\newcommand{\tsubhead}{% + \tablefontsize{head} +} +% \end{macrocode} +% \end{macro} +% +% Both head and subhead have a start and an end command. By default the start +% includes a hline and the rowcolor, whereas the end command does nothing. +% +% \begin{macro}{\theadstart} +% \begin{macrocode} +%% style of header start (line and row color) +\newcommand\theadstart{% + \tlinetop% + \rowcolor{\tablecolor{head}}% +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\theadend} +% \begin{macrocode} +%% style of header end - empty +\newcommand\theadend{} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\tsubheadstart} +% \begin{macrocode} +%% style of subheader start (row color) +\newcommand{\tsubheadstart}{% + \rowcolor{\tablecolor{subhead}} +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\tsubheadend} +% \begin{macrocode} +%% style of subheader end - empty +\newcommand\tsubheadend{} +% \end{macrocode} +% \end{macro} +% +% The commands \cs{theadrow} and the equivalent \cs{tsubheadrow} define a +% multicolumn row for the whole table width. +% It should be used to have a full width spanning header. This command +% includes the background color and the cell properties +% using \cs{thead} and \cs{tsubhead}. +% +% \begin{macro}{\theadrow} +% \begin{macrocode} +%% shortcut for multi column row in header +\newcommand{\theadrow}[2]{% + \multicolumn{#1}{>{\columncolor{\tablecolor{head}}}l}{% + \thead #2% + }% + \tabularnewline% +}% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\tsubheadrow} +% \begin{macrocode} +%% shortcut for multi column row in subheader +\newcommand{\tsubheadrow}[2]{% + \multicolumn{#1}{>{\columncolor{\tablecolor{subhead}}}l}{% + \tsubhead #2% + }% + \tabularnewline% +}% +% \end{macrocode} +% \end{macro} +% +% \subsection{Style definitions} +% +% The following \cs{resettablestyle} is meant to be used with in the +% definition of a table style. It resets most commands to a default value +% equivalent to what a table would look like without +% any style applied. New styles should be built on this basis. The content of +% this command can be changed. However it means that this changes are applied +% to all styles of this package. +% +% \begin{macro}{\resettablestyle} +% \begin{macrocode} +%% 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} +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{default} +% +% \begin{macrocode} +%% 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% + } +} +% \end{macrocode} +% +% \subsubsection{roman} +% This style differs from the default style only in the exchange of the +% \cs{sffamily} with \cs{rmfamily}. +% \begin{macrocode} +%% 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% + } +} +% \end{macrocode} +% +% \subsubsection{sansbold} +% This style differs from the default style in the inclusion of \cs{bfseries} +% in the heading commands. +% +% \begin{macrocode} +%% 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% + } +} +% \end{macrocode} +% +% \subsubsection{sansboldbw} +% This style differs from the sansbold style in exchange of the table colors +% with much darker heading colors +% and a white heading font, which is printed slanted. +% +% \begin{macrocode} +%% style: sansboldbw +\setuptablestyle{sansboldbw}{% + \resettablestyle + \setuptablecolor{body}{white!100} + \setuptablecolor{row}{gray!15} + \setuptablecolor{head}{black!60} + \setuptablecolor{subhead}{gray!40} +% \end{macrocode} +% +% \begin{macrocode} + \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% + } +} +% \end{macrocode} +% +% \subsection{Support for itemized lists in tables} +% +% \begin{macro}{\tsty@removeindentation} +% \begin{macrocode} +%% bugfix code for lists in tables +\newcommand{\tsty@removeindentation}{% + \leftmargini=\labelsep% + \advance\leftmargini by \labelsep% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\tableitemize} +% \begin{macrocode} +\newcommand\tableitemize{ + \@minipagetrue% + \tsty@removeindentation +} +% \end{macrocode} +% \end{macro} +% +% \subsection{New columntype definitions} +%\label{sec:impl:columntypes} +% +% The \cs{arraybackslash} is required to restore the definition of +% \lstinline!\\! after its redefinition. \cs{hspace}\{0pt\} is included to +% allow hyphenation also of the first word. +% +% New columntype definitions: +% +% \begin{macrocode} +%% 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}} +% \end{macrocode} +% +% +% \iffalse +%</tablestyles.sty> +% \fi +% +% \Finale +\endinput diff --git a/Master/texmf-dist/source/latex/tablestyles/tablestyles.ins b/Master/texmf-dist/source/latex/tablestyles/tablestyles.ins new file mode 100644 index 00000000000..b63aad40777 --- /dev/null +++ b/Master/texmf-dist/source/latex/tablestyles/tablestyles.ins @@ -0,0 +1,29 @@ +% See file 'tablestyles.dtx' for copyright and licence. +% +\input docstrip.tex +\keepsilent +\askforoverwritefalse + +\usedir{tex/latex/tablestyles} + +\generate{% + \file{tablestyles.sty}{\nopreamble\from{tablestyles.dtx}{tablestyles.sty}} +} + +\obeyspaces +\Msg{*************************************************************} +\Msg{* *} +\Msg{* To finish the installation you have to move the following *} +\Msg{* file into a directory searched by TeX: *} +\Msg{* *} +\Msg{* tablestyles.sty *} +\Msg{* *} +\Msg{* To produce the documentation run the file *} +\Msg{* tablestyles.dtx *} +\Msg{* through LaTeX. *} +\Msg{* *} +\Msg{* Happy TeXing! *} +\Msg{* *} +\Msg{*************************************************************} + +\endbatchfile 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'. |