summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tblr-extras/tblr-extras-dev.sty
blob: 45c58d081a04fdce73fb8063d016c06484833b86 (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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
% -----------------------------------------------------------------------
%%% tblr-extras: Extra libraries for tabularray package.
%%% Version    : 1.2 - 2024-05-30
%%% Copyright  : 2024 (c) Manuel E. Merino <manuel.merino.pe@gmail.com>
%%% License    : The LaTeX Project Public License 1.3c
% -----------------------------------------------------------------------
%%% LPPL 1.3c Notice: ---------------------------------------------------
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
%   https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2008 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Manuel E. Merino
% -----------------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}[2018-04-01]
\ProvidesPackage{tblr-extras-dev}[2024/05/30 package tblr-extras]
\RequirePackage{tabularray}
%% ----------------------------------------------------------------------
%% TblrLibrary caption - Use caption package to typeset tabularray tall
%% and long tabulars captions.
%% This stuff needs to be ported to expl3 soon.
\ExplSyntaxOn
\prg_generate_conditional_variant:Nnn \tl_if_empty:n { e } { TF }
\let \IfTokenListEmpty = \tl_if_empty:eTF
\let \IfBoolFalse = \bool_if:NF
\let \IfBoolTF = \bool_if:NTF
\bool_new:N \l__tblrextras_table_title_below_bool
\bool_set_false:N \l__tblrextras_table_title_below_bool
\NewTblrLibrary{caption}
{%
	\RequirePackage{caption}
	%% Check if a KomaClass is loaded and issue a warning for caption position setup
	\@ifundefined{KOMAClassName}
	{}
	{\PackageWarningNoLine{tblr-extras}{KOMAScript class detected. Setup caption position using 'captions=option'}}
	%%% Presetup
	\NewDocumentCommand{\TblrCaptionBelow}{}{\bool_set_true:N \l__tblrextras_table_title_below_bool}
	\NewDocumentCommand{\TblrCaptionAbove}{}{\bool_set_false:N \l__tblrextras_table_title_below_bool}
	\SetTblrOuter[talltblr,longtblr]{headsep=0pt}
	%%%%%%%%%% TEMPLATES
	\DefTblrTemplate{firsthead}{default}{
		\IfBoolTF \l__tblr_table_no_label_bool
		% True NoLabel
		{ }
		% False NoLabel
		{
		\IfBoolTF \l__tblrextras_table_title_below_bool
			% Cap Below
			{ }
			% Cap Above (default)
			{
			\addtocounter{table}{-1}
			\captionsetup{type=table}
			\IfTokenListEmpty{\InsertTblrText{entry}}{
				\caption{\InsertTblrText{caption}}
				\UseTblrTemplate{contfoot}{default}
				}{
				\caption[\InsertTblrText{entry}]{\InsertTblrText{caption}}
				}
			}
		}
	} % END FIRSTHEAD
	\DefTblrTemplate{middlehead}{default}{
		\IfBoolTF \l__tblr_table_no_label_bool
		% True NoLabel
		{ \UseTblrTemplate{conthead}{default} \vspace{4pt} }
		% False NoLabel
		{
		\IfBoolTF \l__tblrextras_table_title_below_bool
			% Cap Below
			{ \UseTblrTemplate{conthead}{default} \vspace{4pt} }
			% Cap Above (default)
			{
			\addtocounter{table}{-1}
			\captionsetup{type=table}
			\caption[]{\InsertTblrText{caption}~			\UseTblrTemplate{conthead-text}{default}}
			}
		}
	}% END MIDDLEHEAD
	\DefTblrTemplate{lasthead}{default}{
		\IfBoolTF \l__tblr_table_no_label_bool
		% True NoLabel
		{ \UseTblrTemplate{conthead}{default} \vspace{4pt} }
		% False NoLabel
		{
		\IfBoolTF \l__tblrextras_table_title_below_bool
			% Cap Below
			{ \UseTblrTemplate{conthead}{default} \vspace{4pt} }
			% Cap Above (default)
			{
			\addtocounter{table}{-1}
			\captionsetup{type=table}
			\caption[]{\InsertTblrText{caption}~			\UseTblrTemplate{conthead-text}{default}}
			}
		}
	}% END LASTHEAD
	\DefTblrTemplate{firstfoot}{default}{
		\IfBoolTF \l__tblr_table_no_label_bool
		% True NoLabel
		{ \UseTblrTemplate{contfoot}{default} }
		% False NoLabel
		{
		\IfBoolTF \l__tblrextras_table_title_below_bool
			% Cap Below
			{
			\addtocounter{table}{-1}
			\captionsetup{type=table}
			\caption[]{\InsertTblrText{caption}}
			\UseTblrTemplate{contfoot}{default}
			}
			% Cap Above (default)
			{
			\UseTblrTemplate{contfoot}{default}
			}
		}
	}% END FIRSTFOOT
	\DefTblrTemplate{middlefoot}{default}{
		\IfBoolTF \l__tblr_table_no_label_bool
		% True NoLabel
		{ \UseTblrTemplate{contfoot}{default} }
		% False NoLabel
		{
		\IfBoolTF \l__tblrextras_table_title_below_bool
			% Cap Below
			{
			\addtocounter{table}{-1}
			\captionsetup{type=table}
			\caption[]{\InsertTblrText{caption}}
			\UseTblrTemplate{contfoot}{default}
			}
			% Cap Above (default)
			{
				\UseTblrTemplate{contfoot}{default}
			}
		}
	}% END MIDDLEFOOT
	\DefTblrTemplate{lastfoot}{default}{
		\IfBoolTF \l__tblr_table_no_label_bool
		% True NoLabel
		{
			\UseTblrTemplate{note}{default}
			\UseTblrTemplate{remark}{default}
		}
		% False NoLabel
		{
		\IfBoolTF \l__tblrextras_table_title_below_bool
			% Cap Below
			{
				\UseTblrTemplate{note}{default}
				\UseTblrTemplate{remark}{default}
				\addtocounter{table}{-1}
				\captionsetup{type=table}	\IfTokenListEmpty{\InsertTblrText{entry}}{
					\caption{\InsertTblrText{caption}}
				}{
					\caption[\InsertTblrText{entry}]{\InsertTblrText{caption}}
				}
			}
			% Cap Above (default)
			{
				\UseTblrTemplate{note}{default}
				\UseTblrTemplate{remark}{default}
			}
		}
	}% END LASTFOOT
	\SetTblrTemplate{caption-lot}{empty}
}
\ExplSyntaxOff
%% ----------------------------------------------------------------------
%% TblrLibrary babel - Translate contfoot and conthead to current babel/polyglossia
%% language. Supports: ngerman, french, spanish, russian and ukrainian translations.
%% Check engine
\newif\if@unicode@engine
\ifdefined\luatexversion
	\@unicode@enginetrue
\else\ifdefined\XeTeXrevision
	\@unicode@enginetrue
\fi\fi
\NewTblrLibrary{babel}
{%
	\AddToHook{begindocument/before}{%
		\@ifpackageloaded{babel}{}{%
			\@ifpackageloaded{polyglossia}{}{%
				\RequirePackage{babel}
			}
		}
		\ifdefined\captionsspanish
			\addto\captionsspanish{%
				\DefTblrTemplate{contfoot-text}{default}{Continúa en la página siguiente}%
				\DefTblrTemplate{conthead-text}{default}{(Continuación)}%
			}
		\fi
		\ifdefined\captionsngerman
			\addto\captionsngerman{%
				\DefTblrTemplate{contfoot-text}{default}{Fortsetzung auf der nächsten Seite}%
				\DefTblrTemplate{conthead-text}{default}{(Fortsetzung)}%
			}
		\fi
		\ifdefined\captionsgerman
			\addto\captionsgerman{%
				\DefTblrTemplate{contfoot-text}{default}{Fortsetzung auf der nächsten Seite}%
				\DefTblrTemplate{conthead-text}{default}{(Fortsetzung)}%
			}
		\fi
		\ifdefined\captionsfrench
			\addto\captionsfrench{%
				\DefTblrTemplate{contfoot-text}{default}{Suite à la page suivante}%
				\DefTblrTemplate{conthead-text}{default}{(Suite)}%
			}
		\fi
		\ifdefined\captionsrussian
			\if@unicode@engine
				\addto\captionsrussian{%
					\DefTblrTemplate{contfoot-text}{default}{Продолжение на следующей странице}%
					\DefTblrTemplate{conthead-text}{default}{(продолжение)}%
				}
			\else
				\addto\captionsrussian{%
					\DefTblrTemplate{contfoot-text}{default}{\cyr\CYRP\cyrr\cyro\cyrd\cyro\cyrl\cyrzh\cyre\cyrn\cyri\cyre\ \cyrn\cyra\ \cyrs\cyrl\cyre\cyrd\cyru\cyryu\cyrshch\cyre\cyrishrt\ \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyre}%
					\DefTblrTemplate{conthead-text}{default}{(\cyr\cyrp\cyrr\cyro\cyrd\cyro\cyrl\cyrzh\cyre\cyrn\cyri\cyre)}%
				}
			\fi
		\fi
		\ifdefined\captionsukrainian
			\if@unicode@engine
				\addto\captionsukrainian{%
					\DefTblrTemplate{contfoot-text}{default}{Продовження на наступній сторінці}%
					\DefTblrTemplate{conthead-text}{default}{(продовження)}%
				}
			\else
				\addto\captionsukrainian{%
					\DefTblrTemplate{contfoot-text}{default}{\cyr\CYRP\cyrr\cyro\cyrd\cyro\cyrv\cyrzh\cyre\cyrn\cyrn\cyrya\ \cyrn\cyra\ \cyrn\cyra\cyrs\cyrt\cyru\cyrp\cyrn\cyrii\cyrishrt\ \cyrs\cyrt\cyro\cyrr\cyrii\cyrn\cyrc\cyrii}%
					\DefTblrTemplate{conthead-text}{default}{(\cyr\cyrp\cyrr\cyro\cyrd\cyro\cyrv\cyrzh\cyre\cyrn\cyrn\cyrya)}%
				}
			\fi
		\fi
	}
}