summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/threeparttablex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/threeparttablex
Initial commit
Diffstat (limited to 'macros/latex/contrib/threeparttablex')
-rw-r--r--macros/latex/contrib/threeparttablex/README55
-rw-r--r--macros/latex/contrib/threeparttablex/threeparttablex.pdfbin0 -> 61880 bytes
-rw-r--r--macros/latex/contrib/threeparttablex/threeparttablex.sty164
-rw-r--r--macros/latex/contrib/threeparttablex/threeparttablex.tex265
4 files changed, 484 insertions, 0 deletions
diff --git a/macros/latex/contrib/threeparttablex/README b/macros/latex/contrib/threeparttablex/README
new file mode 100644
index 0000000000..fd2c2e4693
--- /dev/null
+++ b/macros/latex/contrib/threeparttablex/README
@@ -0,0 +1,55 @@
+% (C) Lars Madsen, daleif@imf.au.dk, 2013/07/23
+% This material is subject to the LaTeX Project Public License.
+% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html
+% for the details of that license.
+
+This small package brings tablenotes to longtable, though using a
+slightly different syntax.
+
+By default it does not change anything in theeparttable.
+
+If asked for (using the referable package option), we change some
+threeparttable internals such that table notes are referable, i.e.
+
+\item[a] \label{tn:a} some text
+
+then \ref{tn:a} gives you an 'a' (without any formatting). Instead of
+manually keeping track of all the \tnote arguments in the table you
+can now do \tnotex{tn:a} to get \tnote{\ref{tn:a}}.
+
+For information on how to use threeparttable with longtable see the manual.
+
+
+* v0.3
+ Bug fix, \roman -> \romannumeral
+
+* v0.25
+ Sporadic space removed
+
+* v0.2
+ Bug fixes regarding threeparttable options
+
+* v0.1
+ Bug fix, width of table notes inserted into longtable
+ might get the wrong width
+
+* v0.08
+ re-Added support for \note and \source when loading the referable option,
+ for example of use, see the manual
+
+ They got lost in the last update (someone forgot to commit them to his
+ subversion repository)
+
+* v0.06
+ Made \tnotex robust
+
+* v0.04
+ Added \setTableNoteFont
+
+* v0.03
+ First public release.
+
+
+
+
+/daleif
diff --git a/macros/latex/contrib/threeparttablex/threeparttablex.pdf b/macros/latex/contrib/threeparttablex/threeparttablex.pdf
new file mode 100644
index 0000000000..34fb54e67f
--- /dev/null
+++ b/macros/latex/contrib/threeparttablex/threeparttablex.pdf
Binary files differ
diff --git a/macros/latex/contrib/threeparttablex/threeparttablex.sty b/macros/latex/contrib/threeparttablex/threeparttablex.sty
new file mode 100644
index 0000000000..b186a9f68b
--- /dev/null
+++ b/macros/latex/contrib/threeparttablex/threeparttablex.sty
@@ -0,0 +1,164 @@
+\ProvidesPackage{threeparttablex}[2013/07/23 v0.3 by daleif]
+
+%%
+%% This package can 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 2003/12/01 or later.
+%%
+%% This work has the LPPL maintenance status "maintained".
+%%
+%% The Current Maintainer of this work is Lars Madsen (daleif@imf.au.dk).
+%%
+
+
+\newif\ifTPTL@referable
+\DeclareOption{referable}{\TPTL@referabletrue}
+\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{threeparttable}}
+
+\ProcessOptions\relax
+
+\RequirePackage{threeparttable}
+\RequirePackage{environ}
+
+
+\newcommand\TPTL@font{}
+\newcommand\setTableNoteFont[1]{\renewcommand\TPTL@font{#1}}
+
+% length to store the longtable width in
+\newlength\TPTL@width
+% macro to store the optional argument for tablenotes
+\def\TPTL@optarg{}
+% wrapper env used to collect the tablenotes for later use
+\newenvironment{TableNotes}[1][]{
+ \gdef\TPTL@optarg{#1}%
+ \Collect@Body\TPTL@collector}{}
+\newcommand\TPTL@collector[1]{%
+ \long\gdef\TPTL@body{#1}}
+% the macro used to store the tablenotes contents
+\gdef\TPTL@body{}
+\newcommand\insertTableNotes{%
+ % first we need to know the width of the longtable, remember that it
+ % will only settle after a few compilations
+ \noalign{\begingroup
+ \setlength\TPTL@width{0pt}
+ \renewcommand\LT@entry[2]{\global\advance\TPTL@width by ##2}
+ \@nameuse{LT@\romannumeral\c@LT@tables}
+ \ifdim\TPTL@width<\TPTminimum\relax\global\TPTL@width=\TPTminimum\fi
+ \endgroup}
+ % then add the table notes inside a \parbox of the required width
+ \multicolumn{\LT@cols}{c}{%
+ \makebox[0pt][c]{%
+ \parbox{\TPTL@width}{%
+ \let\TPT@hsize\@empty% otherwise the width is not reset
+ % correctly as \TPT@hsize messes with
+ % \@parboxrestore
+ \let\TPToverlap\relax%
+ \begin{tablenotes}[\TPTL@optarg]%
+ \TPTL@font%
+ \TPTL@body
+ \end{tablenotes}
+ }%
+ }%
+ }%
+}
+
+% the alternative threeparttable env, it only enables \TPToverlap
+\newenvironment{ThreePartTable}{\let\TPToverlap\TPTrlap}{}
+
+
+
+\ifTPTL@referable\else\endinput\fi
+
+% we only come here if we need to make tablenotes referable
+
+
+% define an extra \tnote command that table a label instead of a string
+\DeclareRobustCommand\tnotex{\@ifstar{\TPTL@tnotex{01}}{\TPTL@tnotex{00}}}
+
+\newcommand\TPTL@tnotex[2]{\tnote{\ref{#2}}}
+
+% if hyperref is loaded we activate a starred version
+\AtBeginDocument{%
+ \@ifpackageloaded{hyperref}{%
+ \renewcommand\TPTL@tnotex[2]{%
+ \if#1\relax%
+ \tnote{\ref{#2}}%
+ \else%
+ \tnote{\ref*{#2}}%
+ \fi}}{}}
+
+
+\newcommand\TPTL@generator[2]{%
+ \providecommand{#1}{}% just to make it exist
+ \renewcommand#1[1][#2]{%
+ \let\TPTL@oldmakelabel=\makelabel%
+ \renewcommand\makelabel[1]{\TPTLnotesnamefontcommand{##1:}}%
+ \item%
+ \let\makelabel=\TPTL@oldmakelabel}}
+
+\newcommand\TPTL@generator@para[2]{%
+ \providecommand{#1}{}% just to make it exist
+ \renewcommand#1[1][#2]{%
+ \TPTLnotesnamefontcommand{##1: }%
+ }}
+
+
+\providecommand\TPTLnotename{Note}
+\providecommand\TPTLsourcename{Source}
+\providecommand\TPTLnotesnamefontcommand{\textit}
+
+
+
+\let\TPTL@tablenotes=\tablenotes
+
+% \makelabel (i.e. \item) hides its argument inside a group, making it
+% difficult to set \@currentlabel, so we locally overload \item to get
+% the argument and set \@currentlabel AFTER \item[...]
+
+
+\renewcommand\tablenotes{%
+ \let\TPTL@item=\item
+ \renewcommand\item[1][]{\TPTL@item[##1]%
+ \phantomsection\protected@edef\@currentlabel{##1}}
+ \TPTL@generator\note{\TPTLnotename}
+ \TPTL@generator\source{\TPTLsourcename}
+ \TPTL@font\TPTL@tablenotes}
+
+
+% this is a copy from threeparttable, since adding to it failed
+\def\TPT@doparanotes{\par
+ \prevdepth\z@ \TPT@hsize
+ \TPTnoteSettings
+ \parindent\z@ \pretolerance 8
+ \linepenalty 200
+ \renewcommand\item[1][]{\relax\ifhmode \begingroup
+ \unskip
+ \advance\hsize 10em % \hsize is scratch register, based on real hsize
+ \penalty -45 \hskip\z@\@plus\hsize \penalty-19
+ \hskip .15\hsize \penalty 9999 \hskip-.15\hsize
+ \hskip .01\hsize\@plus-\hsize\@minus.01\hsize
+ \hskip 1em\@plus .3em
+ \endgroup\fi
+ \tnote{##1}%
+ \phantomsection\protected@edef\@currentlabel{##1}%
+ \,\ignorespaces}%
+ \let\TPToverlap\relax%
+ \TPTL@generator@para\note{\TPTLnotename}%
+ \TPTL@generator@para\source{\TPTLsourcename}%
+ \TPTL@font%
+ \def\endtablenotes{\par}%
+ }
+
+
+
+% just in case it is not already there
+\providecommand\phantomsection{}
+
+
+\endinput
+
+The End
diff --git a/macros/latex/contrib/threeparttablex/threeparttablex.tex b/macros/latex/contrib/threeparttablex/threeparttablex.tex
new file mode 100644
index 0000000000..7005d710ca
--- /dev/null
+++ b/macros/latex/contrib/threeparttablex/threeparttablex.tex
@@ -0,0 +1,265 @@
+\documentclass[a4paper,article]{memoir}
+\usepackage[T1]{fontenc}
+%\usepackage[garamond]{mathdesign}
+
+\usepackage{bera}
+
+\setsecnumdepth{part}
+\pagestyle{plain}
+
+\usepackage{xspace,listings,xcolor}
+\newcommand\pkg{\jobname\xspace}
+
+\newcommand\env[1]{\texttt{#1}}
+
+\newcommand\tpt{threeparttable\xspace}
+
+\definecolor{felinesrcbgcolor}{rgb}{1,1,0.85}
+\definecolor{austdblue}{cmyk}{1,0.8,0,0.15}
+\definecolor{nicered}{rgb}{.647,.129,.149}
+\lstset{
+ basicstyle=\ttfamily\footnotesize,
+ columns=fixed,
+ backgroundcolor=\color{felinesrcbgcolor},
+ frame=single,
+ extendedchars=true,
+ framexleftmargin=3pt,
+ numbers=none,
+ numberstyle=\tiny\ttfamily,
+ escapeinside={X}{X},
+}
+
+\usepackage[referable]{threeparttablex}
+\usepackage{longtable}
+
+\usepackage{hyperref}
+
+\begin{document}
+
+\title{A small extension to threeparttable \\ -- or bringing
+ threeparttable to longtable}
+
+\author{Lars Madsen\thanks{Email: daleif@imf.au.dk}}
+
+\date{Corresponding to version 0.3, manual updated \today}
+
+\maketitle
+
+\section{Introduction}
+\label{sec:introduction}
+
+Because of the measuring nature of the original \tpt
+environment, one cannot use it in combination with the longtable
+environment. This package makes up for this and brings \tpt
+to longtable, at the small cost of having to do things a little
+different when adding table notes to longtable.
+
+If asked for it, the pacakge will also enable the user to label and
+refer to table notes.
+
+
+\section{Prerequisites}
+\label{sec:prerequisites}
+
+The \pkg package requires the \tpt and environ packages to
+be available on your system.
+
+\section{Basic usage}
+\label{sec:basic-usage}
+
+The interface for the regular \tpt system has not changed. We add the
+following:
+\begin{description}
+\item[ThreePartTable] a very simple wrapper environment that should
+ wrap around the entire longtable. (It actually does nothing else but
+ enable the \cs{tnote} command).
+\item[TableNotes] an environment taking the same options as the normal
+ table\-notes environment, write the table notes in this environment.
+ It needs to be placed \emph{before} the longtable. It \emph{cannot}
+ be added inside longtable.
+\item[\cs{insertTableNotes}] use this macro to insert the table notes
+ inside the longtable. It is inserted via a special
+ \cs{multicolumn}. If you add stuff after the table notes, e.g.\ a
+ caption, you should remember to use \verb+\insertTableNotes\\+.
+\end{description}
+
+\noindent A longtable example could look like this:
+\begin{lstlisting}
+\begin{ThreePartTable}
+ \begin{TableNotes}
+ \item[a] A note
+ \item[b] Another note
+ \end{TableNotes}
+ \begin{longtable}{l l}
+ \toprule
+ Column 1 & Column 2 \\
+ \midrule
+ \endhead
+ \cmidrule{2-2}
+ \multicolumn{2}{r}{\textit{continued}}
+ \endfoot
+ \bottomrule
+ \insertTableNotes
+ \endlastfoot
+
+ % the contents of the table
+ A & B\tnote{a} \\
+ C\tnote{b} & D \\
+ \end{longtable}
+\end{ThreePartTable}
+\end{lstlisting}
+
+\paragraph{Caveat:} As mentioned on
+\url{http://tex.stackexchange.com/q/149032/3929}, if you use \cs{fill}
+to spread out the columns in the table, the width \env{longtable}
+reports back (which we use to specify the width of the notes) will be
+wrong. It will be the natural width of the table not the actual
+width. The result is that the area for the notes will have the wrong
+width. A remedy is to tell it to use the full width, something similar
+to
+\begin{lstlisting}
+\begin{ThreePartTable}
+ \renewcommand\TPTminimum{\textwidth} %%% we want full width
+ ...
+\end{lstlisting}
+will do.
+
+
+\section{Extending \tpt}
+\label{sec:extending-tpt}
+
+One thing missing in \tpt is the ability to refer to
+individual table notes. And even let \cs{tnote} pickup the note
+marker via a label (reducing the error-40 factor).
+
+By using the package option >>\texttt{referable}<< we will change a
+few \tpt internals such that
+\begin{enumerate}[(a)]
+\item The manually specified note markers issued by \verb+\item[...]+
+ is referable, and
+\item \cs{tnotex}\marg{label} will refer to the table note identified
+ by \meta{label}. (We do not want to change \cs{tnote}). In case you
+ are using hyperref, there is also a \cs{tnotex*} that does not make
+ the tnote into a hyperlink.
+\item \cs{setTableNoteFont}\marg{font commands} can be used to set the
+ font inside tables notes. (default is empty)
+\item inside the \emph{tablenotes} environment, the macros \cs{note}
+ and \cs{source} can be used to specify general notes and a source
+ reference for the table data. These are commonly used within the
+ examples in The Chicago Manual of Style.
+\item The macros \cs{TPTLnotename} \cs{TPTLsourcename} holds the title
+ names for \cs{note} and \cs{source} (default: >>Note<< and
+ >>Source<<). Both are typeset using \cs{TPTLnotesnamefontcommand}
+ which deaults to \cs{textit}.
+\end{enumerate}
+
+\section{Example}
+\label{sec:example}
+
+\begin{lstlisting}
+\begin{ThreePartTable}
+ \begin{TableNotes}
+ \item[a] \label{tn:a} test test test test test test test test
+ \item[b] \label{tn:b} test2
+ \source Made up by daleif
+ \end{TableNotes}
+
+\begin{longtable}{l l l}
+ \caption{A long table}\\
+ \toprule
+ Coloum 1 & & Column 2 \\
+ \midrule
+ \endhead
+ \cmidrule{3-3}
+ \multicolumn{3}{r}{\textit{continued}}
+ \endfoot
+ \bottomrule
+ \insertTableNotes\\
+ \endlastfoot
+ AAAA\tnotex{tn:a} & XXXXXXXX & BBBB \\
+% \newpage
+ CC & & DD\tnotex{tn:b} \\
+\end{longtable}
+\end{ThreePartTable}
+
+
+\begin{center}
+ \begin{threeparttable}
+ \caption{A regular tabular}
+ \begin{tabular}{l l l}
+ \toprule
+ Coloum 1 & & Column 2 \\
+ \midrule
+ AAAA\tnote{c} & XXXXXXXX & BBBB \\
+ CC & & DD\tnotex*{tn:c} \\
+ \bottomrule
+ \end{tabular}
+ \begin{tablenotes}
+ \footnotesize
+ \item[c] test test test test test test test test
+ \item[d] \label{tn:c} the reference to this is not a link
+ \note Some general note
+ \end{tablenotes}
+ \end{threeparttable}
+\end{center}
+\end{lstlisting}
+
+\newpage
+
+\noindent Resulting in:
+
+\begin{ThreePartTable}
+ \begin{TableNotes}
+ \item[a] \label{tn:a} test test test test test test test test
+ \item[b] \label{tn:b} test2
+ \source Made up by daleif
+ \end{TableNotes}
+
+\begin{longtable}{l l l}
+ \caption{A long table}\\
+ \toprule
+ Coloum 1 & & Column 2 \\
+ \midrule
+ \endhead
+ \cmidrule{3-3}
+ \multicolumn{3}{r}{\textit{continued}}
+ \endfoot
+ \bottomrule
+ \insertTableNotes\\
+ \endlastfoot
+ AAAA\tnotex{tn:a} & XXXXXXXX & BBBB \\
+% \newpage
+ CC & & DD\tnotex{tn:b} \\
+\end{longtable}
+\end{ThreePartTable}
+
+
+\begin{center}
+ \begin{threeparttable}
+ \caption{A regular tabular}
+ \begin{tabular}{l l l}
+ \toprule
+ Coloum 1 & & Column 2 \\
+ \midrule
+ AAAA\tnote{c} & XXXXXXXX & BBBB \\
+ CC & & DD\tnotex*{tn:c} \\
+ \bottomrule
+ \end{tabular}
+ \begin{tablenotes}
+ \footnotesize
+ \item[c] test test test test test test test test
+ \item[d] \label{tn:c} the reference to this is not a link
+ \note Some general note
+ \end{tablenotes}
+ \end{threeparttable}
+\end{center}
+
+
+
+
+\end{document}
+
+%%% Local Variables:
+%%% mode: latex
+%%% TeX-master: t
+%%% End: