blob: 314f513b659ee4e3e54b854426a2f87af75d68df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
%%
%% This is file `widetable.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% widetable.dtx (with options: `package')
%% ______________________________________________________
%% The WIDETABLE bundle
%% Copyright (C) 2009-2018 Claudio Beccari
%% All rights reserved
%%
%% License information appended
%%
\ProvidesPackage{widetable}%
[2018-12-14 v.1.5 Package for typesetting specified width tables]
\NeedsTeXFormat{LaTeX2e}[2018/01/01]
\AtBeginDocument{%
\@ifpackageloaded{array}{}{\RequirePackage{array}}%
}
\dimendef\wt@Numer=2
\dimendef\wt@Denom=4
\countdef\wt@Num=2
\countdef\wt@Den=4
\RequirePackage{xparse}
\newcommand\WT@scale[4]{\begingroup
\wt@Num #2\relax \wt@Den #3\relax
\ifnum#3=\z@
\@tempdima\ifnum#2<0-\fi\maxdimen
\else
\@tempdima\dimexpr#1*#2/#3\relax
\fi
\edef\x{\noexpand\endgroup\noexpand\setlength{#4}{\the\@tempdima}}%
\x}
\newdimen\wt@width
\newif\ifwt@scartare\wt@scartarefalse
\DeclareDocumentCommand\widetable{m O{c} m}
{% OPENING WIDETABLE
\def\@tempC{widetable}%
\setlength{\wt@width}{#1}%
\def\wt@preamble{#3}%
\def\wt@starttabular{\tabular[#2]{#3}}%
\wt@getTable}%
\def\endwidetable{% CLOSING WIDETABLE
\ifwt@scartare
\noindent\null
\else
\tabcolsep=\z@
\setbox\z@=\hbox{\wt@starttabular\the\toks@\endtabular}%
\tabcolsep=6pt\relax
\setbox\tw@=\hbox{\wt@starttabular\the\toks@\endtabular}%
\ifdim\wt@width<\wd\z@
\@tempdimb=\dimexpr\wd\tw@-\wd\z@\relax
\PackageWarning{widetable}{%
The natural width \the\wd\z@ \space of the tabular\MessageBreak
material is larger than the specified width
\the\wt@width.\MessageBreak\MessageBreak
The table is typeset with the default\MessageBreak
column spacing}%
\else
\@tempdimb=\dimexpr\wt@width-\wd\z@\relax
\fi
\@tempdimc=\dimexpr\wd\tw@-\wd\z@\relax
\WT@scale{\tabcolsep}{\@tempdimb}{\@tempdimc}{\tabcolsep}\relax
\wt@starttabular\the\toks@\endtabular
\fi
\ignorespacesafterend
}
\def\wt@finetabella{\end{widetable}}%
\def\wt@getTable#1\end#2{\def\@tempB{#2}%
\ifx\@tempB\@tempC
\toks@={#1}%
\expandafter\wt@finetabella
\else
\PackageWarning{widetable}{%
The table contains environment `\@tempB' %
\MessageBreak
not enclosed in braces. This is expressly forbidden!%
\MessageBreak
The table is not typeset and is substituted%
\MessageBreak
with a framed box}%
\advance\wt@width-2\fboxsep
\noindent\fbox{\parbox{\wt@width}{The table was not typeset
because it contains a visible \texttt{\char`\\end} in one
or more cells.}}\par
\expandafter\wt@finishTable
\fi
}
\def\wt@finishTable#1\end#2{%
\def\@tempB{#2}%
\ifx\@tempB\@tempC
\wt@scartaretrue\expandafter\wt@finetabella
\else
\expandafter\wt@finishTable
\fi
}
%%
%% Copyright 2009-2017 Claudio Beccari
%%
%% Distributable under the LaTeX Project Public License,
%% version 1.3c or higher (your choice). The latest version of
%% this license is at: http://www.latex-project.org/lppl.txt
%%
%% This work is "author-maintained"
%%
%% This work consists of this file widetable.dtx, a README file
%% the manifest.txt file, and the derived files:
%% widetable.sty and widetable.pdf.
%%
%%
%% By running pdflatex on widetable.dtx the user gets the sty
%% file and the English documentation file in
%% PDF format.
%%
%%
%% End of file `widetable.sty'.
|