| 1 |
% easyfloats.dtx |
| 2 |
% Copyright 2020 E. Zöllner |
| 3 |
% |
| 4 |
% This work may be distributed and/or modified under the |
| 5 |
% conditions of the LaTeX Project Public License, either version 1.3 |
| 6 |
% of this license or (at your option) any later version. |
| 7 |
% The latest version of this license is in |
| 8 |
% http://www.latex-project.org/lppl.txt |
| 9 |
% and version 1.3 or later is part of all distributions of LaTeX |
| 10 |
% version 2005/12/01 or later. |
| 11 |
% |
| 12 |
% This work has the LPPL maintenance status `maintained'. |
| 13 |
% |
| 14 |
% The Current Maintainer of this work is E. Zöllner. |
| 15 |
% |
| 16 |
% This work consists of the files listed in easyfloats-file-list.txt. |
| 17 |
% The official git repository is https://gitlab.com/erzo/latex-easyfloats |
| 18 |
|
| 19 |
|
| 20 |
% dtx files (documented tex files) allow "to put the user documentation, |
| 21 |
% code documentation and code itself in one place." |
| 22 |
% https://www.texdev.net/2009/10/05/the-dtx-format/ |
| 23 |
% see also |
| 24 |
% https://www.texdev.net/2009/10/06/a-model-dtx-file/ |
| 25 |
% https://ctan.org/pkg/dtxtut |
| 26 |
% |
| 27 |
% This file is a lot simpler, it contains nothing but the package code with comments. |
| 28 |
% Technically it could be used instead of the sty file. |
| 29 |
% easyfloats.ins reads this file, strips comments and indentation using docstrip |
| 30 |
% and writes the result to the sty file in order to make it faster. |
| 31 |
|
| 32 |
%TODO: \footnotetext |
| 33 |
|
| 34 |
|
| 35 |
\NeedsTeXFormat{LaTeX2e} |
| 36 |
\ProvidesPackage{easyfloats}[2024/10/28 v1.1.0] |
| 37 |
|
| 38 |
|
| 39 |
% ========== options ========== |
| 40 |
|
| 41 |
% load either graphicx or graphbox |
| 42 |
\newif\ifesf@loadgraphics |
| 43 |
% load graphbox |
| 44 |
\newif\ifesf@loadgraphbox |
| 45 |
% load longtable |
| 46 |
\newif\ifesf@loadlongtable |
| 47 |
% load array |
| 48 |
\newif\ifesf@loadarray |
| 49 |
% load booktabs |
| 50 |
\newif\ifesf@loadbooktabs |
| 51 |
% print a warning if figure or table is used directly |
| 52 |
\newif\ifesf@warnstandardfloats |
| 53 |
\esf@warnstandardfloatstrue |
| 54 |
|
| 55 |
\DeclareOption{graphicx}{% |
| 56 |
\esf@loadgraphicstrue |
| 57 |
\esf@loadgraphboxfalse |
| 58 |
} |
| 59 |
\DeclareOption{graphbox}{% |
| 60 |
\esf@loadgraphicstrue |
| 61 |
\esf@loadgraphboxtrue |
| 62 |
} |
| 63 |
\DeclareOption{nographic}{% |
| 64 |
\esf@loadgraphicsfalse |
| 65 |
\esf@loadgraphboxfalse |
| 66 |
} |
| 67 |
|
| 68 |
\DeclareOption{longtable}{% |
| 69 |
\esf@loadlongtabletrue |
| 70 |
} |
| 71 |
\DeclareOption{nolongtable}{% |
| 72 |
\esf@loadlongtablefalse |
| 73 |
} |
| 74 |
|
| 75 |
\DeclareOption{booktabs}{% |
| 76 |
\esf@loadbooktabstrue |
| 77 |
} |
| 78 |
\DeclareOption{nobooktabs}{% |
| 79 |
\esf@loadbooktabsfalse |
| 80 |
} |
| 81 |
|
| 82 |
\DeclareOption{array}{% |
| 83 |
\esf@loadarraytrue |
| 84 |
} |
| 85 |
\DeclareOption{noarray}{% |
| 86 |
\esf@loadarrayfalse |
| 87 |
} |
| 88 |
|
| 89 |
% If I spell this with spaces LaTeX complains: |
| 90 |
% > Unknown option `allowstandardfloats' |
| 91 |
% It seems spaces are ignored by \usepackage |
| 92 |
% but not by \DeclareOption. |
| 93 |
% clsguide says: |
| 94 |
% > Note that the name of an option should contain |
| 95 |
% > only those characters allowed in a ‘LaTeX name’ |
| 96 |
% So maybe it's better to not rely on that behaviour. |
| 97 |
\DeclareOption{allowstandardfloats}{% |
| 98 |
\esf@warnstandardfloatsfalse |
| 99 |
} |
| 100 |
|
| 101 |
%\DeclareOption*{\objectset{\CurrentOption}} |
| 102 |
|
| 103 |
|
| 104 |
\ExecuteOptions{graphicx, array, booktabs} |
| 105 |
|
| 106 |
% \relax is in definition order, starred is in specification order |
| 107 |
\ProcessOptions\relax |
| 108 |
|
| 109 |
|
| 110 |
% ========== required packages ========== |
| 111 |
|
| 112 |
\RequirePackage{etoolbox} |
| 113 |
\RequirePackage{pgfkeys} |
| 114 |
|
| 115 |
% The float package defines the placement option H so that I don't need to |
| 116 |
% provide a separate inline/floating option and deal with spacing and captions |
| 117 |
% of inline objects. I can just use the usual environments like always. |
| 118 |
% It also defines float styles which move the caption to the top or bottom of |
| 119 |
% the object. It makes things easier for me because I can just insert the |
| 120 |
% caption somewhere independent of the object type. |
| 121 |
% I am *not* making use of it's capability to define new float types. |
| 122 |
% Please note that \floatplacement is overridden if the placement option is non-empty. |
| 123 |
\RequirePackage{float} |
| 124 |
|
| 125 |
% By default there is no space between a table and it's caption (at least with |
| 126 |
% the standard document classes). The caption package fixes this. |
| 127 |
% The caption package defines the \phantomcaption command (see object environment). |
| 128 |
% The caption package is required by the subcaption package. |
| 129 |
% It also gives the possibility to customize the layout of captions. But I am |
| 130 |
% leaving it to the user to do this if desired. |
| 131 |
\RequirePackage{caption} |
| 132 |
|
| 133 |
% subobjects |
| 134 |
\RequirePackage{environ} |
| 135 |
|
| 136 |
% "Die Pakete subfigure.sty und subfig.sty werden nicht mehr weiterentwickelt |
| 137 |
% und sind inkompatibel zu einigen aktuelleren Paketen wie hyperref.sty. |
| 138 |
% Als Ersatz bei Kompatibilitätsproblemen empfiehlt sich subcaption.sty." |
| 139 |
% (l2tabu, Version 2.4 vom 3. Februar 2016, Seite 16) |
| 140 |
\RequirePackage{subcaption} |
| 141 |
|
| 142 |
% \includegraphics |
| 143 |
\ifesf@loadgraphics |
| 144 |
\ifesf@loadgraphbox |
| 145 |
% extension for graphicx |
| 146 |
\RequirePackage{graphbox} |
| 147 |
\else |
| 148 |
\RequirePackage{graphicx} |
| 149 |
\fi |
| 150 |
\fi |
| 151 |
|
| 152 |
% Set long tables which are not floating |
| 153 |
% but can span across page breaks. |
| 154 |
% Requires several runs. |
| 155 |
\ifesf@loadlongtable |
| 156 |
\RequirePackage{longtable} |
| 157 |
\fi |
| 158 |
|
| 159 |
% Additional features in column specification like <, >, !. |
| 160 |
% Changes also the behaviour of rules but that is irrelevant if you use booktabs. |
| 161 |
\ifesf@loadarray |
| 162 |
\RequirePackage{array} |
| 163 |
\fi |
| 164 |
|
| 165 |
% Macros for formating tables. |
| 166 |
\ifesf@loadbooktabs |
| 167 |
\RequirePackage{booktabs} |
| 168 |
\fi |
| 169 |
|
| 170 |
|
| 171 |
% ========== init ========== |
| 172 |
|
| 173 |
\newif\ifobject@directkeys |
| 174 |
\object@directkeystrue |
| 175 |
|
| 176 |
\newif\if@inobject |
| 177 |
\newif\if@firstsubobject |
| 178 |
\newif\if@containssubobjects |
| 179 |
|
| 180 |
\floatstyle{plaintop} |
| 181 |
\restylefloat{table} |
| 182 |
\floatstyle{plain} |
| 183 |
\restylefloat{figure} |
| 184 |
|
| 185 |
|
| 186 |
% ========== hooks ========== |
| 187 |
|
| 188 |
\newif\ifobject@isgraphic |
| 189 |
|
| 190 |
\newcommand{\object@hook}{} |
| 191 |
\newcommand{\object@endhook}{} |
| 192 |
\newcommand{\subobject@hook}{} |
| 193 |
\newcommand{\object@graphic@hook}{} |
| 194 |
|
| 195 |
\newrobustcmd{\AtBeginObject}[1]{\appto\object@hook{#1}} |
| 196 |
\newrobustcmd{\AtEndObject}[1]{\appto\object@endhook{#1}} |
| 197 |
\newrobustcmd{\AtBeginSubobject}[1]{\appto\subobject@hook{#1}} |
| 198 |
\newrobustcmd{\AtBeginGraphicObject}[1]{\appto\object@graphic@hook{#1}} |
| 199 |
|
| 200 |
|
| 201 |
% ========== key management ========== |
| 202 |
|
| 203 |
\newcommand{\esf@ifpgfkeyhasvalue}[1]{% #1: key, #2: executed if #1 is set, #3: executed if #1 has not been set |
| 204 |
% WARNING: Trying to get the value defines the key to \relax if it |
| 205 |
% was undefined (because of \csname). Setting the key to \relax is |
| 206 |
% discouraged because it causes inconsistent behaviour [TikZ & PGF |
| 207 |
% Manual v3.1.5b page 976 \pgfkeysifdefined]. |
| 208 |
% With eTeX: \pgfkeysifdefined will report the key as *defined*. |
| 209 |
% Without eTeX: \pgfkeysifdefined will report the key as *un*defined. |
| 210 |
% Therefore don't use this macro with undefined keys. If you do use |
| 211 |
% it with an undefined key it will be treated as if it has been set [!]. |
| 212 |
\pgfkeysgetvalue{#1}{\esf@tmp@value}% |
| 213 |
\ifx \pgfkeysnovalue@text \esf@tmp@value |
| 214 |
\expandafter \@secondoftwo |
| 215 |
\else |
| 216 |
\expandafter \@firstoftwo |
| 217 |
\fi |
| 218 |
} |
| 219 |
|
| 220 |
\newcommand{\esf@ifpgfkeyexists}[3]{% |
| 221 |
% I cannot use \@firstoftwo and \@secondoftwo because \pgfkeysifdefined |
| 222 |
% does not close the if statement before expanding the 2nd and 3rd argument |
| 223 |
\pgfkeysifdefined{#1} |
| 224 |
{#2} |
| 225 |
{\pgfkeysifdefined{#1/.@cmd}{#2}{#3}}% |
| 226 |
} |
| 227 |
\newcommand{\esf@ifpgfkeyrequiresvalue}[3]{% #1: key, #2: then block, #3: else block |
| 228 |
\pgfkeysifdefined{#1/.@def}{% |
| 229 |
\pgfkeysgetvalue{#1/.@def}{\esf@tmp@value}% |
| 230 |
\ifx \esf@tmp@value \pgfkeysvaluerequired |
| 231 |
#2% |
| 232 |
\else |
| 233 |
#3% |
| 234 |
\fi |
| 235 |
}{% |
| 236 |
#3% |
| 237 |
}% |
| 238 |
} |
| 239 |
|
| 240 |
\newcommand{\esf@ifkeyvalkeyexists}[4]{% #1: family, #2: key, #3: then block, #4: else block |
| 241 |
% \ifcsdef would treat \relax as defined, \ifcsundef does not |
| 242 |
\ifcsundef{KV@#1@#2}{#4}{#3}% |
| 243 |
} |
| 244 |
\newcommand{\esf@ifkeyvalkeyrequiresvalue}[2]{% #1: family, #2: key, #3: then block, #4: else block |
| 245 |
% \ifcsdef would treat \relax as defined, \ifcsundef does not |
| 246 |
\ifcsundef{KV@#1@#2@default}% |
| 247 |
} |
| 248 |
|
| 249 |
\newcommand{\esf@pgfkeyscopyvalue}[2]{% #1: key to be set, #2 key to take the value from |
| 250 |
% WARNING: the order of arguments is opposite of the shell command cp |
| 251 |
% because all pgf macros take the key they operate on as first argument. |
| 252 |
\pgfkeysgetvalue{#2}{\esf@tmp@value}% |
| 253 |
\pgfkeyslet{#1}{\esf@tmp@value}% |
| 254 |
} |
| 255 |
\newcommand{\esf@pgfkeysvalueappend}[2]{% #1: key to be set, #2 value to be appended |
| 256 |
\pgfkeysgetvalue{#1}{\esf@tmp@value}% |
| 257 |
\appto\esf@tmp@value{#2}% |
| 258 |
\pgfkeyslet{#1}{\esf@tmp@value}% |
| 259 |
} |
| 260 |
|
| 261 |
\pgfqkeys{/handlers}{% |
| 262 |
% ------- recommended ------- |
| 263 |
.esf@recommended/.code={% |
| 264 |
\esf@ifpgfkeyhasvalue{\pgfkeyscurrentpath}{% |
| 265 |
% do nothing |
| 266 |
}{% |
| 267 |
\edef\esf@tmp@path{\pgfkeyscurrentpath}% |
| 268 |
\PackageWarning{easyfloats}{Recommended key '\strippath\esf@tmp@path' not given. #1\ifx\pgfkeysnovalue#1\@empty\else. \fi This warning occured}% |
| 269 |
}% |
| 270 |
}, |
| 271 |
% |
| 272 |
% ------- mandatory ------- |
| 273 |
.esf@mandatory/.code={% |
| 274 |
\esf@ifpgfkeyhasvalue{\pgfkeyscurrentpath}{% |
| 275 |
% do nothing |
| 276 |
}{% |
| 277 |
\edef\esf@tmp@path{\pgfkeyscurrentpath}% |
| 278 |
\PackageError{easyfloats}{Mandatory key '\strippath\esf@tmp@path' not given\ifx\pgfkeysnovalue#1\@empty\else. \fi #1}{}% |
| 279 |
}% |
| 280 |
}, |
| 281 |
% |
| 282 |
% |
| 283 |
% ------- save unknown ------- |
| 284 |
% I can't use /pgf/keyfilters/defined with /pgf/key filter handlers/append filtered to |
| 285 |
% because that appends full keys which are incompatible with keyval. |
| 286 |
.esf@exec on unknown/.code={% #1: control sequence taking two args: key and value |
| 287 |
\pgfkeysalso{\pgfkeyscurrentpath/.unknown/.code=% ##1: value |
| 288 |
#1{\pgfkeyscurrentname}{##1}% |
| 289 |
}% |
| 290 |
}, |
| 291 |
% |
| 292 |
% ------- also from ------- |
| 293 |
.esf@also from/.code={% #1: expandable control sequence containing options |
| 294 |
\pgfkeysalsofrom{#1}% |
| 295 |
}, |
| 296 |
% |
| 297 |
% ------- debugging ------- |
| 298 |
.show boolean/.code={% |
| 299 |
\begingroup |
| 300 |
\renewcommand\pgfkeys@handle@boolean[2]{% ##1: if name, ##2: value |
| 301 |
\expandafter \show \csname if##1\endcsname |
| 302 |
}% |
| 303 |
\edef\esf@tmp@path{\pgfkeyscurrentpath}% |
| 304 |
\pgfkeysalso{\esf@tmp@path}% |
| 305 |
\endgroup |
| 306 |
}, |
| 307 |
.show boolean/.value forbidden, |
| 308 |
} |
| 309 |
|
| 310 |
\newcommand{\AppendToOptionsList}[3]{% #1: macro to append to, #2: key, #3: value |
| 311 |
\ifdefvoid#1% |
| 312 |
{}% |
| 313 |
{\appto#1{, }}% |
| 314 |
\eappto#1{#2}% |
| 315 |
\ifx \pgfkeysnovalue #3\relax |
| 316 |
% do nothing |
| 317 |
\else |
| 318 |
\appto#1{={#3}}% |
| 319 |
\fi |
| 320 |
} |
| 321 |
|
| 322 |
\newcommand{\strippath}[1]{% |
| 323 |
\expandafter\strippath@do#1/\pgfeov |
| 324 |
} |
| 325 |
\def\strippath@do#1/#2\pgfeov{% |
| 326 |
\if\relax\detokenize{#2}\relax |
| 327 |
#1% |
| 328 |
\else |
| 329 |
\strippath@do#2\pgfeov |
| 330 |
\fi |
| 331 |
} |
| 332 |
|
| 333 |
|
| 334 |
% ========== other helper ========== |
| 335 |
|
| 336 |
\newcommand{\IfEnvironmentExistsOrIsEmpty}[1]{% #1: environment name, #2: then block, #3: else block |
| 337 |
\ifstrempty{#1}{% |
| 338 |
\let\IfEnvironmentExistsOrIsEmpty@do=\@firstoftwo |
| 339 |
}{\IfEnvironmentExists{#1}{% |
| 340 |
\let\IfEnvironmentExistsOrIsEmpty@do=\@firstoftwo |
| 341 |
}{% |
| 342 |
\let\IfEnvironmentExistsOrIsEmpty@do=\@secondoftwo |
| 343 |
}}% |
| 344 |
\IfEnvironmentExistsOrIsEmpty@do |
| 345 |
} |
| 346 |
|
| 347 |
\newcommand{\IfEnvironmentExists}[3]{% #1: environment name, #2: then block, #3: else block |
| 348 |
\ifcsmacro{#1}{% |
| 349 |
% I am not checking the existence of end#1 because for tabularx that is \relax. |
| 350 |
#2% |
| 351 |
}{% |
| 352 |
#3% |
| 353 |
}% |
| 354 |
} |
| 355 |
|
| 356 |
|
| 357 |
% \patchcmd replaces the first occurence only. |
| 358 |
% therefore I am recursing as long as patching was successful |
| 359 |
% to make sure that each occurrence was replaced. |
| 360 |
% it is important to replace with \textunderscore instead of \_ |
| 361 |
% because otherwise it would replace \_ by \\_ and loop infinitely. |
| 362 |
\newcommand{\PatchUnderscore}[1]{% #1: macro |
| 363 |
\patchcmd{#1} |
| 364 |
{_}{\textunderscore} |
| 365 |
{\PatchUnderscore#1}{}% |
| 366 |
} |
| 367 |
|
| 368 |
|
| 369 |
% ========== object ========== |
| 370 |
|
| 371 |
\newif\ifobject@warnotherenv |
| 372 |
\newif\ifobject@warnnolabel |
| 373 |
\newif\ifobject@warnnocaption |
| 374 |
\newif\ifobject@showenv |
| 375 |
|
| 376 |
% ---------- set object options ---------- |
| 377 |
|
| 378 |
\newrobustcmd{\objectset}{% #1: options |
| 379 |
\@ifnextchar [%] |
| 380 |
\objectset@appendtostyles |
| 381 |
\objectset@direct |
| 382 |
} |
| 383 |
|
| 384 |
\newcommand{\objectset@direct}{% #1: options |
| 385 |
\pgfqkeys{/object}% |
| 386 |
} |
| 387 |
|
| 388 |
\newcommand{\GobbleLeadingSpaceIn}[1]{\edef#1{\expandafter\@firstofone#1}} |
| 389 |
|
| 390 |
\def\objectset@appendtostyles[#1]#2{% #1: style #2: options |
| 391 |
\pgfkeyssetvalue{/object.check/env}{}% |
| 392 |
\pgfqkeys{/object.check}{% |
| 393 |
.esf@exec on unknown=\AppendOptionToObjectStyleGroups{#1}, |
| 394 |
#2% |
| 395 |
}% |
| 396 |
} |
| 397 |
|
| 398 |
% ---------- check object options ---------- |
| 399 |
|
| 400 |
\newcommand{\CheckObjectOption}[2]{% #1: key, #2: value, #3: executed if valid |
| 401 |
% if #3 is *not* executed an error message is printed |
| 402 |
% |
| 403 |
% It is important to reset it at the beginning |
| 404 |
% because the \Check* macros do not expand any |
| 405 |
% of the two arguments if they throw an error. |
| 406 |
\let\CheckObjectOption@handleArg=\@gobble |
| 407 |
\esf@ifpgfkeyexists{/object/#1}{% |
| 408 |
\esf@ifpgfkeyrequiresvalue{/object/#1}{% |
| 409 |
\ifx \pgfkeysnovalue #2\relax |
| 410 |
\PackageError{easyfloats}{The key '#1' requires a value. I am going to ignore this key}{}% |
| 411 |
\else |
| 412 |
\let\CheckObjectOption@handleArg=\@firstofone |
| 413 |
\fi |
| 414 |
}{% |
| 415 |
\let\CheckObjectOption@handleArg=\@firstofone |
| 416 |
}% |
| 417 |
}{\CheckObjectGraphicOption{#1}{#2}{% |
| 418 |
\let\CheckObjectOption@handleArg=\@firstofone |
| 419 |
}{\CheckObjectEnvArgs{#1}{#2}{% |
| 420 |
\let\CheckObjectOption@handleArg=\@firstofone |
| 421 |
}{% |
| 422 |
\PackageError{easyfloats}{I do not know the key '#1' and I am going to ignore it. Perhaps you misspelled it}{}% |
| 423 |
}}}% |
| 424 |
\CheckObjectOption@handleArg |
| 425 |
} |
| 426 |
|
| 427 |
|
| 428 |
% ---------- available object options ---------- |
| 429 |
|
| 430 |
\pgfqkeys{/object}{% |
| 431 |
% |
| 432 |
% ------- mandatory ------- |
| 433 |
% |
| 434 |
% The environment to use (figure|table) |
| 435 |
% An empty value is allowed for longtable |
| 436 |
% but that is intentionally left undocumented. |
| 437 |
type/.initial, |
| 438 |
type/.value required, |
| 439 |
type/.code=\@ifundefined{fps@#1} |
| 440 |
{\PackageError{easyfloats}{Invalid value for key 'type': '#1'. I am going to ignore this option}{}} |
| 441 |
{\pgfkeyssetvalue{/object/type}{#1}}, |
| 442 |
% |
| 443 |
% Where to place the caption, see float package (plain|plaintop|ruled|boxed) |
| 444 |
% If empty do *not* perform a restyle. |
| 445 |
% This is ignored if type is empty. |
| 446 |
float style/.initial=, |
| 447 |
float style/.value required, |
| 448 |
% |
| 449 |
% |
| 450 |
% ------- recommended ------- |
| 451 |
% |
| 452 |
% The caption displayed above or below the content (depending on the float style). |
| 453 |
% There is *no* dot added automatically behind it. |
| 454 |
caption/.initial, |
| 455 |
caption/.value required, |
| 456 |
caption/.prefix code={% |
| 457 |
\esf@ifpgfkeyhasvalue{/object/caption}{% |
| 458 |
\PackageWarning{easyfloats}{Overwriting existing value for caption with "#1"}% |
| 459 |
}{% |
| 460 |
% ok |
| 461 |
}% |
| 462 |
}, |
| 463 |
% |
| 464 |
% A label which can be referenced by e.g. \ref{label} or \refpage{label} |
| 465 |
label/.initial, |
| 466 |
label/.value required, |
| 467 |
label/.prefix code={% |
| 468 |
\esf@ifpgfkeyhasvalue{/object/label}{% |
| 469 |
\PackageWarning{easyfloats}{Overwriting existing value for label with "#1"}% |
| 470 |
}{% |
| 471 |
% ok |
| 472 |
}% |
| 473 |
}, |
| 474 |
% |
| 475 |
% |
| 476 |
% ------- optional ------- |
| 477 |
% |
| 478 |
% Where to put the float on the page ([htbp]+ | H | <empty>) |
| 479 |
% (empty means to *not* pass the optional placement argument to the foating environment) |
| 480 |
% This is more powerful than \floatplacement because it allows H. |
| 481 |
placement/.initial=, |
| 482 |
placement/.value required, |
| 483 |
% |
| 484 |
% The caption used in the list of figures/list of tables |
| 485 |
list caption/.initial, |
| 486 |
list caption/.value required, |
| 487 |
% |
| 488 |
% An addition to the caption (at the object only, not in a list) |
| 489 |
details/.initial=, |
| 490 |
details/.value required, |
| 491 |
% |
| 492 |
details sep/.initial=.\space, |
| 493 |
details sep/.value required, |
| 494 |
% |
| 495 |
% An additional label which can be used synonymously to label. |
| 496 |
% If this key is given several times, only the last one will have an effect. |
| 497 |
add label/.initial, |
| 498 |
add label/.value required, |
| 499 |
% |
| 500 |
% TeX code which is inserted at the beginning of the type environment |
| 501 |
align/.initial=\centering, |
| 502 |
align/.value required, |
| 503 |
% |
| 504 |
% TeX code which is inserted at the beginning of the type environment (before align) |
| 505 |
exec/.initial=, |
| 506 |
exec/.value required, |
| 507 |
exec +/.code=\esf@pgfkeysvalueappend{/object/exec}{#1}, |
| 508 |
exec +/.value required, |
| 509 |
exec+/.forward to=/object/exec +, |
| 510 |
exec+/.value required, |
| 511 |
% |
| 512 |
% An additional inner environment to wrap the content in like tabular, tabularx, tikzpicture |
| 513 |
env/.code=\IfEnvironmentExistsOrIsEmpty{#1} |
| 514 |
{\pgfkeyssetvalue{/object/env}{#1}}% |
| 515 |
{\PackageError{easyfloats}{Environment #1 which you passed to the key 'env' does not exist}{}}, |
| 516 |
env/.value required, |
| 517 |
env=, |
| 518 |
% |
| 519 |
% Specify that this object contains subobjects. |
| 520 |
% This means that if env has a non-empty value |
| 521 |
% this value is used for subobject env |
| 522 |
% and env is set to an empty value. |
| 523 |
sub/.forward to=/object/contains subobjects, |
| 524 |
contains subobjects/.is if = @containssubobjects, |
| 525 |
% |
| 526 |
% |
| 527 |
% ------- tables ------- |
| 528 |
% first head and last foot are optional but if they are given they have priority. |
| 529 |
% head and foot always need to have a value even if it's just empty. |
| 530 |
% |
| 531 |
first head/.initial, |
| 532 |
first head/.value required, |
| 533 |
% |
| 534 |
head/.initial=, |
| 535 |
head/.value required, |
| 536 |
% |
| 537 |
foot/.initial=, |
| 538 |
foot/.value required, |
| 539 |
% |
| 540 |
last foot/.initial, |
| 541 |
last foot/.value required, |
| 542 |
% |
| 543 |
table head style/.code=\pgfkeysdef{/object/table head}{\pgfqkeys{/object}{#1}}, |
| 544 |
table head style/.value required, |
| 545 |
table head style={% |
| 546 |
first head = |
| 547 |
\toprule |
| 548 |
#1 \\ |
| 549 |
\midrule, |
| 550 |
head = |
| 551 |
#1 \\ |
| 552 |
\midrule, |
| 553 |
foot = |
| 554 |
\midrule |
| 555 |
\ifx\object@tableBreakText\@empty |
| 556 |
\else |
| 557 |
\multicolumn{\the\LT@cols}{r@\relax}{\object@tableBreakText}% |
| 558 |
\fi, |
| 559 |
last foot = |
| 560 |
\bottomrule, |
| 561 |
}, |
| 562 |
% |
| 563 |
% text displayed in the non-last foot of a table |
| 564 |
table break text/.code=\def\object@tableBreakText{#1}, |
| 565 |
table break text/.value required, |
| 566 |
table break text = (to be continued), |
| 567 |
% |
| 568 |
% |
| 569 |
% ------- warnings ------- |
| 570 |
% |
| 571 |
warn no caption/.is if=object@warnnocaption, |
| 572 |
warn no caption=true, |
| 573 |
% |
| 574 |
warn no label/.is if=object@warnnolabel, |
| 575 |
warn no label=true, |
| 576 |
% |
| 577 |
warn other env/.is if=object@warnotherenv, |
| 578 |
warn other env=false, |
| 579 |
% |
| 580 |
% |
| 581 |
% ------- debugging ------- |
| 582 |
% |
| 583 |
show env args/.is if=object@showenv, |
| 584 |
show env args=false, |
| 585 |
% |
| 586 |
% |
| 587 |
% ------- subobject ------- |
| 588 |
% .value required is code duplication but |
| 589 |
% it is necessary for \esf@ifpgfkeyrequiresvalue. |
| 590 |
% It also changes the error message to report |
| 591 |
% this key instead of the linked key. |
| 592 |
% |
| 593 |
subobject linewidth/.forward to=/subobject/linewidth, |
| 594 |
subobject linewidth/.value required, |
| 595 |
subobject env/.forward to=/subobject/env, |
| 596 |
subobject env/.value required, |
| 597 |
% |
| 598 |
subcaptionbox/.forward to=/subobject/subcaptionbox, |
| 599 |
subcaptionbox/.value forbidden, |
| 600 |
subpage/.forward to=/subobject/subpage, |
| 601 |
subpage/.value forbidden, |
| 602 |
% |
| 603 |
subcaptionbox inner pos/.forward to=/subobject/subcaptionbox inner pos, |
| 604 |
subcaptionbox inner pos/.value required, |
| 605 |
% |
| 606 |
subpage inner pos/.forward to=/subobject/subpage inner pos, |
| 607 |
subpage inner pos/.value required, |
| 608 |
subpage height/.forward to=/subobject/subpage height, |
| 609 |
subpage height/.value required, |
| 610 |
subpage outer pos/.forward to=/subobject/subpage outer pos, |
| 611 |
subpage outer pos/.value required, |
| 612 |
subpage align/.forward to=/subobject/subpage align, |
| 613 |
subpage align/.value required, |
| 614 |
% |
| 615 |
subobject sep/.forward to=/subobject/sep, |
| 616 |
subobject sep/.value required, |
| 617 |
% |
| 618 |
subobject hor/.forward to=/subobject/hor, |
| 619 |
%subobject hor/ value is allowed but not necessary |
| 620 |
subobject hor sep/.forward to=/subobject/hor sep, |
| 621 |
subobject hor sep/.value required, |
| 622 |
subobject hor sep+/.forward to=/subobject/hor sep+, |
| 623 |
subobject hor sep+/.value required, |
| 624 |
subobject hor sep +/.forward to=/subobject/hor sep +, |
| 625 |
subobject hor sep +/.value required, |
| 626 |
% |
| 627 |
subobject ver/.forward to=/subobject/ver, |
| 628 |
%subobject ver/ value is allowed but not necessary |
| 629 |
subobject ver sep/.forward to=/subobject/ver sep, |
| 630 |
subobject ver sep/.value required, |
| 631 |
subobject ver sep+/.forward to=/subobject/ver sep+, |
| 632 |
subobject ver sep+/.value required, |
| 633 |
subobject ver sep +/.forward to=/subobject/ver sep +, |
| 634 |
subobject ver sep +/.value required, |
| 635 |
% |
| 636 |
subobject exec/.forward to=/subobject/exec, |
| 637 |
subobject exec/.value required, |
| 638 |
subobject exec+/.forward to=/subobject/exec+, |
| 639 |
subobject exec+/.value required, |
| 640 |
subobject exec +/.forward to=/subobject/exec +, |
| 641 |
subobject exec +/.value required, |
| 642 |
% |
| 643 |
subobject warn no caption/.forward to=/subobject/warn no caption, |
| 644 |
%value is allowed but not necessary |
| 645 |
subobject warn no label/.forward to=/subobject/warn no label, |
| 646 |
%value is allowed but not necessary |
| 647 |
% |
| 648 |
% |
| 649 |
% ------- unknown handler / key patterns ------- |
| 650 |
% |
| 651 |
% Two key patterns are defined to automatically pass arguments to the environments specified by the env option if the environment name matches. |
| 652 |
% `<envname> arg` is for a single mandatory (undelimited) argument. It is wrapped in braces. |
| 653 |
% `<envname> args` is not wrapped in braces and can be used for several arguments or an optional argument. |
| 654 |
% It cannot be used for a single mandatory argument because \pgfkeys strips several levels of braces. |
| 655 |
.unknown/.code={% |
| 656 |
\ObjectProcessKeyPattern{\pgfkeyscurrentname}{#1}{% |
| 657 |
\pgfkeysgetvalue{/object/.really unknown/.@cmd}{\esf@tmp@err}% |
| 658 |
\esf@tmp@err#1\pgfeov |
| 659 |
}% |
| 660 |
}, |
| 661 |
% Setting an unknown key handler shall not override env args but set an additional unknown handler. |
| 662 |
.unknown/.code/.code={% |
| 663 |
\pgfkeysdef{/object/.really unknown}{#1}% |
| 664 |
}, |
| 665 |
.really unknown/.code={% |
| 666 |
\edef\do{\noexpand\pgfkeys{/errors/unknown key={\pgfkeyscurrentkey}{\unexpanded{#1}}}}% |
| 667 |
\do |
| 668 |
}, |
| 669 |
} |
| 670 |
|
| 671 |
\pgfqkeys{/object.check}{% |
| 672 |
env/.initial=, |
| 673 |
env/.code={% |
| 674 |
\ifx \pgfkeysnovalue #1\relax |
| 675 |
\PackageError{easyfloats}{The key 'env' requires a value. I am going to ignore this key}{}% |
| 676 |
\else |
| 677 |
\IfEnvironmentExistsOrIsEmpty{#1}{% |
| 678 |
% set env so that I can use the value to check args |
| 679 |
\pgfkeyssetvalue{/object.check/env}{#1}% |
| 680 |
% call the unknown handler which appends it to the style |
| 681 |
% unlike '/errors/unknown key' '.unknown' does not take the key as argument |
| 682 |
% but it may require \pgfkeyscurrentpath and \pgfkeyscurrentname to be set |
| 683 |
\pgfkeys@split@path |
| 684 |
\pgfkeysvalueof{\pgfkeyscurrentpath/.unknown/.@cmd}#1\pgfeov |
| 685 |
}{% |
| 686 |
\PackageError{easyfloats}{Environment #1 which you passed to the key 'env' does not exist}{}% |
| 687 |
}% |
| 688 |
\fi |
| 689 |
}, |
| 690 |
type/.code={% |
| 691 |
% set type so that I can use the value in \NewObjectStyleGroup |
| 692 |
\pgfkeyssetvalue{/object.check/type}{#1}% |
| 693 |
% call the unknown handler which appends it to the style |
| 694 |
% unlike '/errors/unknown key' '.unknown' does not take the key as argument |
| 695 |
% but it may require \pgfkeyscurrentpath and \pgfkeyscurrentname to be set |
| 696 |
\pgfkeys@split@path |
| 697 |
% Without the braces I got "Undefined control sequence. [...] \pgfeov" |
| 698 |
% \pgfkeys strips several levels of braces around an argument. |
| 699 |
% (I have already experienced that while experimenting with <env> args. |
| 700 |
% That is the reason why I defined two separate keys arg and args.) |
| 701 |
% I am assuming that because of that the \pgfeov ended the argument of some |
| 702 |
% pgfkeys internal macro too early causing undefined behavior. |
| 703 |
% I am preventing this from happening by hiding \pgfeov inside of braces |
| 704 |
% which are inside of the argument so they won't get stripped. |
| 705 |
% I put \@firstofone in front of them so that they do not function as a group. |
| 706 |
\@firstofone{\pgfkeysvalueof{\pgfkeyscurrentpath/.unknown/.@cmd}#1\pgfeov}% |
| 707 |
}, |
| 708 |
} |
| 709 |
|
| 710 |
% ---------- process key patterns ---------- |
| 711 |
|
| 712 |
\newcommand{\ObjectProcessKeyPattern}[2]{% #1: key, #2: value, #3: else |
| 713 |
\expandafter\ObjectProcessKeyPattern@expandedkey\expandafter{#1}{#2}% |
| 714 |
} |
| 715 |
|
| 716 |
\newcommand{\ObjectProcessKeyPattern@expandedkey}[2]{% #1: key, #2: value, #3: else |
| 717 |
\ObjectProcessGraphicOption@expandedkey{#1}{#2}{% |
| 718 |
\@gobble |
| 719 |
}{% |
| 720 |
\ObjectProcessArgs@expandedkey{#1}{#2}\relax |
| 721 |
}% |
| 722 |
} |
| 723 |
|
| 724 |
% ---------- process graphic options ---------- |
| 725 |
|
| 726 |
\ifesf@loadgraphics |
| 727 |
|
| 728 |
% do not confuse this with \CheckGraphicobjectOption |
| 729 |
\newcommand{\CheckObjectGraphicOption}[2]{% #1: key, #2: value |
| 730 |
% #3: executed if valid, #4: executed if *not* a graphic option |
| 731 |
% Please note that if the option looks like a graphic option |
| 732 |
% but is not valid neither #3 nor #4 is executed. |
| 733 |
% Instead an appropriate error message is printed. |
| 734 |
\begingroup |
| 735 |
\let\ObjectCheckGraphicOption@aftergroup=\@gobbletwo |
| 736 |
\renewcommand{\AppendToOptionsList}[3]{% |
| 737 |
\let\ObjectCheckGraphicOption@aftergroup=\@firstoftwo |
| 738 |
}% |
| 739 |
\ObjectProcessGraphicOption{#1}{#2}{% |
| 740 |
\let\ObjectCheckGraphicOption@aftergroup=\@secondoftwo |
| 741 |
}% |
| 742 |
\expandafter |
| 743 |
\endgroup |
| 744 |
\ObjectCheckGraphicOption@aftergroup |
| 745 |
} |
| 746 |
|
| 747 |
\newcommand{\ObjectProcessGraphicOption}[2]{% #1: key, #2: value |
| 748 |
% #3: executed if *not* a graphic option |
| 749 |
\expandafter\ObjectProcessGraphicOption@expandedkey\expandafter{#1}{#2}\relax |
| 750 |
} |
| 751 |
\newcommand{\ObjectProcessGraphicOption@expandedkey}[2]{% #1: key, #2: value |
| 752 |
% #3: executed if graphic option, #4: executed if *not* a graphic option |
| 753 |
\ObjectProcessGraphicOption@checkoption#1graphic \pgfeov{#2}% |
| 754 |
} |
| 755 |
\long\def\ObjectProcessGraphicOption@checkoption#1graphic #2\pgfeov#3{% #1: empty if graphic option, #2: key, #3: value |
| 756 |
% #4: executed if graphic option, #5: executed if *not* a graphic option |
| 757 |
\def\esf@tmp@arg{#1}% |
| 758 |
\ifx \esf@tmp@arg \@empty |
| 759 |
\edef\esf@opgoco@key{\StripGraphicSpace#2\pgfeov}% |
| 760 |
\CheckGraphicobjectOption{\esf@opgoco@key}{#3}{% |
| 761 |
\AppendGraphicobjectOption{\esf@opgoco@key}{#3}% |
| 762 |
}% |
| 763 |
\expandafter \@firstoftwo |
| 764 |
\else |
| 765 |
\expandafter \@secondoftwo |
| 766 |
\fi |
| 767 |
} |
| 768 |
|
| 769 |
\def\StripGraphicSpace#1graphic \pgfeov{#1} |
| 770 |
|
| 771 |
\else %\ifesf@loadgraphics |
| 772 |
|
| 773 |
\newcommand{\CheckObjectGraphicOption}[2]{% #1: key, #2: value |
| 774 |
% #3: executed if valid, #4: executed if *not* a graphic option |
| 775 |
\@secondoftwo |
| 776 |
} |
| 777 |
|
| 778 |
\newcommand{\ObjectProcessGraphicOption@expandedkey}[2]{% #1: key, #2: value |
| 779 |
% #3: executed if graphic option, #4: executed if *not* a graphic option |
| 780 |
\@secondoftwo |
| 781 |
} |
| 782 |
|
| 783 |
\fi %\ifesf@loadgraphics |
| 784 |
|
| 785 |
% ---------- process env args ---------- |
| 786 |
|
| 787 |
\newcommand{\@object@envkey}{/object/env} |
| 788 |
\newcommand{\CheckObjectEnvArgs}[2]{% #1: key, #2: value |
| 789 |
% #3: executed if valid, #4: executed if *not* an <env> arg |
| 790 |
% Please note that if the option looks like an <env> arg |
| 791 |
% but is not valid neither #3 nor #4 is executed. |
| 792 |
% Instead an appropriate error message is printed. |
| 793 |
\begingroup |
| 794 |
\edef\ObjectCheckArgs@key{#1}% |
| 795 |
\let\ObjectCheckArgs@aftergroup=\@gobbletwo |
| 796 |
\pgfkeysgetvalue{/object.check/env}{\esf@tmp@env}% |
| 797 |
\pgfkeys{\@object@envkey/.expand once=\esf@tmp@env}% |
| 798 |
\renewcommand{\ObjectDefineEnvargs}[2]{% ##1: env name, ##2: arguments |
| 799 |
\let\ObjectCheckArgs@aftergroup=\@firstoftwo |
| 800 |
}% |
| 801 |
\ObjectProcessArgs{\ObjectCheckArgs@key}{#2}{% |
| 802 |
\let\ObjectCheckArgs@aftergroup=\@secondoftwo |
| 803 |
}% |
| 804 |
\expandafter |
| 805 |
\endgroup |
| 806 |
\ObjectCheckArgs@aftergroup |
| 807 |
} |
| 808 |
|
| 809 |
|
| 810 |
\newcommand{\ObjectProcessArgs}[2]{% #1: key, #2: value, #3: else |
| 811 |
\expandafter\ObjectProcessArgs@expandedkey\expandafter{#1}{#2}\relax |
| 812 |
} |
| 813 |
|
| 814 |
\newcommand{\ObjectProcessArgs@expandedkey}[2]{% #1: key, #2: value, #3: then, #4: else |
| 815 |
\IfEndsOnSpacePlus{#1}{% |
| 816 |
\let\ObjectProcessArgs@csdef=\csappto |
| 817 |
\expandafter\ObjectProcessArgs@checkArgs\expandafter{\StripSpacePlus#1\pgfeov}{#2}% |
| 818 |
}{\IfEndsOnPlus{#1}{% |
| 819 |
\let\ObjectProcessArgs@csdef=\csappto |
| 820 |
\expandafter\ObjectProcessArgs@checkArgs\expandafter{\StripPlus#1\pgfeov}{#2}% |
| 821 |
}{% |
| 822 |
\let\ObjectProcessArgs@csdef=\csdef |
| 823 |
\ObjectProcessArgs@checkArgs{#1}{#2}% |
| 824 |
}}% |
| 825 |
} |
| 826 |
|
| 827 |
\newrobustcmd{\IfEndsOn}[2]{% #1: end character, #2: text |
| 828 |
\def\IfEndsOn@do##1#1##2\pgfeov{% |
| 829 |
\ifstrequal{##2}{}{% |
| 830 |
\let\do=\@secondoftwo |
| 831 |
}{\ifstrequal{##2}{#1}{% |
| 832 |
\let\do=\@firstoftwo |
| 833 |
}{% |
| 834 |
\def\do{\IfEndsOn@do##2\pgfeov}% |
| 835 |
}}% |
| 836 |
\do |
| 837 |
}% |
| 838 |
\IfEndsOn@do#2#1\pgfeov |
| 839 |
} |
| 840 |
\newcommand{\IfEndsOnPlus}{\IfEndsOn+} |
| 841 |
\newcommand{\IfEndsOnSpacePlus}{\IfEndsOn{ +}} |
| 842 |
|
| 843 |
\def\StripSpacePlus#1 +\pgfeov{#1} |
| 844 |
\def\StripPlus#1+\pgfeov{#1} |
| 845 |
|
| 846 |
|
| 847 |
\newcommand{\ObjectProcessArgs@checkArgs}[2]{% #1: key, #2: value, #3: then, #4: else |
| 848 |
\ObjectProcessArgs@do#1 args\pgfeov{#2}% |
| 849 |
} |
| 850 |
\long\def\ObjectProcessArgs@do#1 arg#2\pgfeov#3{% #1: env name, #2: test value, #3: arguments, #4: then, #5: else |
| 851 |
\let\ObjectProcessArgs@do@after=\@firstoftwo |
| 852 |
\ifstrequal{#2}{ args}{% |
| 853 |
\ObjectDefineEnvargsCheckName{#1}{{#3}}% |
| 854 |
}{\ifstrequal{#2}{s args}{% |
| 855 |
\ObjectDefineEnvargsCheckName{#1}{#3}% |
| 856 |
}{\ifstrequal{#2}{s}{% |
| 857 |
\ifstrequal{#1}{arg}{% |
| 858 |
\ObjectDefineEnvargsAuto{{#3}}% |
| 859 |
}{\ifstrequal{#1}{args}{% |
| 860 |
\ObjectDefineEnvargsAuto{#3}% |
| 861 |
}{% |
| 862 |
\let\ObjectProcessArgs@do@after=\@secondoftwo |
| 863 |
}}% |
| 864 |
}{% |
| 865 |
\let\ObjectProcessArgs@do@after=\@secondoftwo |
| 866 |
}}}% |
| 867 |
\ObjectProcessArgs@do@after |
| 868 |
} |
| 869 |
\newcommand{\ObjectDefineEnvargsCheckName}[2]{% #1: env name, #2: arguments |
| 870 |
\ifobject@directkeys |
| 871 |
\pgfkeysgetvalue{\@object@envkey}{\esf@tmp@env}% |
| 872 |
\ifdefvoid{\esf@tmp@env}{% |
| 873 |
}{\ifdefstring{\esf@tmp@env}{#1}{% |
| 874 |
}{% |
| 875 |
\ifobject@warnotherenv |
| 876 |
\PackageWarning{easyfloats}{Defining 'arg(s)' for #1 but 'env=\esf@tmp@env'}% |
| 877 |
\fi |
| 878 |
}}% |
| 879 |
\fi |
| 880 |
\IfEnvironmentExists{#1} |
| 881 |
{\ObjectDefineEnvargs{#1}{#2}} |
| 882 |
{\PackageError{easyfloats}{Environment #1 for which you set 'arg(s)' does not exist}{}}% |
| 883 |
} |
| 884 |
\newcommand{\ObjectDefineEnvargsAuto}[1]{% #1: arguments |
| 885 |
\pgfkeysgetvalue{\@object@envkey}{\esf@tmp@env}% |
| 886 |
\ifx \esf@tmp@env \@empty |
| 887 |
\PackageError{easyfloats}{'env' for 'arg(s)' is not defined}{}% |
| 888 |
\else |
| 889 |
\ObjectDefineEnvargs{\esf@tmp@env}{#1}% |
| 890 |
\fi |
| 891 |
} |
| 892 |
\newcommand{\ObjectDefineEnvargs}[2]{% #1: env name, #2: arguments |
| 893 |
\ObjectProcessArgs@csdef{object@#1 env@args}{#2}% |
| 894 |
} |
| 895 |
|
| 896 |
|
| 897 |
\newcommand{\ObjectAppendEnvargs}[1]{% #1: macro |
| 898 |
\ifcsname object@\pgfkeysvalueof{\@object@envkey} env@args\endcsname |
| 899 |
\eappto#1{\csexpandonce{object@\pgfkeysvalueof{\@object@envkey} env@args}}% |
| 900 |
\fi |
| 901 |
} |
| 902 |
|
| 903 |
|
| 904 |
% ---------- object environment ---------- |
| 905 |
|
| 906 |
\newcommand{\object@head}{} |
| 907 |
\newcommand{\object@foot}{} |
| 908 |
\newcommand{\object@restorestandardfloats}{} |
| 909 |
|
| 910 |
\newcommand{\object@label}[1]{% |
| 911 |
\pgfkeys{/object/label={#1}}% |
| 912 |
}% |
| 913 |
\newcommand{\object@caption}[2][\pgfkeysnovalue]{% |
| 914 |
\pgfkeys{/object/caption={#2}}% |
| 915 |
\ifx \pgfkeysnovalue #1\relax |
| 916 |
\pgfkeys{/object/list caption={#2}}% |
| 917 |
\else |
| 918 |
\pgfkeys{/object/list caption={#1}}% |
| 919 |
\fi |
| 920 |
} |
| 921 |
\newcommand{\object@longtable@label}[1]{% |
| 922 |
\ObjectDefineEnvargs{longtable}{\label{#1}}% |
| 923 |
}% |
| 924 |
\newcommand{\object@longtable@caption}[2][\pgfkeysnovalue]{% |
| 925 |
\ifx \pgfkeysnovalue #1\relax |
| 926 |
\ObjectDefineEnvargs{longtable}{\caption{#2}}% |
| 927 |
\else |
| 928 |
\ObjectDefineEnvargs{longtable}{\caption[#1]{#2}}% |
| 929 |
\fi |
| 930 |
\def\object@longtable@caption@sep{\ObjectDefineEnvargs{longtable}{\\}}% |
| 931 |
} |
| 932 |
|
| 933 |
\newtoks\object@last@arg |
| 934 |
\newenvironment{object}[1]{% #1: options |
| 935 |
\if@inobject |
| 936 |
\PackageError{easyfloats}{object environment may not be nested}{Did you mean to use the subobject environment instead?}% |
| 937 |
\fi |
| 938 |
\@inobjecttrue |
| 939 |
\object@last@arg={#1}% |
| 940 |
% |
| 941 |
\object@restorestandardfloats |
| 942 |
% |
| 943 |
\object@hook |
| 944 |
\ifobject@isgraphic |
| 945 |
\object@graphic@hook |
| 946 |
\global\object@isgraphicfalse |
| 947 |
\fi |
| 948 |
% |
| 949 |
% ---------- options --------- |
| 950 |
% |
| 951 |
\pgfqkeys{/object}{% |
| 952 |
#1, |
| 953 |
% |
| 954 |
% ------- mandatory ------- |
| 955 |
type/.esf@mandatory=It should be the name of a floating environment like figure or table, |
| 956 |
float style/.esf@mandatory={It should be one of plain, plaintop, ruled or boxed. See float package}, |
| 957 |
env/.esf@mandatory=It should be the name of an environment like tabular or empty, |
| 958 |
}% |
| 959 |
% |
| 960 |
% ------- contains subobjects ------- |
| 961 |
\if@containssubobjects |
| 962 |
\pgfkeysgetvalue{/object/env}{\esf@tmp@env}% |
| 963 |
\ifx \esf@tmp@env \@empty |
| 964 |
\else |
| 965 |
\pgfkeys{/subobject/env/.expand once=\esf@tmp@env}% |
| 966 |
\pgfkeyssetvalue{/object/env}{}% |
| 967 |
\fi |
| 968 |
\fi |
| 969 |
% |
| 970 |
% ---------- prepare --------- |
| 971 |
% |
| 972 |
\pgfkeysgetvalue{/object/env}{\esf@tmp@env}% |
| 973 |
\ifdefstring\esf@tmp@env{longtable}{% |
| 974 |
\object@longtable@prepare |
| 975 |
}{% |
| 976 |
\esf@ifpgfkeyhasvalue{/object/first head}{% |
| 977 |
\pgfkeysgetvalue{/object/first head}{\object@head}% |
| 978 |
}{% |
| 979 |
\pgfkeysgetvalue{/object/head}{\object@head}% |
| 980 |
}% |
| 981 |
\esf@ifpgfkeyhasvalue{/object/last foot}{% |
| 982 |
\pgfkeysgetvalue{/object/last foot}{\object@foot}% |
| 983 |
}{% |
| 984 |
\pgfkeysgetvalue{/object/foot}{\object@foot}% |
| 985 |
}% |
| 986 |
}% |
| 987 |
% |
| 988 |
\pgfkeysgetvalue{/object/type}{\esf@tmp@type}% |
| 989 |
\ifx\esf@tmp@type\@empty |
| 990 |
\let\object@floatenv@begin=\relax |
| 991 |
\let\object@floatenv@end=\relax |
| 992 |
\else |
| 993 |
\pgfkeysgetvalue{/object/float style}{\esf@tmp@floatstyle}% |
| 994 |
\ifx \esf@tmp@floatstyle \@empty |
| 995 |
\else |
| 996 |
\floatstyle{\esf@tmp@floatstyle}% |
| 997 |
\restylefloat{\esf@tmp@type}% |
| 998 |
\fi |
| 999 |
\edef\object@floatenv@begin{\expandonce{\csname\esf@tmp@type\endcsname}}% |
| 1000 |
\edef\object@floatenv@end{\expandonce{\csname end\esf@tmp@type\endcsname}}% |
| 1001 |
\def\esf@text@I{I}% |
| 1002 |
\pgfkeysgetvalue{/object/placement}{\esf@tmp@placement}% |
| 1003 |
\ifx \esf@tmp@placement \@empty |
| 1004 |
% do nothing |
| 1005 |
\else\ifx \esf@tmp@placement \esf@text@I |
| 1006 |
% I am using placement H with two changes: |
| 1007 |
% - redefined \columnwidth to \linewidth |
| 1008 |
% - added \leavevmode before setting the float in order to get correct indentation |
| 1009 |
% see texdoc float |
| 1010 |
\preto\object@floatenv@begin{% |
| 1011 |
\columnwidth = \linewidth |
| 1012 |
\let \float@endH = \esf@float@endI |
| 1013 |
}% |
| 1014 |
\appto\object@floatenv@begin{[H]}% |
| 1015 |
\else |
| 1016 |
\eappto\object@floatenv@begin{[\esf@tmp@placement]}% |
| 1017 |
\fi \fi |
| 1018 |
\fi |
| 1019 |
% |
| 1020 |
\pgfkeysgetvalue{/object/details}{\object@details}% |
| 1021 |
\ifx \object@details \@empty |
| 1022 |
% do nothing |
| 1023 |
\else |
| 1024 |
\preto\object@details{\pgfkeysvalueof{/object/details sep}}% |
| 1025 |
\fi |
| 1026 |
% |
| 1027 |
\pgfkeysgetvalue{/object/env}{\esf@tmp@env}% |
| 1028 |
\ifx \esf@tmp@env \@empty |
| 1029 |
% if you change this remember to update \object@lookahead@beforesubobject |
| 1030 |
\def\object@innerenv@begin{\object@head\ignorespaces}% |
| 1031 |
\def\object@innerenv@end{\unskip\object@foot}% |
| 1032 |
\else |
| 1033 |
\edef\object@innerenv@begin{\expandonce{\csname\esf@tmp@env\endcsname}}% |
| 1034 |
\edef\object@innerenv@end{\expandonce{\csname end\esf@tmp@env\endcsname}}% |
| 1035 |
\ObjectAppendEnvargs{\object@innerenv@begin}% |
| 1036 |
\eappto\object@innerenv@begin{\expandonce{\object@head}}% |
| 1037 |
\epreto\object@innerenv@end{\expandonce{\object@foot}}% |
| 1038 |
\let\object@lookahead@begin=\object@innerenv@begin |
| 1039 |
\ifobject@showenv |
| 1040 |
\show\object@innerenv@begin |
| 1041 |
\fi |
| 1042 |
\let\object@innerenv@begin=\object@lookahead |
| 1043 |
\fi |
| 1044 |
% |
| 1045 |
\global \@firstsubobjecttrue |
| 1046 |
% |
| 1047 |
% ---------- execute --------- |
| 1048 |
% |
| 1049 |
\object@floatenv@begin |
| 1050 |
\preto\par{\global\@firstsubobjecttrue}% |
| 1051 |
\let\esf@original@label=\label |
| 1052 |
\let\esf@original@caption=\caption |
| 1053 |
\let\label=\object@label |
| 1054 |
\let\caption=\object@caption |
| 1055 |
\pgfkeysvalueof{/object/exec}% |
| 1056 |
\pgfkeysvalueof{/object/align}% |
| 1057 |
\object@innerenv@begin |
| 1058 |
}{% |
| 1059 |
\object@innerenv@end |
| 1060 |
\if@containssubobjects |
| 1061 |
\if@firstsubobject |
| 1062 |
\PackageWarning{easyfloats}{'contains subobjects' is true but the object does not contain any subobjects.}% |
| 1063 |
\fi |
| 1064 |
\fi |
| 1065 |
\object@endhook |
| 1066 |
\let\label=\esf@original@label |
| 1067 |
\let\caption=\esf@original@caption |
| 1068 |
\object@processCaptionAndLabel |
| 1069 |
\object@floatenv@end |
| 1070 |
} |
| 1071 |
|
| 1072 |
% copied from texdoc float, page 8, the definition of \float@endH |
| 1073 |
\newcommand\esf@float@endI{% |
| 1074 |
\@endfloatbox |
| 1075 |
\vskip\intextsep |
| 1076 |
\if@flstyle |
| 1077 |
\setbox\@currbox\float@makebox\columnwidth |
| 1078 |
\fi |
| 1079 |
\leavevmode% added by me |
| 1080 |
\box\@currbox |
| 1081 |
\vskip\intextsep\relax |
| 1082 |
} |
| 1083 |
|
| 1084 |
\newcommand{\object@processCaptionAndLabel}{% |
| 1085 |
% position of caption (above/below) is handled by float package (see float style) |
| 1086 |
\esf@ifpgfkeyhasvalue{/object/caption}{% |
| 1087 |
\esf@ifpgfkeyhasvalue{/object/list caption}% |
| 1088 |
{\pgfkeysgetvalue{/object/list caption}{\esf@tmp@caption@short}}% |
| 1089 |
{\pgfkeysgetvalue{/object/caption}{\esf@tmp@caption@short}}% |
| 1090 |
\ifx \esf@tmp@caption@short \@empty |
| 1091 |
\else |
| 1092 |
\edef \esf@tmp@caption@short {{\expandonce{\esf@tmp@caption@short}}}% |
| 1093 |
\fi |
| 1094 |
\expandafter\caption\expandafter[\esf@tmp@caption@short]{\pgfkeysvalueof{/object/caption}\object@details}% |
| 1095 |
}{% |
| 1096 |
\ifobject@warnnocaption |
| 1097 |
\PackageWarning{easyfloats}{% |
| 1098 |
No caption given. |
| 1099 |
This object will not show up in the list of figures/tables/whatsoever. |
| 1100 |
If captions for subfigures are given they will be placed incorrectly in the list of figures. |
| 1101 |
If you are using hyperref links to this figure may turn out wrong. |
| 1102 |
This warning occured% |
| 1103 |
}% |
| 1104 |
\fi |
| 1105 |
% Generate an anchor for a \label. |
| 1106 |
% \phantomcaption is defined in the caption-package but |
| 1107 |
% documented in subcaption for the subfigure environment. |
| 1108 |
% It appears that here (without a subfigure but within a figure) |
| 1109 |
% references are output correctly but links created by hyperref |
| 1110 |
% which should be pointing to this object point to the previous caption. |
| 1111 |
\phantomcaption |
| 1112 |
}% |
| 1113 |
% ------- label ------- |
| 1114 |
\esf@ifpgfkeyhasvalue{/object/label}{% |
| 1115 |
\label{\pgfkeysvalueof{/object/label}}% |
| 1116 |
}{% |
| 1117 |
\ifobject@warnnolabel |
| 1118 |
\PackageWarning{easyfloats}{% |
| 1119 |
No label given. |
| 1120 |
Without a label you cannot reference this object. |
| 1121 |
This warning occured% |
| 1122 |
}% |
| 1123 |
\fi |
| 1124 |
}% |
| 1125 |
\esf@ifpgfkeyhasvalue{/object/add label}% |
| 1126 |
{\label{\pgfkeysvalueof{/object/add label}}}% |
| 1127 |
{}% |
| 1128 |
} |
| 1129 |
|
| 1130 |
\newcommand{\object@longtable@prepare}{% |
| 1131 |
\pgfkeyssetvalue{/object/type}{}% |
| 1132 |
\pgfkeyssetvalue{/object/align}{}% |
| 1133 |
\let\object@label=\label |
| 1134 |
\let\object@caption=\caption |
| 1135 |
\let\ObjectProcessArgs@csdef=\csappto |
| 1136 |
% |
| 1137 |
\let\esf@original@label=\label |
| 1138 |
\let\esf@original@caption=\caption |
| 1139 |
\let\label=\object@longtable@label |
| 1140 |
\let\caption=\object@longtable@caption |
| 1141 |
\let\object@longtable@caption@sep=\relax |
| 1142 |
% it seems possible to have a label without a caption in a longtable |
| 1143 |
% which actually makes sense because \caption may appear several times |
| 1144 |
% so it makes sense to increase the counter somewhere else. |
| 1145 |
\let\phantomcaption=\relax |
| 1146 |
\object@processCaptionAndLabel |
| 1147 |
\let\object@processCaptionAndLabel=\relax |
| 1148 |
\object@longtable@caption@sep |
| 1149 |
\let\label=\esf@original@label |
| 1150 |
\let\caption=\esf@original@caption |
| 1151 |
% |
| 1152 |
\esf@ifpgfkeyhasvalue{/object/first head}{% |
| 1153 |
\ObjectDefineEnvargs{longtable}{\pgfkeysvalueof{/object/first head}}% |
| 1154 |
}{% |
| 1155 |
\ObjectDefineEnvargs{longtable}{\pgfkeysvalueof{/object/head}}% |
| 1156 |
}% |
| 1157 |
\ObjectDefineEnvargs{longtable}{% |
| 1158 |
\endfirsthead |
| 1159 |
\pgfkeysvalueof{/object/head}% |
| 1160 |
\endhead |
| 1161 |
\pgfkeysvalueof{/object/foot}% |
| 1162 |
\endfoot |
| 1163 |
}% |
| 1164 |
\esf@ifpgfkeyhasvalue{/object/last foot}{% |
| 1165 |
\ObjectDefineEnvargs{longtable}{\pgfkeysvalueof{/object/last foot}}% |
| 1166 |
}{% |
| 1167 |
\ObjectDefineEnvargs{longtable}{\pgfkeysvalueof{/object/foot}}% |
| 1168 |
}% |
| 1169 |
\ObjectDefineEnvargs{longtable}{% |
| 1170 |
\endlastfoot |
| 1171 |
}% |
| 1172 |
} |
| 1173 |
|
| 1174 |
|
| 1175 |
% ---------- split object environment ---------- |
| 1176 |
|
| 1177 |
\newcommand{\splitobject}{% |
| 1178 |
% does not work inside of \begingroup ... \endgroup |
| 1179 |
% I cannot use anything not expandable here in case a table foot needs to be inserted |
| 1180 |
\expanded{% |
| 1181 |
\noexpand\end{\@currenvir}% |
| 1182 |
\noexpand\begin{\@currenvir}{\the\object@last@arg, warn no label=false, list caption=, exec+={\unexpanded{% |
| 1183 |
\pgfkeyssetvalue{/object/label}{\pgfkeysnovalue}% |
| 1184 |
\ContinuedFloat |
| 1185 |
}}}% |
| 1186 |
}% |
| 1187 |
} |
| 1188 |
|
| 1189 |
|
| 1190 |
% ---------- lookahead for subobjects ---------- |
| 1191 |
|
| 1192 |
\newcommand{\object@lookahead@nosubobject}{% |
| 1193 |
\object@lookahead@begin |
| 1194 |
} |
| 1195 |
\newcommand{\object@lookahead@beforesubobject}{% |
| 1196 |
\PackageWarning{easyfloats}{It seems you have forgotten to specify 'contains subobjects'. I am using the value of 'env' for the subobjects instead of for \@currenvir.}% |
| 1197 |
\pgfkeysgetvalue{/object/env}{\esf@tmp@env}% |
| 1198 |
\pgfkeys{/subobject/env/.expand once=\esf@tmp@env}% |
| 1199 |
\pgfkeyssetvalue{/object/env}{}% |
| 1200 |
\let\object@innerenv@end=\unskip |
| 1201 |
%\ignorespaces unnecessary because I just checked |
| 1202 |
%that the next token is the start of a subobject |
| 1203 |
} |
| 1204 |
|
| 1205 |
\newcommand{\object@lookahead}{% |
| 1206 |
\futurelet \next \object@lookahead@checknext |
| 1207 |
} |
| 1208 |
\newcommand{\object@lookahead@checknext}{% |
| 1209 |
\ifx \next \@implicitspace |
| 1210 |
\let\object@lookahead@gobble=\@gobblespace |
| 1211 |
\let\object@lookahead@do=\object@lookahead |
| 1212 |
\else\ifx \next \par |
| 1213 |
\let\object@lookahead@gobble=\@gobble |
| 1214 |
\let\object@lookahead@do=\object@lookahead |
| 1215 |
\else\ifx \next \begin |
| 1216 |
\let\object@lookahead@gobble=\@empty |
| 1217 |
\let\object@lookahead@do=\object@lookahead@checkbegin |
| 1218 |
\else\ifx \next \includegraphicsubobject |
| 1219 |
\let\object@lookahead@gobble=\@empty |
| 1220 |
\let\object@lookahead@do=\object@lookahead@beforesubobject |
| 1221 |
\else |
| 1222 |
\let\object@lookahead@gobble=\@empty |
| 1223 |
\let\object@lookahead@do=\object@lookahead@nosubobject |
| 1224 |
\fi \fi \fi \fi |
| 1225 |
\expandafter \object@lookahead@do \object@lookahead@gobble |
| 1226 |
} |
| 1227 |
\newcommand{\object@lookahead@checkbegin}[2]{% #1: \begin, #2: environment name |
| 1228 |
\ifstrequal{#2}{subobject} |
| 1229 |
\object@lookahead@beforesubobject |
| 1230 |
\object@lookahead@nosubobject |
| 1231 |
#1{#2}% |
| 1232 |
} |
| 1233 |
|
| 1234 |
\@firstofone{\let\@implicitspace= } |
| 1235 |
\@firstofone{\def\@gobblespace} {} |
| 1236 |
|
| 1237 |
|
| 1238 |
% ========== object styles ========== |
| 1239 |
|
| 1240 |
\newcommand{\IfObjectStyleExists}[1]{% #1: style name or group name, #2: then block, #3: else block |
| 1241 |
\ifcsmacro{object@style@#1}% |
| 1242 |
} |
| 1243 |
\newcommand{\IfObjectStyleNotGroup}[1]{% #1: style name, #2: then block, #3: else block |
| 1244 |
\IfObjectStyleExists{#1} |
| 1245 |
{\edef\esf@tmp@do{\ifcsstring{object@stylegroup@#1}{{#1}}}\esf@tmp@do}% |
| 1246 |
\@secondoftwo |
| 1247 |
} |
| 1248 |
|
| 1249 |
\newcommand{\objectstyle@init}[1]{% #1: style name or group name |
| 1250 |
\expandafter \newcommand \csname object@style@#1\endcsname{/utils/exec=\object@directkeysfalse}% |
| 1251 |
\expandafter \newcommand \csname object@stylegroup@#1\endcsname{}% |
| 1252 |
} |
| 1253 |
|
| 1254 |
\newrobustcmd{\AddObjectStyleToGroup}[2]{% #1: group name, #2: style name |
| 1255 |
\IfObjectStyleExists{#1}{% |
| 1256 |
\IfObjectStyleNotGroup{#2}{% |
| 1257 |
\AddObjectStyleToGroup@do{#1}{#2}% |
| 1258 |
}{% |
| 1259 |
\PackageError{easyfloats}{Undefined object style: #2}{In this case you cannot use a style group instead of a group.}% |
| 1260 |
}}{% |
| 1261 |
\PackageError{easyfloats}{Undefined object style group: #1}{}% |
| 1262 |
}% |
| 1263 |
} |
| 1264 |
\newrobustcmd{\AddObjectStyleToGroup@do}[2]{% #1: group name, #2: style name |
| 1265 |
\expandafter\eappto\csname object@stylegroup@#1\endcsname{{#2}}% |
| 1266 |
} |
| 1267 |
\newrobustcmd{\ShowObjectStylesInGroup}[1]{% |
| 1268 |
\expandafter\show\csname object@stylegroup@#1\endcsname |
| 1269 |
} |
| 1270 |
|
| 1271 |
\newcommand{\AppendOptionToObjectStyleGroups}[3]{% #1: list of style groups, #2: key, #3: value |
| 1272 |
\CheckObjectOption{#2}{#3}{% |
| 1273 |
\@for\esf@aotosg@group:=#1\do{% |
| 1274 |
\GobbleLeadingSpaceIn\esf@aotosg@group |
| 1275 |
\AppendOptionToObjectStyleGroup\esf@aotosg@group{#2}{#3}% |
| 1276 |
}% |
| 1277 |
}% |
| 1278 |
} |
| 1279 |
\newcommand{\AppendOptionToObjectStyleGroup}[3]{% #1: style group, #2: key, #3: value |
| 1280 |
\IfObjectStyleExists{#1}{% |
| 1281 |
\expandafter \let \expandafter \esf@tmp@listofstyles \csname object@stylegroup@#1\endcsname |
| 1282 |
\def\esf@tmp@loop{\@tfor\esf@aotosg@style:=}% |
| 1283 |
\expandafter\esf@tmp@loop\esf@tmp@listofstyles \do {% |
| 1284 |
\AppendOptionToObjectStyle\esf@aotosg@style{#2}{#3}% |
| 1285 |
}% |
| 1286 |
}{% |
| 1287 |
\PackageError{easyfloats}{Undefined object style: '#1'}{}% |
| 1288 |
}% |
| 1289 |
} |
| 1290 |
\newcommand{\AppendOptionToObjectStyle}[3]{% #1: style, #2: key, #3: value |
| 1291 |
\expandafter\AppendToOptionsList\csname object@style@#1\endcsname{#2}{#3}% |
| 1292 |
} |
| 1293 |
\newrobustcmd{\ShowObjectStyleOptions}[1]{% |
| 1294 |
\IfObjectStyleNotGroup{#1} |
| 1295 |
{\expandafter\show\csname object@style@#1\endcsname}% |
| 1296 |
{\PackageError{easyfloats}{Undefined object style: '#1'}{}}% |
| 1297 |
} |
| 1298 |
|
| 1299 |
|
| 1300 |
% ---------- style groups ---------- |
| 1301 |
|
| 1302 |
\newrobustcmd{\NewObjectStyleGroup}[2]{% #1: group name, #2: list of style names |
| 1303 |
\IfObjectStyleExists{#1}{% |
| 1304 |
\PackageError{easyfloats}{Style or style group with the name '#1' exists already}{}% |
| 1305 |
}{% |
| 1306 |
\objectstyle@init{#1}% |
| 1307 |
\@for\esf@nosg@style:=#2\do{% |
| 1308 |
\GobbleLeadingSpaceIn\esf@nosg@style |
| 1309 |
\AddObjectStyleToGroup{#1}{\esf@nosg@style}% |
| 1310 |
}% |
| 1311 |
}% |
| 1312 |
} |
| 1313 |
|
| 1314 |
% ---------- object styles ---------- |
| 1315 |
|
| 1316 |
\newrobustcmd{\NewObjectStyle}[2]{% #1: name, #2: options |
| 1317 |
\IfObjectStyleExists{#1}{% |
| 1318 |
\PackageError{easyfloats}{Style or style group with the name '#1' exists already}{}% |
| 1319 |
}{% |
| 1320 |
\objectstyle@init{#1}% |
| 1321 |
\AddObjectStyleToGroup@do{#1}{#1}% |
| 1322 |
%hack into \objectset[#1] to retrieve the value of type |
| 1323 |
\pgfkeyssetvalue{/object.check/type}{\pgfkeysnovalue}% |
| 1324 |
\objectset[#1]{#2}% |
| 1325 |
\esf@ifpgfkeyhasvalue{/object.check/type}{% |
| 1326 |
\edef\@do{\noexpand\DeprecateStandardFloatObject{\pgfkeysvalueof{/object.check/type}}{#1object}}% |
| 1327 |
\@do |
| 1328 |
}{% |
| 1329 |
\PackageError{easyfloats}{Missing required key 'type'}% |
| 1330 |
}% |
| 1331 |
% |
| 1332 |
\AddObjectStyleToGroup{all}{#1}% |
| 1333 |
% |
| 1334 |
\newenvironment{#1object}[1]{% #1: options |
| 1335 |
\object{% |
| 1336 |
.esf@also from/.expand once=\csname object@style@#1\endcsname, |
| 1337 |
/utils/exec=\object@directkeystrue, |
| 1338 |
##1, |
| 1339 |
}% |
| 1340 |
}{% |
| 1341 |
\endobject |
| 1342 |
}% |
| 1343 |
\pgfkeysgetvalue{/object.check/type}{\NewObjectStyle@type}% |
| 1344 |
\edef\@do{\noexpand\AfterPreamble{% |
| 1345 |
\noexpand\IfEnvironmentExists{sub\NewObjectStyle@type}{% |
| 1346 |
\noexpand\PackageInfo{easyfloats}{environment 'sub\NewObjectStyle@type' exists already}% |
| 1347 |
}{\NewObjectStyle@IfCaptionNewEnough{% |
| 1348 |
\noexpand\PackageInfo{easyfloats}{declaring new caption subtype 'sub\NewObjectStyle@type'}% |
| 1349 |
\noexpand\DeclareCaptionSubType{\NewObjectStyle@type}% |
| 1350 |
}{% |
| 1351 |
\noexpand\PackageWarning{easyfloats}{The caption package is too old for me to define the subtype automatically. Please insert `\string\AtBeginDocument{\string\DeclareCaptionSubType{\NewObjectStyle@type}}' before loading this package}% |
| 1352 |
}% |
| 1353 |
}% |
| 1354 |
}}\@do |
| 1355 |
}% |
| 1356 |
} |
| 1357 |
|
| 1358 |
\@ifpackagelater{caption}{2020/08/30} |
| 1359 |
{\let\NewObjectStyle@IfCaptionNewEnough=\@firstoftwo} |
| 1360 |
{\let\NewObjectStyle@IfCaptionNewEnough=\@secondoftwo} |
| 1361 |
|
| 1362 |
|
| 1363 |
\newcommand{\DeprecateStandardFloatObject}[2]{% #1: float environment, #2: alternative object environment |
| 1364 |
\ifesf@warnstandardfloats |
| 1365 |
\ifcsmacro{esf@#1@alternatives}{% |
| 1366 |
\expandafter \appto \csname esf@#1@alternatives\endcsname{ or #2}% |
| 1367 |
}{% |
| 1368 |
\AtBeginDocument{% |
| 1369 |
\csletcs{esf@original#1}{#1}% |
| 1370 |
\expandafter \preto\csname#1\endcsname{\PackageWarning{easyfloats}{In order to profit from the advantages of the easyfloats package please use \csname esf@#1@alternatives\endcsname\space instead}}% |
| 1371 |
}% |
| 1372 |
\expandafter \def \csname esf@#1@alternatives\endcsname{#2}% |
| 1373 |
\ifesf@loadgraphics |
| 1374 |
\ifstrequal{#1}{table}{% |
| 1375 |
% do nothing |
| 1376 |
}{% |
| 1377 |
\expandafter \appto \csname esf@#1@alternatives\endcsname{ or \string\includegraphicobject}% |
| 1378 |
}% |
| 1379 |
\fi |
| 1380 |
\eappto\object@restorestandardfloats{\let\expandonce{\csname #1\endcsname}=\expandonce{\csname esf@original#1\endcsname}}% |
| 1381 |
}% |
| 1382 |
\fi |
| 1383 |
} |
| 1384 |
|
| 1385 |
|
| 1386 |
% ---------- default styles ---------- |
| 1387 |
|
| 1388 |
\NewObjectStyleGroup{all}{} |
| 1389 |
|
| 1390 |
\NewObjectStyle{table}{type=table} |
| 1391 |
\NewObjectStyle{figure}{type=figure} |
| 1392 |
|
| 1393 |
|
| 1394 |
% ========== include graphic object ========== |
| 1395 |
|
| 1396 |
\newif\ifgraphicobject@autocaption |
| 1397 |
\newif\ifgraphicobject@autolabel |
| 1398 |
\newif\ifgraphicobject@autocaption@strippath |
| 1399 |
\newif\ifgraphicobject@autolabel@strippath |
| 1400 |
\newif\ifgraphicobject@warnenv |
| 1401 |
\newif\ifgraphicobject@noenv |
| 1402 |
|
| 1403 |
\ifesf@loadgraphics |
| 1404 |
|
| 1405 |
\newcommand\object@graphic@env{figureobject} |
| 1406 |
\newcommand\object@graphic@path{/object} |
| 1407 |
\newcommand\object@graphic@options{} |
| 1408 |
|
| 1409 |
\newrobustcmd{\graphicobjectstyle}[1]{% |
| 1410 |
\IfObjectStyleNotGroup{#1}{% |
| 1411 |
\def\object@graphic@env{#1object}% |
| 1412 |
}{% |
| 1413 |
\PackageError{easyfloats}{Undefined object style: '#1'}{}% |
| 1414 |
}% |
| 1415 |
} |
| 1416 |
|
| 1417 |
% do not confuse this with \CheckObjectGraphicOption |
| 1418 |
% this corresponds to \CheckObjectOption |
| 1419 |
\newcommand{\CheckGraphicobjectOption}[2]{% #1: key, #2: value, #3: executed if valid |
| 1420 |
% if #3 is *not* executed an error message is printed |
| 1421 |
\let\CheckGraphicobjectOption@handleArg=\@gobble |
| 1422 |
\esf@ifpgfkeyexists{/graphicobject/#1}{% |
| 1423 |
\esf@ifpgfkeyrequiresvalue{/graphicobject/#1}{% |
| 1424 |
\ifx \pgfkeysnovalue #2\relax |
| 1425 |
\PackageError{easyfloats}{The key '#1' requires a value. I am going to ignore this key}{}% |
| 1426 |
\else |
| 1427 |
\let\CheckGraphicobjectOption@handleArg=\@firstofone |
| 1428 |
\fi |
| 1429 |
}{% |
| 1430 |
\let\CheckGraphicobjectOption@handleArg=\@firstofone |
| 1431 |
}% |
| 1432 |
}{\esf@ifkeyvalkeyexists{Gin}{#1}{% |
| 1433 |
\esf@ifkeyvalkeyrequiresvalue{Gin}{#1}{% |
| 1434 |
\ifx \pgfkeysnovalue #2\relax |
| 1435 |
\PackageError{easyfloats}{The key '#1' requires a value. I am going to ignore this key}{}% |
| 1436 |
\else |
| 1437 |
\let\CheckGraphicobjectOption@handleArg=\@firstofone |
| 1438 |
\fi |
| 1439 |
}{% |
| 1440 |
\let\CheckGraphicobjectOption@handleArg=\@firstofone |
| 1441 |
}% |
| 1442 |
}{% |
| 1443 |
\PackageError{easyfloats}{'#1' is not a valid graphic option key} |
| 1444 |
{If you intended to use a graphbox option please make sure that you loaded this package with the option 'graphbox'.}% |
| 1445 |
}}% |
| 1446 |
\CheckGraphicobjectOption@handleArg |
| 1447 |
} |
| 1448 |
|
| 1449 |
\newcommand{\AppendGraphicobjectOption}[2]{% #1: key, #2: value |
| 1450 |
\AppendToOptionsList{\object@graphic@options}{#1}{#2}% |
| 1451 |
} |
| 1452 |
\newcommand{\includegraphicobject@SetGraphicobjectOption}[2]{% #1: key, #2: value |
| 1453 |
\pgfkeysalso{#1={#2}}% |
| 1454 |
} |
| 1455 |
|
| 1456 |
% available options |
| 1457 |
\pgfqkeys{/graphicobject}{% |
| 1458 |
auto caption/.is if=graphicobject@autocaption, |
| 1459 |
auto caption=true, |
| 1460 |
% |
| 1461 |
auto label/.is if=graphicobject@autolabel, |
| 1462 |
auto label=true, |
| 1463 |
% |
| 1464 |
auto caption strip path/.is if=graphicobject@autocaption@strippath, |
| 1465 |
auto caption strip path=false, |
| 1466 |
% |
| 1467 |
auto label strip path/.is if=graphicobject@autolabel@strippath, |
| 1468 |
auto label strip path=false, |
| 1469 |
% |
| 1470 |
auto label prefix/.initial=, |
| 1471 |
auto label prefix/.value required, |
| 1472 |
% |
| 1473 |
warn env/.is if=graphicobject@warnenv, |
| 1474 |
warn env=true, |
| 1475 |
% |
| 1476 |
no env/.is if=graphicobject@noenv, |
| 1477 |
no env=true, |
| 1478 |
% |
| 1479 |
before graphic/.initial=, |
| 1480 |
before graphic/.value required, |
| 1481 |
% |
| 1482 |
after graphic/.initial=, |
| 1483 |
after graphic/.value required, |
| 1484 |
} |
| 1485 |
|
| 1486 |
\newrobustcmd{\includegraphicobject}{% [#1: graphicstyle], [#2: options], #3: graphic filename without extension |
| 1487 |
\begingroup |
| 1488 |
\@ifnextchar [% |
| 1489 |
\includegraphicobject@firstarg |
| 1490 |
\includegraphicobject@parseoptions |
| 1491 |
} |
| 1492 |
\def\includegraphicobject@firstarg[#1]{% |
| 1493 |
\@ifnextchar [% |
| 1494 |
{% |
| 1495 |
\graphicobjectstyle{#1}% |
| 1496 |
\includegraphicobject@parseoptions |
| 1497 |
}% |
| 1498 |
{% |
| 1499 |
\includegraphicobject@parseoptions[#1]% |
| 1500 |
}% |
| 1501 |
} |
| 1502 |
|
| 1503 |
\newcommand{\includegraphicobject@parseoptions}{% [#1: options], #2: graphic filename without extension |
| 1504 |
% expanding \object@graphic@env before is important for subcaptionbox |
| 1505 |
% otherwise I get the error \begin{subobject} ended by \end{subobject} |
| 1506 |
\@ifnextchar [ |
| 1507 |
{\expandafter\includegraphicobject@do\expandafter{\object@graphic@env}} |
| 1508 |
{\expandafter\includegraphicobject@do\expandafter{\object@graphic@env}[]}% |
| 1509 |
} |
| 1510 |
\def\includegraphicobject@do#1[#2]#3{% #1: environment name, #2: options, #3: graphic filename without extension |
| 1511 |
\global\object@isgraphictrue |
| 1512 |
\begin{#1}{% |
| 1513 |
/utils/exec=\def\object@graphic@options@tmp{}% |
| 1514 |
\let\AppendGraphicobjectOption\includegraphicobject@SetGraphicobjectOption, |
| 1515 |
.unknown/.code={% |
| 1516 |
\esf@ifkeyvalkeyexists{Gin}{\pgfkeyscurrentname}{% |
| 1517 |
\AppendToOptionsList{\object@graphic@options@tmp}{\pgfkeyscurrentname}{##1}% |
| 1518 |
}{% |
| 1519 |
\let\pgfkeys@searchalso@name=\pgfkeyscurrentname |
| 1520 |
\pgfkeysalso{% |
| 1521 |
/graphicobject/\pgfkeys@searchalso@name={##1}, |
| 1522 |
}% |
| 1523 |
}% |
| 1524 |
}, |
| 1525 |
.esf@also from=\object@graphic@options, |
| 1526 |
#2, |
| 1527 |
/utils/exec= |
| 1528 |
\ifgraphicobject@autocaption |
| 1529 |
\esf@ifpgfkeyhasvalue{\object@graphic@path/caption}{% |
| 1530 |
% do nothing |
| 1531 |
}{% |
| 1532 |
\def\graphicobject@caption{#3}% |
| 1533 |
\PatchUnderscore\graphicobject@caption |
| 1534 |
\ifgraphicobject@autocaption@strippath |
| 1535 |
\protected@edef\graphicobject@caption{\strippath\graphicobject@caption}% |
| 1536 |
\fi |
| 1537 |
\pgfkeyslet{\object@graphic@path/caption}{\graphicobject@caption}% |
| 1538 |
}% |
| 1539 |
\fi |
| 1540 |
\ifgraphicobject@autolabel |
| 1541 |
\esf@ifpgfkeyhasvalue{\object@graphic@path/label}{% |
| 1542 |
% do nothing |
| 1543 |
}{% |
| 1544 |
\def\graphicobject@label{#3}% |
| 1545 |
\ifgraphicobject@autolabel@strippath |
| 1546 |
\protected@edef\graphicobject@label{\strippath\graphicobject@label}% |
| 1547 |
\fi |
| 1548 |
\epreto\graphicobject@label{\pgfkeysvalueof{/graphicobject/auto label prefix}}% |
| 1549 |
\pgfkeyslet{\object@graphic@path/label}{\graphicobject@label}% |
| 1550 |
}% |
| 1551 |
\fi |
| 1552 |
\ifgraphicobject@warnenv |
| 1553 |
\pgfkeysalso{env/.get=\esf@tmp@env}% |
| 1554 |
\ifx \esf@tmp@env \@empty |
| 1555 |
\else |
| 1556 |
\ifdefstring{\object@graphic@env}{subobject} |
| 1557 |
{\edef\esf@tmp@name{\string\includegraphicsubobject}} |
| 1558 |
{\edef\esf@tmp@name{\string\includegraphicobject}}% |
| 1559 |
\ifgraphicobject@noenv |
| 1560 |
\PackageWarning{easyfloats}{I am ignoring 'env=\esf@tmp@env' in \esf@tmp@name}% |
| 1561 |
\else |
| 1562 |
\PackageWarning{easyfloats}{'env=\esf@tmp@env' in \esf@tmp@name. Is that intended?}% |
| 1563 |
\fi |
| 1564 |
\fi |
| 1565 |
\fi |
| 1566 |
\ifgraphicobject@noenv |
| 1567 |
\pgfkeysalso{env=}% |
| 1568 |
\fi |
| 1569 |
, |
| 1570 |
} |
| 1571 |
\pgfkeysvalueof{/graphicobject/before graphic}% |
| 1572 |
\expandafter\includegraphics\expandafter[\object@graphic@options@tmp]{#3}% |
| 1573 |
\pgfkeysvalueof{/graphicobject/after graphic}% |
| 1574 |
\end{#1}% |
| 1575 |
% This command is supposed to insert a floating object which can float somewhere else. |
| 1576 |
% Therefore it should not influence the paragraph indentation of the next paragraph (\@endparenv/\@doendpe). |
| 1577 |
\endgroup |
| 1578 |
\ignorespaces |
| 1579 |
} |
| 1580 |
|
| 1581 |
\newrobustcmd{\includegraphicsubobject}{% |
| 1582 |
\begingroup |
| 1583 |
\def\object@graphic@env{subobject}% |
| 1584 |
\def\object@graphic@path{/subobject}% |
| 1585 |
\includegraphicobject@parseoptions |
| 1586 |
} |
| 1587 |
|
| 1588 |
|
| 1589 |
\fi %\ifesf@loadgraphics |
| 1590 |
|
| 1591 |
|
| 1592 |
% ========== sub object ========== |
| 1593 |
|
| 1594 |
\newif\ifsubobject@warnnolabel |
| 1595 |
\newif\ifsubobject@warnnocaption |
| 1596 |
|
| 1597 |
% available options |
| 1598 |
\pgfqkeys{/subobject}{% |
| 1599 |
% A label for the left/right part of the content |
| 1600 |
label/.initial, |
| 1601 |
label/.value required, |
| 1602 |
% |
| 1603 |
% A caption displayed above or below the sub content |
| 1604 |
% (depending on the float style). |
| 1605 |
% There is *no* dot added automatically behind it. |
| 1606 |
caption/.initial, |
| 1607 |
caption/.value required, |
| 1608 |
% |
| 1609 |
% A caption used in the list of figures/tables/... |
| 1610 |
% for the left/right part of the content. |
| 1611 |
list caption/.initial, |
| 1612 |
list caption/.value required, |
| 1613 |
% |
| 1614 |
% An addition to the caption (at the object only, not in a list) |
| 1615 |
details/.initial=, |
| 1616 |
details/.value required, |
| 1617 |
% |
| 1618 |
details sep/.initial=.\space, |
| 1619 |
details sep/.value required, |
| 1620 |
% |
| 1621 |
% TeX code which is inserted before env |
| 1622 |
exec/.initial=, |
| 1623 |
exec/.value required, |
| 1624 |
exec +/.code=\esf@pgfkeysvalueappend{/subobject/exec}{#1}, |
| 1625 |
exec +/.value required, |
| 1626 |
exec+/.forward to=/subobject/exec +, |
| 1627 |
exec+/.value required, |
| 1628 |
% |
| 1629 |
% The width argument of \subcaptionbox or subfigure. |
| 1630 |
% For \subcaptionbox an empty value is allowed |
| 1631 |
% meaning that the argument is not passed so that |
| 1632 |
% \subcaptionbox takes the width of the content. |
| 1633 |
linewidth/.initial=.5\linewidth, |
| 1634 |
linewidth/.value required, |
| 1635 |
% |
| 1636 |
% Use the \subcaptionbox command. |
| 1637 |
% Aligns the captions. |
| 1638 |
% Does not allow verbatim content. |
| 1639 |
% Is *not* compatible with env=tabularx. |
| 1640 |
subcaptionbox/.code= |
| 1641 |
\let\subobject@begin\subobject@subcaptionbox |
| 1642 |
\let\subobject@end\endsubobject@subcaptionbox, |
| 1643 |
subcaptionbox/.value forbidden, |
| 1644 |
% Use the subfigure/subtable environment. |
| 1645 |
% Requires linewidth. |
| 1646 |
subpage/.code= |
| 1647 |
\let\subobject@begin\subobject@subpage |
| 1648 |
\let\subobject@end\endsubobject@subpage, |
| 1649 |
subpage/.value forbidden, |
| 1650 |
% |
| 1651 |
% ------- subcaptionbox options ------- |
| 1652 |
% Horizontal position of the content in the box. |
| 1653 |
% Allowed values: c, l, r, s, <empty> or any |
| 1654 |
% justification defined with \DeclareCaptionJustification |
| 1655 |
% (see the caption package documentation). |
| 1656 |
% An empty value means that this optional argument is |
| 1657 |
% *not* passed to the \subcaptionbox command. |
| 1658 |
% This option has no effect if linewidth is empty. |
| 1659 |
% I discourage using this option because it destroys |
| 1660 |
% the alignment of (sub)object and (sub)caption. |
| 1661 |
subcaptionbox inner pos/.initial=, |
| 1662 |
subcaptionbox inner pos/.value required, |
| 1663 |
% |
| 1664 |
% ------- subfigure/subtable options ------- |
| 1665 |
% The subfigure/subtable environments are minipages |
| 1666 |
% and take the same arguments. |
| 1667 |
% http://tug.org/texinfohtml/latex2e.html#minipage |
| 1668 |
% |
| 1669 |
% The vertical position of the minipage on the baseline. |
| 1670 |
% Allowed values: c, t, b, auto, auto-inverted, <empty>. |
| 1671 |
% auto means t if the caption is displayed at the top |
| 1672 |
% or b if the caption is displayed at the bottom |
| 1673 |
% so that the captions are aligned if the captions |
| 1674 |
% have the same height. |
| 1675 |
% auto-inverted means b if the caption is displayed at the top |
| 1676 |
% or t if the caption is displayed at the bottom |
| 1677 |
% so that the captions are aligned if the bodies |
| 1678 |
% have the same height. |
| 1679 |
% <empty> is equivalent to c. |
| 1680 |
subpage outer pos/.initial=auto, |
| 1681 |
subpage outer pos/.value required, |
| 1682 |
% |
| 1683 |
% The height of the minipage. |
| 1684 |
% An empty value means that this optional argument is |
| 1685 |
% *not* passed to the subfigure/subtable environment. |
| 1686 |
subpage height/.initial=, |
| 1687 |
subpage height/.value required=, |
| 1688 |
% |
| 1689 |
% The vertical position of the content on the minipage. |
| 1690 |
% Allowed values: t, c, b, s, <empty>. |
| 1691 |
% <empty> means that this optional argument is |
| 1692 |
% *not* passed to the subfigure/subtable environment. |
| 1693 |
% This option has no effect if subpage height is <empty>. |
| 1694 |
subpage inner pos/.initial=, |
| 1695 |
subpage inner pos/.value required, |
| 1696 |
% |
| 1697 |
% TeX code which is inserted at the beginning of the subfigure/subtable environment |
| 1698 |
subpage align/.initial=\centering, |
| 1699 |
subpage align/.value required, |
| 1700 |
% |
| 1701 |
% ------- separator options ------- |
| 1702 |
% Insert a separator in front of each subobject |
| 1703 |
% except for the first subobject. |
| 1704 |
sep/.initial=, |
| 1705 |
sep/.value required, |
| 1706 |
% |
| 1707 |
% Place the subobjects side by side. |
| 1708 |
hor/.code= |
| 1709 |
\esf@pgfkeyscopyvalue{/subobject/sep}{/subobject/hor sep}% |
| 1710 |
\esf@pgfkeysvalueappend{/subobject/sep}{#1}, |
| 1711 |
hor/.default=, |
| 1712 |
% |
| 1713 |
% The separator to be used when the subobjects |
| 1714 |
% shall be placed side by side. |
| 1715 |
hor sep/.initial=, |
| 1716 |
hor sep/.value required, |
| 1717 |
hor sep+/.forward to=/subobject/hor sep +, |
| 1718 |
hor sep+/.value required, |
| 1719 |
hor sep +/.code=\esf@pgfkeysvalueappend{/subobject/hor sep}{#1}, |
| 1720 |
hor sep +/.value required, |
| 1721 |
% |
| 1722 |
% Place the subobjects below each other. |
| 1723 |
ver/.code= |
| 1724 |
\esf@pgfkeyscopyvalue{/subobject/sep}{/subobject/ver sep}% |
| 1725 |
\esf@pgfkeysvalueappend{/subobject/sep}{#1}, |
| 1726 |
ver/.default=, |
| 1727 |
% |
| 1728 |
% The separator to be used when the subobjects |
| 1729 |
% shall be placed below eachother. |
| 1730 |
ver sep/.initial=\par\bigskip, |
| 1731 |
ver sep/.value required, |
| 1732 |
ver sep+/.forward to=/subobject/ver sep +, |
| 1733 |
ver sep+/.value required, |
| 1734 |
ver sep +/.code=\esf@pgfkeysvalueappend{/subobject/ver sep}{#1}, |
| 1735 |
ver sep +/.value required, |
| 1736 |
% |
| 1737 |
% |
| 1738 |
% ------- warnings ------- |
| 1739 |
% |
| 1740 |
warn no caption/.is if=subobject@warnnocaption, |
| 1741 |
warn no caption=true, |
| 1742 |
% |
| 1743 |
warn no label/.is if=subobject@warnnolabel, |
| 1744 |
warn no label=false, |
| 1745 |
% |
| 1746 |
warn other env/.forward to=/object/warn other env, |
| 1747 |
%value is allowed but not necessary |
| 1748 |
% |
| 1749 |
% |
| 1750 |
% ------- debugging ------- |
| 1751 |
% |
| 1752 |
show env args/.forward to=/object/show env args, |
| 1753 |
% |
| 1754 |
% |
| 1755 |
% ------- inner environment ------- |
| 1756 |
% |
| 1757 |
% An additional inner environment to wrap the content in like tabular, tabularx, tikzpicture |
| 1758 |
env/.code=\IfEnvironmentExistsOrIsEmpty{#1}{% |
| 1759 |
\ifstrequal{#1}{longtable}{% |
| 1760 |
\PackageError{easyfloats}{You cannot use 'env=longtable' in a subobject} |
| 1761 |
{Either use 'env=tabular' instead or combine the subobjects into one longtable.}% |
| 1762 |
\pgfkeyssetvalue{/subobject/env}{tabular}% |
| 1763 |
}{% |
| 1764 |
\pgfkeyssetvalue{/subobject/env}{#1}% |
| 1765 |
}% |
| 1766 |
}{% |
| 1767 |
\PackageError{easyfloats}{Environment #1 which you passed to the key 'env' does not exist}{}% |
| 1768 |
}, |
| 1769 |
env/.value required, |
| 1770 |
env=, |
| 1771 |
% |
| 1772 |
% ------- unknown handler / env args ------- |
| 1773 |
% |
| 1774 |
% see /object |
| 1775 |
% |
| 1776 |
.unknown/.code={% |
| 1777 |
% Using \ObjectProcessKeyPattern instead of \ObjectProcessArgs |
| 1778 |
% means that keys like `graphic width` can be used in subobjects as well. |
| 1779 |
% For a directly used subobject this should not be allowed. |
| 1780 |
% But I am leaving it in for \includegraphicsubobject so that the same key |
| 1781 |
% which works in \objectset and \includegraphicobject also works there. |
| 1782 |
\ObjectProcessKeyPattern{\pgfkeyscurrentname}{#1}{% |
| 1783 |
\pgfkeysgetvalue{/subobject/.really unknown/.@cmd}{\esf@tmp@err}% |
| 1784 |
\esf@tmp@err#1\pgfeov |
| 1785 |
}% |
| 1786 |
}, |
| 1787 |
% Setting an unknown key handler shall not override env args but set an additional unknown handler. |
| 1788 |
.unknown/.code/.code={% |
| 1789 |
\pgfkeysdef{/subobject/.really unknown}{#1}% |
| 1790 |
}, |
| 1791 |
.really unknown/.code={% |
| 1792 |
\edef\do{\noexpand\pgfkeys{/errors/unknown key={\pgfkeyscurrentkey}{\unexpanded{#1}}}}% |
| 1793 |
\do |
| 1794 |
}, |
| 1795 |
}% |
| 1796 |
|
| 1797 |
\newenvironment{subobject}[1]{% #1: options |
| 1798 |
\if@inobject |
| 1799 |
\else |
| 1800 |
\PackageError{easyfloats}{subobject environment may not be used outside of an object}{Did you mean to use the object environment instead?}% |
| 1801 |
\fi |
| 1802 |
% |
| 1803 |
\subobject@hook |
| 1804 |
\ifobject@isgraphic |
| 1805 |
\object@graphic@hook |
| 1806 |
\global\object@isgraphicfalse |
| 1807 |
\fi |
| 1808 |
% |
| 1809 |
\let\label=\esf@original@label |
| 1810 |
\let\caption=\esf@original@caption |
| 1811 |
% |
| 1812 |
% ------- options ------- |
| 1813 |
% |
| 1814 |
\renewcommand\@object@envkey{/subobject/env}% |
| 1815 |
\pgfqkeys{/subobject}{#1}% |
| 1816 |
\ifsubobject@warnnocaption |
| 1817 |
\pgfkeys{/subobject/caption/.esf@recommended}% |
| 1818 |
\fi |
| 1819 |
\ifsubobject@warnnolabel |
| 1820 |
\pgfkeys{/subobject/label/.esf@recommended}% |
| 1821 |
\fi |
| 1822 |
% |
| 1823 |
\esf@ifpgfkeyhasvalue{/subobject/list caption}% |
| 1824 |
{\pgfkeys{/subobject/list caption/.get=\subobject@caption@short}}% |
| 1825 |
{\pgfkeys{/subobject/caption/.get=\subobject@caption@short}}% |
| 1826 |
\pgfkeysgetvalue{/subobject/linewidth}{\subobject@linewidth}% |
| 1827 |
% |
| 1828 |
\pgfkeysgetvalue{/subobject/details}{\subobject@details}% |
| 1829 |
\ifx \subobject@details \@empty |
| 1830 |
% do nothing |
| 1831 |
\else |
| 1832 |
\preto\subobject@details{\pgfkeysvalueof{/subobject/details sep}}% |
| 1833 |
\fi |
| 1834 |
% |
| 1835 |
\pgfkeysgetvalue{/subobject/env}{\esf@tmp@env}% |
| 1836 |
\ifx \esf@tmp@env \@empty |
| 1837 |
\def\subobject@innerenv@begin{\ignorespaces}% |
| 1838 |
\def\subobject@innerenv@end{\unskip}% |
| 1839 |
\else |
| 1840 |
\edef\subobject@innerenv@begin{\expandonce{\csname\esf@tmp@env\endcsname}}% |
| 1841 |
\edef\subobject@innerenv@end{\expandonce{\csname end\esf@tmp@env\endcsname}}% |
| 1842 |
\ObjectAppendEnvargs{\subobject@innerenv@begin}% |
| 1843 |
\ifobject@showenv |
| 1844 |
\show\subobject@innerenv@begin |
| 1845 |
\fi |
| 1846 |
\fi |
| 1847 |
% |
| 1848 |
% ------- execute ------- |
| 1849 |
% |
| 1850 |
\if@firstsubobject |
| 1851 |
\else |
| 1852 |
% No need to worry about \parskip. |
| 1853 |
% Inside of a floating environment it appears to be always zero. |
| 1854 |
\pgfkeysvalueof{/subobject/sep}% |
| 1855 |
\fi |
| 1856 |
\subobject@begin |
| 1857 |
}{% |
| 1858 |
\subobject@end |
| 1859 |
\global \@firstsubobjectfalse |
| 1860 |
} |
| 1861 |
|
| 1862 |
\NewEnviron{subobject@subcaptionbox}{% |
| 1863 |
\def\subobject@box{% |
| 1864 |
\subcaptionbox[% list caption |
| 1865 |
\subobject@caption@short |
| 1866 |
]{% caption |
| 1867 |
\pgfkeysvalueof{/subobject/caption}% |
| 1868 |
\subobject@details |
| 1869 |
\esf@ifpgfkeyhasvalue{/subobject/label} |
| 1870 |
{\label{\pgfkeysvalueof{/subobject/label}}} |
| 1871 |
{}% |
| 1872 |
}% |
| 1873 |
}% |
| 1874 |
\ifdefvoid\subobject@linewidth{% |
| 1875 |
% do nothing |
| 1876 |
}{% |
| 1877 |
\appto\subobject@box{[\subobject@linewidth]}% |
| 1878 |
\pgfkeysgetvalue{/subobject/subcaptionbox inner pos}{\subobject@innerpos}% |
| 1879 |
\ifx \subobject@innerpos \@empty |
| 1880 |
% do nothing |
| 1881 |
\else |
| 1882 |
\eappto\subobject@box{[\subobject@innerpos]}% |
| 1883 |
\fi |
| 1884 |
}% |
| 1885 |
\subobject@box{% content |
| 1886 |
\begingroup |
| 1887 |
\renewcommand{\label}[1]{\PackageError{easyfloats}{\string\label\space is not allowed in subobject. Please use the 'label' option instead}{}}% |
| 1888 |
\renewcommand{\caption}[2][]{\PackageError{easyfloats}{\string\caption\space is not allowed in subobject. Please use the 'caption' option instead}{}}% |
| 1889 |
\pgfkeysvalueof{/subobject/exec}% |
| 1890 |
\subobject@innerenv@begin |
| 1891 |
\BODY |
| 1892 |
\subobject@innerenv@end |
| 1893 |
\endgroup |
| 1894 |
}% |
| 1895 |
} |
| 1896 |
|
| 1897 |
\newenvironment{subobject@subpage}{% |
| 1898 |
\ifx \subobject@linewidth \@empty |
| 1899 |
\PackageError{easyfloats}{'linewidth' may not be empty when using the 'subpage' backend}{}% |
| 1900 |
\fi |
| 1901 |
\edef\subobject@subpage@envname{sub\pgfkeysvalueof{/object/type}}% |
| 1902 |
\def\subobject@subpage@begin{\csname\subobject@subpage@envname\endcsname}% |
| 1903 |
\def\subobject@subpage@end{\csname end\subobject@subpage@envname\endcsname}% |
| 1904 |
% |
| 1905 |
\pgfkeysgetvalue{/subobject/subpage outer pos}{\subobject@outerpos}% |
| 1906 |
\ifx \subobject@outerpos \@empty |
| 1907 |
\appto\subobject@subpage@begin{[c]}% |
| 1908 |
\else \ifdefstring \subobject@outerpos {auto}{% |
| 1909 |
\caption@iftop |
| 1910 |
{\eappto\subobject@subpage@begin{[t]}}% |
| 1911 |
{\eappto\subobject@subpage@begin{[b]}}% |
| 1912 |
}{\ifdefstring \subobject@outerpos {Auto}{% |
| 1913 |
\caption@iftop |
| 1914 |
{\eappto\subobject@subpage@begin{[T]}}% |
| 1915 |
{\eappto\subobject@subpage@begin{[B]}}% |
| 1916 |
}{\ifdefstring \subobject@outerpos {auto-inverted}{% |
| 1917 |
\caption@iftop |
| 1918 |
{\eappto\subobject@subpage@begin{[b]}}% |
| 1919 |
{\eappto\subobject@subpage@begin{[t]}}% |
| 1920 |
}{\ifdefstring \subobject@outerpos {Auto-inverted}{% |
| 1921 |
\caption@iftop |
| 1922 |
{\eappto\subobject@subpage@begin{[B]}}% |
| 1923 |
{\eappto\subobject@subpage@begin{[T]}}% |
| 1924 |
}{% |
| 1925 |
\eappto\subobject@subpage@begin{[\subobject@outerpos]}% |
| 1926 |
}}}}\fi |
| 1927 |
\pgfkeysgetvalue{/subobject/subpage height}{\subobject@height}% |
| 1928 |
\ifx \subobject@height \@empty |
| 1929 |
\else |
| 1930 |
\appto\subobject@subpage@begin{[\subobject@height]}% |
| 1931 |
\pgfkeysgetvalue{/subobject/subpage inner pos}{\subobject@innerpos}% |
| 1932 |
\ifx \subobject@innerpos \@empty |
| 1933 |
\else |
| 1934 |
\eappto\subobject@subpage@begin{[\subobject@innerpos]}% |
| 1935 |
\fi |
| 1936 |
\fi |
| 1937 |
% |
| 1938 |
\subobject@subpage@begin{\subobject@linewidth}% |
| 1939 |
\pgfkeysvalueof{/subobject/subpage align}% |
| 1940 |
% \caption@iftop is defined by caption package |
| 1941 |
\caption@iftop{\subobject@subpage@captionAndLabel}{}% |
| 1942 |
\begingroup |
| 1943 |
\renewcommand{\label}[1]{\PackageError{easyfloats}{\string\label\space is not allowed in subobject. Please use the 'label' option instead}{}}% |
| 1944 |
\renewcommand{\caption}[2][]{\PackageError{easyfloats}{\string\caption\space is not allowed in subobject. Please use the 'caption' option instead}{}}% |
| 1945 |
\pgfkeysvalueof{/subobject/exec}% |
| 1946 |
\subobject@innerenv@begin |
| 1947 |
}{% |
| 1948 |
\subobject@innerenv@end |
| 1949 |
\endgroup |
| 1950 |
\caption@iftop{}{\subobject@subpage@captionAndLabel}% |
| 1951 |
\subobject@subpage@end |
| 1952 |
\ignorespacesafterend |
| 1953 |
} |
| 1954 |
\newcommand{\subobject@subpage@captionAndLabel}{% |
| 1955 |
% ------- caption ------- |
| 1956 |
% position of caption (above/below) is handled by float package (see float style) |
| 1957 |
\esf@ifpgfkeyhasvalue{/subobject/caption}{% |
| 1958 |
\caption[\subobject@caption@short]{\pgfkeysvalueof{/subobject/caption}\subobject@details}% |
| 1959 |
}{% |
| 1960 |
% Generate an anchor for a \label. |
| 1961 |
\phantomcaption |
| 1962 |
}% |
| 1963 |
% ------- label ------- |
| 1964 |
\esf@ifpgfkeyhasvalue{/subobject/label}% |
| 1965 |
{\label{\pgfkeysvalueof{/subobject/label}}}% |
| 1966 |
{}% |
| 1967 |
} |
| 1968 |
|
| 1969 |
\pgfqkeys{/subobject}{subpage} |