| 1 |
% \iffalse meta-comment |
| 2 |
% !TEX program = pdflatex |
| 3 |
% !TEX encoding = ISO-8859-1 |
| 4 |
%<*internal> |
| 5 |
\iffalse |
| 6 |
%</internal> |
| 7 |
%<*readme> |
| 8 |
---------------------------------------------------------------- |
| 9 |
trivfloat --- Quick floats in LaTeX |
| 10 |
E-mail: [email protected] |
| 11 |
Released under the LaTeX Project Public License v1.3c or later |
| 12 |
See http://www.latex-project.org/lppl.txt |
| 13 |
---------------------------------------------------------------- |
| 14 |
|
| 15 |
The trivfloat package provides a quick method for defining new |
| 16 |
float types in LaTeX. A single command sets up a new float in |
| 17 |
the same style as the LaTeX kernel figure and table float |
| 18 |
types. |
| 19 |
%</readme> |
| 20 |
%<*internal> |
| 21 |
\fi |
| 22 |
\def\nameofplainTeX{plain} |
| 23 |
\ifx\fmtname\nameofplainTeX\else |
| 24 |
\expandafter\begingroup |
| 25 |
\fi |
| 26 |
%</internal> |
| 27 |
%<*install> |
| 28 |
\input docstrip.tex |
| 29 |
\keepsilent |
| 30 |
\askforoverwritefalse |
| 31 |
\preamble |
| 32 |
trivfloat --- Quick floats in LaTeX |
| 33 |
E-mail: [email protected] |
| 34 |
Released under the LaTeX Project Public License v1.3c or later |
| 35 |
See http://www.latex-project.org/lppl.txt |
| 36 |
---------------------------------------------------------------- |
| 37 |
|
| 38 |
\endpreamble |
| 39 |
\postamble |
| 40 |
|
| 41 |
Copyright (C) 2007,2009 by |
| 42 |
Joseph Wright <[email protected]> |
| 43 |
|
| 44 |
It may be distributed and/or modified under the conditions of |
| 45 |
the LaTeX Project Public License (LPPL), either version 1.3c of |
| 46 |
this license or (at your option) any later version. The latest |
| 47 |
version of this license is in the file: |
| 48 |
|
| 49 |
http://www.latex-project.org/lppl.txt |
| 50 |
|
| 51 |
This work is "maintained" (as per LPPL maintenance status) by |
| 52 |
Joseph Wright. |
| 53 |
|
| 54 |
This work consists of the file trivfloat.dtx |
| 55 |
and the derived files trivfloat.pdf, |
| 56 |
trivfloat.ins and |
| 57 |
trivfloat.sty. |
| 58 |
|
| 59 |
\endpostamble |
| 60 |
\usedir{tex/latex/trivfloat} |
| 61 |
\generate{ |
| 62 |
\file{\jobname.sty}{\from{\jobname.dtx}{package}} |
| 63 |
} |
| 64 |
%</install> |
| 65 |
%<install>\endbatchfile |
| 66 |
%<*internal> |
| 67 |
\usedir{source/latex/trivfloat} |
| 68 |
\generate{ |
| 69 |
\file{\jobname.ins}{\from{\jobname.dtx}{install}} |
| 70 |
} |
| 71 |
\nopreamble\nopostamble |
| 72 |
\usedir{doc/latex/trivfloat} |
| 73 |
\generate{ |
| 74 |
\file{README.txt}{\from{\jobname.dtx}{readme}} |
| 75 |
} |
| 76 |
\ifx\fmtname\nameofplainTeX |
| 77 |
\expandafter\endbatchfile |
| 78 |
\else |
| 79 |
\expandafter\endgroup |
| 80 |
\fi |
| 81 |
\immediate\write18{makeindex -s gglo.ist -o trivfloat.gls trivfloat.glo} |
| 82 |
\immediate\write18{makeindex -s gind.ist -o trivfloat.ind trivfloat.idx} |
| 83 |
%</internal> |
| 84 |
%<*package> |
| 85 |
\NeedsTeXFormat{LaTeX2e} |
| 86 |
\ProvidesPackage{trivfloat} |
| 87 |
[2009/04/23 v1.4 Quick floats in LaTeX] |
| 88 |
%</package> |
| 89 |
%<*driver> |
| 90 |
\documentclass[a4paper]{ltxdoc} |
| 91 |
\usepackage[T1]{fontenc} |
| 92 |
\usepackage{lmodern,trivfloat} |
| 93 |
\usepackage[osf]{mathpazo} |
| 94 |
\usepackage[scaled=0.95]{helvet} |
| 95 |
\usepackage[final]{listings,microtype} |
| 96 |
\usepackage[numbered]{hypdoc} |
| 97 |
\trivfloat{graph} |
| 98 |
\EnableCrossrefs |
| 99 |
\CodelineIndex |
| 100 |
\RecordChanges |
| 101 |
\begin{document} |
| 102 |
\DocInput{\jobname.dtx} |
| 103 |
\end{document} |
| 104 |
%</driver> |
| 105 |
% \fi |
| 106 |
% |
| 107 |
%\CheckSum{295} |
| 108 |
% |
| 109 |
%\changes{v1.0}{2007/06/09}{Initial public release} |
| 110 |
%\changes{v1.1}{2007/08/13}{Floats can be generated as package |
| 111 |
% options} |
| 112 |
%\changes{v1.2}{2007/08/20}{Added \textsf{memoir} support} |
| 113 |
%\changes{v1.2}{2007/08/20}{Improved emulation of default floats} |
| 114 |
%\changes{v1.3b}{2007/09/20}{Fixed error with \textsf{hyperref}} |
| 115 |
%\changes{v1.3b}{2007/09/20}{Licence changed from GPL to LPPL} |
| 116 |
%\changes{v1.4}{2009/04/23}{Re-think of internal methods to make |
| 117 |
% work-flow clearer} |
| 118 |
%\changes{v1.4}{2009/04/23}{Support for \textsf{babel} introduced} |
| 119 |
% |
| 120 |
%\GetFileInfo{\jobname.sty} |
| 121 |
% |
| 122 |
%\makeatletter |
| 123 |
% |
| 124 |
%^^A \DescribeOption is in l3doc but not ltxdoc |
| 125 |
%\newcommand*{\DescribeOption}{^^A |
| 126 |
% \leavevmode |
| 127 |
% \@bsphack |
| 128 |
% \begingroup |
| 129 |
% \MakePrivateLetters |
| 130 |
% \Describe@Option |
| 131 |
%} |
| 132 |
%\newcommand*{\Describe@Option}[1]{^^A |
| 133 |
% \endgroup |
| 134 |
% \marginpar{^^A |
| 135 |
% \raggedleft |
| 136 |
% \PrintDescribeEnv{#1}^^A |
| 137 |
% }% |
| 138 |
% \SpecialOptionIndex{#1}^^A |
| 139 |
% \@esphack |
| 140 |
% \ignorespaces |
| 141 |
%} |
| 142 |
%\newcommand*{\SpecialOptionIndex}[1]{^^A |
| 143 |
% \@bsphack |
| 144 |
% \index{^^A |
| 145 |
% #1\actualchar{\protect\ttfamily#1} (option)\encapchar usage^^A |
| 146 |
% }^^A |
| 147 |
% \index{^^A |
| 148 |
% options:\levelchar#1\actualchar{\protect\ttfamily#1} |
| 149 |
% \encapchar usage^^A |
| 150 |
% }^^A |
| 151 |
% \@esphack |
| 152 |
%} |
| 153 |
% |
| 154 |
%^^A For creating examples with nice highlighting of code, and so |
| 155 |
%^^A on; based on the system used in the listings source (lstsample). |
| 156 |
%\lst@RequireAspects{writefile} |
| 157 |
%\newsavebox{\LaTeXdemo@box} |
| 158 |
%\lstnewenvironment{LaTeXdemo}[1][code and example]{^^A |
| 159 |
% \global\let\lst@intname\@empty |
| 160 |
% \expandafter\let\expandafter\LaTeXdemo@end |
| 161 |
% \csname LaTeXdemo@#1@end\endcsname |
| 162 |
% \@nameuse{LaTeXdemo@#1}^^A |
| 163 |
%}{^^A |
| 164 |
% \LaTeXdemo@end |
| 165 |
%} |
| 166 |
%\newcommand*\LaTeXdemo@new[3]{^^A |
| 167 |
% \expandafter\newcommand\expandafter*\expandafter |
| 168 |
% {\csname LaTeXdemo@#1\endcsname}{#2}^^A |
| 169 |
% \expandafter\newcommand\expandafter*\expandafter |
| 170 |
% {\csname LaTeXdemo@#1@end\endcsname}{#3}^^A |
| 171 |
%} |
| 172 |
%\newcommand*\LaTeXdemo@common{^^A |
| 173 |
% \setkeys{lst}{ |
| 174 |
% basicstyle = \small\ttfamily, |
| 175 |
% basewidth = 0.51em, |
| 176 |
% gobble = 3, |
| 177 |
% keywordstyle = \color{blue}, |
| 178 |
% language = [LaTeX]{TeX}, |
| 179 |
% moretexcs = { |
| 180 |
% trivfloat |
| 181 |
% } |
| 182 |
% }^^A |
| 183 |
%} |
| 184 |
%\newcommand*\LaTeXdemo@input{^^A |
| 185 |
% \MakePercentComment |
| 186 |
% \catcode`\^^M=10\relax |
| 187 |
% \small |
| 188 |
% \begingroup |
| 189 |
% \setkeys{lst}{ |
| 190 |
% SelectCharTable=\lst@ReplaceInput{\^\^I}{\lst@ProcessTabulator} |
| 191 |
% }^^A |
| 192 |
% \leavevmode |
| 193 |
% \input{\jobname.tmp}^^A |
| 194 |
% \endgroup |
| 195 |
% \MakePercentIgnore |
| 196 |
%} |
| 197 |
%\LaTeXdemo@new{code and example}{^^A |
| 198 |
% \setbox\LaTeXdemo@box=\hbox\bgroup |
| 199 |
% \lst@BeginAlsoWriteFile{\jobname.tmp}^^A |
| 200 |
% \LaTeXdemo@common |
| 201 |
%}{^^A |
| 202 |
% \lst@EndWriteFile |
| 203 |
% \egroup |
| 204 |
% \begin{center} |
| 205 |
% \ifdim\wd\LaTeXdemo@box>0.48\linewidth\relax |
| 206 |
% \hbox to\linewidth{\box\LaTeXdemo@box\hss}^^A |
| 207 |
% \begin{minipage}{\linewidth} |
| 208 |
% \LaTeXdemo@input |
| 209 |
% \end{minipage} |
| 210 |
% \else |
| 211 |
% \begin{minipage}{0.48\linewidth} |
| 212 |
% \LaTeXdemo@input |
| 213 |
% \end{minipage} |
| 214 |
% \hfill |
| 215 |
% \begin{minipage}{0.48\linewidth} |
| 216 |
% \hbox to\linewidth{\box\LaTeXdemo@box\hss}^^A |
| 217 |
% \end{minipage} |
| 218 |
% \fi |
| 219 |
% \end{center} |
| 220 |
%} |
| 221 |
%\LaTeXdemo@new{code only}{^^A |
| 222 |
% \LaTeXdemo@common |
| 223 |
%}{} |
| 224 |
% |
| 225 |
%\LaTeXdemo@new{code and float}{^^A |
| 226 |
% \lst@BeginAlsoWriteFile{\jobname.tmp}^^A |
| 227 |
% \LaTeXdemo@common |
| 228 |
%}{^^A |
| 229 |
% \lst@EndWriteFile |
| 230 |
% \LaTeXdemo@input |
| 231 |
%} |
| 232 |
% |
| 233 |
%\providecommand*{\file}{\texttt} |
| 234 |
%\providecommand*{\opt}{\texttt} |
| 235 |
%\providecommand*{\pkg}{\textsf} |
| 236 |
% |
| 237 |
%\makeatother |
| 238 |
% |
| 239 |
%\title{^^A |
| 240 |
% \textsf{trivfloat} --- Quick floats in |
| 241 |
% \texorpdfstring{\LaTeX}{LaTeX}\thanks{^^A |
| 242 |
% This file describes version \fileversion, last revised |
| 243 |
% \filedate.^^A |
| 244 |
% }^^A |
| 245 |
%} |
| 246 |
%\author{^^A |
| 247 |
% Joseph Wright\thanks{E-mail: [email protected]}^^A |
| 248 |
%} |
| 249 |
%\date{Released \filedate} |
| 250 |
% |
| 251 |
%\maketitle |
| 252 |
% |
| 253 |
%\begin{abstract} |
| 254 |
% The \pkg{trivfloat} package provides a quick method for defining new |
| 255 |
% float types in \LaTeX. A single command sets up a new float in the |
| 256 |
% same style as the \LaTeX\ kernel \texttt{figure} and \texttt{table} |
| 257 |
% float types. |
| 258 |
%\end{abstract} |
| 259 |
% |
| 260 |
%\begin{multicols}{2} |
| 261 |
% \tableofcontents |
| 262 |
%\end{multicols} |
| 263 |
% |
| 264 |
%\section{Introduction} |
| 265 |
% |
| 266 |
% The LaTeX kernel provides the \texttt{figure} and \texttt{table} |
| 267 |
% floating environment, but does not provide an easy method for |
| 268 |
% defining new float types. This problem is addressed by the |
| 269 |
% \pkg{float} and \pkg{floatrow} packages, which provides an array of |
| 270 |
% commands to create new float types. However, the one command missing |
| 271 |
% is a quick one to set up a new float type with no customisation. |
| 272 |
% This is addressed by the \pkg{trivfloat} package. |
| 273 |
% |
| 274 |
%\section{Installation} |
| 275 |
% |
| 276 |
% The entire bundle is supplied with the TDS-ready ZIP file, |
| 277 |
% \file{trivfloat.tds.zip}. Simply unzip this into your local texmf |
| 278 |
% tree and run your hash program (\texttt{texhash} for \TeX{}Live or |
| 279 |
% \texttt{initextmf -u} for MiK\TeX). |
| 280 |
% |
| 281 |
% To extract the package from \file{trivfloat.dtx}, run (pdf)\TeX\ on |
| 282 |
% \file{trivfloat.dtx}. This will produce all of the package |
| 283 |
% files, and also \file{README.txt}. To extract the |
| 284 |
% files and build the documentation, run (pdf)\LaTeX\ on |
| 285 |
% \texttt{trivfloat.dtx}. The files can then be installed as above. |
| 286 |
% |
| 287 |
%\section{Using the package} |
| 288 |
% |
| 289 |
%\DescribeMacro{\trivfloat} |
| 290 |
%\changes{v1.4}{2009/04/23}{\cs{trivfloat} now accepts a comma-list of |
| 291 |
% new float types} |
| 292 |
% The package itself provides only a single command to the user, |
| 293 |
% \cmd{\trivfloat}. This takes a single argument \marg{name}, a |
| 294 |
% comma-separated list of new floating environments. The new |
| 295 |
% environment scan be used as normal; the new floats should behave |
| 296 |
% exactly the same as \texttt{figure} and \texttt{table} environments. |
| 297 |
% The \cs{trivfloat} macro does not check for an existing definition |
| 298 |
% of \meta{float}: any existing definition will be overwritten. |
| 299 |
% |
| 300 |
% As an example, this file has in the preamble the line: |
| 301 |
%\begin{LaTeXdemo}[code only] |
| 302 |
% \trivfloat{graph} |
| 303 |
%\end{LaTeXdemo} |
| 304 |
% This allows the ready production of floating graphs: |
| 305 |
%\begin{LaTeXdemo}[code and float] |
| 306 |
% \begin{graph} |
| 307 |
% \centering |
| 308 |
% Something for a graph |
| 309 |
% \caption{My graph} |
| 310 |
% \end{graph} |
| 311 |
%\end{LaTeXdemo} |
| 312 |
% and also lists of graphs |
| 313 |
%\begin{LaTeXdemo} |
| 314 |
% \listofgraphs |
| 315 |
%\end{LaTeXdemo} |
| 316 |
% |
| 317 |
% The \pkg{trivfloat} package works hard to ensure that the |
| 318 |
% newly-produced floats behave exactly like pre-defined ones. The |
| 319 |
% exact behaviour of the new floats is dependant on the document |
| 320 |
% class used: \pkg{trivfloat} knows about the standard classes, |
| 321 |
% \pkg{memoir} and \textsc{koma}-Script. The \cs{trivfloat} command |
| 322 |
% should only be used in the preamble of the document: \LaTeX\ will |
| 323 |
% complain if you use it later. New floats can also be generated by |
| 324 |
% passing the name of the desired float type to the package as an option. |
| 325 |
% |
| 326 |
% The new floats will respect the normal position modifiers, \texttt{t}, |
| 327 |
% \texttt{b}, \texttt{h}, \texttt{p} and (if \pkg{memoir} is not in use) |
| 328 |
% \texttt{H} for \emph{really} here. |
| 329 |
% |
| 330 |
%\DescribeOption{floatrow} |
| 331 |
%\changes{v1.4}{2009/04/23}{Support for \textsf{floatrow} package} |
| 332 |
% \pkg{trivfloat} will use the \pkg{float} package to produce new |
| 333 |
% floats, unless the \pkg{memoir} class is in use. The package |
| 334 |
% will accept the load time option \opt{floatrow}, which will instead |
| 335 |
% use the \pkg{floatrow} package to produce floats. If either |
| 336 |
% \pkg{float} or \pkg{floatrow} is loaded before \pkg{trivfloat}, the |
| 337 |
% loaded package will be used irrespective of this option. |
| 338 |
% |
| 339 |
% When the \pkg{memoir} class is in use, the built-in function is used |
| 340 |
% to produce floats. If the user has loaded \pkg{float} or |
| 341 |
% \pkg{floatrow}, this will be safely detected. |
| 342 |
% |
| 343 |
%\section{Known issues} |
| 344 |
% |
| 345 |
% If you wish to redefine \texttt{\textbackslash the\meta{float}}, to |
| 346 |
% alter the number format, then you must do this after |
| 347 |
% |\begin{document}|. This is to allow \pkg{trivfloat} to work correctly |
| 348 |
% with \pkg{hyperref}. |
| 349 |
% |
| 350 |
% The name passed to \cs{trivfloat} should contain only the letters |
| 351 |
% A--Z and a--z. This ensures that there are no strange errors |
| 352 |
% generated by \TeX. Correctly handling non-English words is not |
| 353 |
% possible using an automated system, and so after defining a new |
| 354 |
% float type the macros \texttt{\textbackslash\meta{float}name} and |
| 355 |
% \texttt{\textbackslash list\meta{float}name} should be corrected to |
| 356 |
% give the desired names. |
| 357 |
% |
| 358 |
% The \pkg{babel} system provides support for a wide range of |
| 359 |
% language-specific strings. It also makes changes to the typography |
| 360 |
% of documents. The changes made by \pkg{babel} can be in almost any |
| 361 |
% area, and so floats created with \pkg{trivfloat} may not act like the |
| 362 |
% standard ones once \pkg{babel} is loaded. For example, the |
| 363 |
% \opt{french} option for \pkg{babel} alters the internal function used |
| 364 |
% to make float captions. Users should search through the |
| 365 |
% \texttt{\meta{language}.ldf} file for the languages they use for |
| 366 |
% ``figure'' and ``lof'' to see what changes \pkg{babel} makes to the |
| 367 |
% standard floats. The user can then correct the behaviour of the |
| 368 |
% new floats as needed. |
| 369 |
% |
| 370 |
%\StopEventually{^^A |
| 371 |
% \PrintChanges |
| 372 |
% \PrintIndex |
| 373 |
%} |
| 374 |
% |
| 375 |
%\section{Implementation} |
| 376 |
% |
| 377 |
%\begin{macro}{\iftfl@floatrow} |
| 378 |
% There is a choice: use \pkg{float} or use \pkg{floatrow}. |
| 379 |
% \begin{macrocode} |
| 380 |
%<*package> |
| 381 |
\newif\iftfl@floatrow |
| 382 |
% \end{macrocode} |
| 383 |
%\end{macro} |
| 384 |
%\begin{macro}{\tlf@make@execute} |
| 385 |
%\begin{macro}{\tlf@make@pkg} |
| 386 |
% So that things work easily, the name of the package used to generate |
| 387 |
% floats is stored for later use. The command to execute everything is |
| 388 |
% also stored, as \pkg{floatrow} needs things to happen earlier than |
| 389 |
% \pkg{float} or \pkg{memoir}. |
| 390 |
% \begin{macrocode} |
| 391 |
\newcommand*{\tfl@make@execute}{} |
| 392 |
\newcommand*{\tfl@make@pkg}{} |
| 393 |
% \end{macrocode} |
| 394 |
%\end{macro} |
| 395 |
%\end{macro} |
| 396 |
% |
| 397 |
% Option handling, including some faked key--value input. |
| 398 |
% \begin{macrocode} |
| 399 |
\DeclareOption{floatrow}{\tfl@floatrowtrue} |
| 400 |
\DeclareOption{floatrow=true}{\tfl@floatrowtrue} |
| 401 |
\DeclareOption{floatrow=false}{\tfl@floatrowfalse} |
| 402 |
\DeclareOption*{% |
| 403 |
\expandafterAtEndOfPackage\expandafter{% |
| 404 |
\expandafter\trivfloat\expandafter{\CurrentOption}% |
| 405 |
}% |
| 406 |
} |
| 407 |
\ProcessOptions\relax |
| 408 |
% \end{macrocode} |
| 409 |
% |
| 410 |
% With options processed, the appropriate packages can be loaded as |
| 411 |
% necessary. The are some checks so that only one package is tried. The |
| 412 |
% order here means that \pkg{memoir} users can choose to load |
| 413 |
% \pkg{float} or \pkg{floatrow} if they use the extra functionality. |
| 414 |
% \begin{macrocode} |
| 415 |
\@ifpackageloaded{floatrow}{% |
| 416 |
\renewcommand*{\tfl@make@pkg}{floatrow} |
| 417 |
\renewcommand*{\tfl@make@execute}{\@firstofone} |
| 418 |
}{% |
| 419 |
\@ifpackageloaded{float}{% |
| 420 |
\renewcommand*{\tfl@make@pkg}{float} |
| 421 |
\renewcommand*{\tfl@make@execute}{\AtBeginDocument} |
| 422 |
}{% |
| 423 |
\@ifclassloaded{memoir}{% |
| 424 |
\renewcommand*{\tfl@make@pkg}{memoir} |
| 425 |
\renewcommand*{\tfl@make@execute}{\AtBeginDocument} |
| 426 |
}{% |
| 427 |
\iftfl@floatrow |
| 428 |
\RequirePackage{floatrow} |
| 429 |
\renewcommand*{\tfl@make@pkg}{floatrow} |
| 430 |
\renewcommand*{\tfl@make@execute}{\@firstofone} |
| 431 |
\else |
| 432 |
\RequirePackage{float} |
| 433 |
\renewcommand*{\tfl@make@pkg}{float} |
| 434 |
\renewcommand*{\tfl@make@execute}{\AtBeginDocument} |
| 435 |
\fi |
| 436 |
}% |
| 437 |
}% |
| 438 |
} |
| 439 |
% \end{macrocode} |
| 440 |
% |
| 441 |
%\begin{macro}{tfl@float@cnt} |
| 442 |
% A track is needed of the number of floats created. |
| 443 |
% \begin{macrocode} |
| 444 |
\newcounter{tfl@float@cnt} |
| 445 |
% \end{macrocode} |
| 446 |
%\end{macro} |
| 447 |
%\begin{macro}{\tfl@floatname} |
| 448 |
% The name of the float currently being made. |
| 449 |
% \begin{macrocode} |
| 450 |
\newcommand*{\tfl@floatname}{} |
| 451 |
% \end{macrocode} |
| 452 |
%\end{macro} |
| 453 |
% |
| 454 |
%\begin{macro}{\tfl@chapter} |
| 455 |
%\begin{macro}{\tfl@chapter@hook} |
| 456 |
% A method to add to the \cs{@chapter} macro is needed. This is |
| 457 |
% not compatible with \cs{g@addto@macro} directly, so a more |
| 458 |
% complex method is used by providing a suitable hook. |
| 459 |
% \begin{macrocode} |
| 460 |
\newcommand*{\tfl@chapter@hook}{} |
| 461 |
\newcommand*{\tfl@chapter}{} |
| 462 |
\ifx\@chapter\@undefined\else |
| 463 |
\let\tfl@chapter\@chapter |
| 464 |
\renewcommand*{\@chapter}{% |
| 465 |
\tfl@chapter@hook |
| 466 |
\tfl@chapter |
| 467 |
} |
| 468 |
\fi |
| 469 |
% \end{macrocode} |
| 470 |
%\end{macro} |
| 471 |
%\end{macro} |
| 472 |
%\begin{macro}{\tfl@chapter@fix} |
| 473 |
% So that floats inside chapters work correctly. |
| 474 |
% \begin{macrocode} |
| 475 |
\newcommand*{\tfl@chapter@fix}[2]{% |
| 476 |
\g@addto@macro{\tfl@chapter@hook}{% |
| 477 |
\addtocontents{#2}{\protect\addvspace{10\p@}}% |
| 478 |
}% |
| 479 |
\@ifundefined{KOMAScriptVersion}{% |
| 480 |
\@namedef{the#1}{% |
| 481 |
\ifnum\c@chapter>\z@\relax |
| 482 |
\thechapter.% |
| 483 |
\fi |
| 484 |
\arabic{#1}% |
| 485 |
}% |
| 486 |
}{}% |
| 487 |
} |
| 488 |
% \end{macrocode} |
| 489 |
%\end{macro} |
| 490 |
% |
| 491 |
%\begin{macro}{\tfl@generate@ext} |
| 492 |
%\changes{v1.2}{2007/08/20}{Removed \texttt{los} from list of possible |
| 493 |
% extensions} |
| 494 |
%\begin{macro}{\tfl@ext} |
| 495 |
% Each float type needs a list to store entries when generating a |
| 496 |
% contents listing. Rather than try complex things with the initial |
| 497 |
% characters of the float name, an arbitrary file extension is used. |
| 498 |
% The extensions \texttt{lof}, \texttt{log} and \texttt{lot} are taken |
| 499 |
% by default, so they are not used. The \pkg{chemscheme} package uses |
| 500 |
% \texttt{los}, so this is left alone as well. Also notice that if |
| 501 |
% people try to make too many new float types, then extension |
| 502 |
% \texttt{xxx} will be used. This is very unlikely, but odd things |
| 503 |
% might happen so we warn them. |
| 504 |
% \begin{macrocode} |
| 505 |
\newcommand*{\tfl@generate@ext}{% |
| 506 |
\edef\tfl@ext{% |
| 507 |
\ifcase\value{tfl@float@cnt}% 0 not possible |
| 508 |
\or % 1 |
| 509 |
loa% |
| 510 |
\or % 2 |
| 511 |
lob% |
| 512 |
\or % 3 |
| 513 |
loc% |
| 514 |
\or % 4 |
| 515 |
lod% |
| 516 |
\or % 5 |
| 517 |
loe% |
| 518 |
\or % 6 |
| 519 |
loh% |
| 520 |
\or % 7 |
| 521 |
loi% |
| 522 |
\or % 8 |
| 523 |
loj% |
| 524 |
\or % 9 |
| 525 |
lok% |
| 526 |
\or % 10 |
| 527 |
lol% |
| 528 |
\or % 11 |
| 529 |
lom% |
| 530 |
\or % 12 |
| 531 |
lon% |
| 532 |
\or % 13 |
| 533 |
loo% |
| 534 |
\or % 15 |
| 535 |
loq% |
| 536 |
\or % 16 |
| 537 |
lor% |
| 538 |
\or % 17 |
| 539 |
lou% |
| 540 |
\or % 18 |
| 541 |
lov% |
| 542 |
\or % 19 |
| 543 |
low% |
| 544 |
\or % 20 |
| 545 |
lox% |
| 546 |
\or % 21 |
| 547 |
loy% |
| 548 |
\or % 22 |
| 549 |
loz% |
| 550 |
\else % 23 or more |
| 551 |
\PackageWarning{trivfloat}{% |
| 552 |
I've run out of extensions \MessageBreak |
| 553 |
I'm using \jobname.xxx to list all future floats |
| 554 |
}% |
| 555 |
xxx% |
| 556 |
\fi |
| 557 |
}% |
| 558 |
}% |
| 559 |
% \end{macrocode} |
| 560 |
%\end{macro} |
| 561 |
%\end{macro} |
| 562 |
% |
| 563 |
%\begin{macro}{\tfl@make@float} |
| 564 |
% When using \pkg{float}, definition depends on the existence of |
| 565 |
% chapters. The name and ``list of'' macros are then created separately. |
| 566 |
% \begin{macrocode} |
| 567 |
\newcommand*{\tfl@make@float}[2]{% |
| 568 |
\@ifundefined{chapter}{% |
| 569 |
\newfloat{#1}{tbp}{#2}% |
| 570 |
}{% |
| 571 |
\newfloat{#1}{tbp}{#2}[chapter]% |
| 572 |
\tfl@chapter@fix{#1}{#2}% |
| 573 |
}% |
| 574 |
\floatname{#1}{\@nameuse{#1name}}% |
| 575 |
\@namedef{listof#1s}{% |
| 576 |
\listof{#1}{\@nameuse{list#1name}}% |
| 577 |
}% |
| 578 |
} |
| 579 |
% \end{macrocode} |
| 580 |
%\end{macro} |
| 581 |
% |
| 582 |
%\begin{macro}{\tfl@make@floatrow} |
| 583 |
% For \pkg{floatrow}, the interface to everything is rather simple. The |
| 584 |
% name here cannot use the original macros created by \pkg{trivfloat}, |
| 585 |
% which results in an infinite loop. |
| 586 |
% \begin{macrocode} |
| 587 |
\newcommand*{\tfl@make@floatrow}[2]{% |
| 588 |
\@ifundefined{chapter}{% |
| 589 |
\DeclareNewFloatType{#1}{% |
| 590 |
fileext = #2, |
| 591 |
placement = tbp, |
| 592 |
name = {% |
| 593 |
\tfl@bgroup |
| 594 |
\tfl@name@format |
| 595 |
\tfl@upperfirst#1% |
| 596 |
\tfl@egroup |
| 597 |
} |
| 598 |
}% |
| 599 |
}{% |
| 600 |
\DeclareNewFloatType{#1}{% |
| 601 |
fileext = #2, |
| 602 |
placement = tbp, |
| 603 |
name = {% |
| 604 |
\tfl@bgroup |
| 605 |
\tfl@name@format |
| 606 |
\tfl@upperfirst#1% |
| 607 |
\tfl@egroup |
| 608 |
}, |
| 609 |
within = chapter |
| 610 |
}% |
| 611 |
\tfl@chapter@fix{#1}{#2}% |
| 612 |
}% |
| 613 |
\@namedef{listof#1s}{% |
| 614 |
\listof{#1}{\@nameuse{list#1name}}% |
| 615 |
}% |
| 616 |
} |
| 617 |
% \end{macrocode} |
| 618 |
%\end{macro} |
| 619 |
% |
| 620 |
%\begin{macro}{\tfl@make@memoir} |
| 621 |
% \pkg{memoir} has a lot of things to set up for a float. This list is |
| 622 |
% essentially the same as the \pkg{memoir} kernel uses. |
| 623 |
% \begin{macrocode} |
| 624 |
\newcommand*{\tfl@make@memoir}[2]{% |
| 625 |
\newfloat[chapter]{#1}{#2}{\@nameuse{#1name}}% |
| 626 |
\newlistof{listof#1s}{#2}{\@nameuse{list#1name}}% |
| 627 |
\addtodef{\@smemfront}{}{\counterwithout{#1}{chapter}}% |
| 628 |
\addtodef{\@smemmain}{}{% |
| 629 |
\ifartopt\else |
| 630 |
\counterwithin{#1}{chapter}% |
| 631 |
\fi |
| 632 |
}% |
| 633 |
\addtodef{\backmatter}{}{% |
| 634 |
\ifartopt\else |
| 635 |
\counterwithout{#1}{chapter}% |
| 636 |
\setcounter{#1}{0}% |
| 637 |
\fi |
| 638 |
}% |
| 639 |
\newlistentry[chapter]{#1}{#2}{0}% |
| 640 |
\cftsetindents{#1}{0em}{2.3em}% |
| 641 |
\addtodef{\insertchapterspace}{}{% |
| 642 |
\addtocontents{#2}{\protect\addvspace{10pt}}% |
| 643 |
}% |
| 644 |
\ifartopt |
| 645 |
\counterwithout{#1}{chapter}% |
| 646 |
\fi |
| 647 |
} |
| 648 |
% \end{macrocode} |
| 649 |
%\end{macro} |
| 650 |
% |
| 651 |
%\begin{macro}{\tfl@make@names} |
| 652 |
% The names for things are made in the same way for all float generation |
| 653 |
% methods. The plural here is of course a guess! |
| 654 |
% \begin{macrocode} |
| 655 |
\newcommand*{\tfl@make@names}{% |
| 656 |
\expandafter\edef\csname\tfl@floatname name\endcsname{% |
| 657 |
\noexpand\tfl@bgroup |
| 658 |
\noexpand\tfl@name@format |
| 659 |
\noexpand\tfl@upperfirst\tfl@floatname |
| 660 |
\noexpand\tfl@egroup |
| 661 |
}% |
| 662 |
\expandafter\edef\csname list\tfl@floatname name\endcsname{% |
| 663 |
List of \noexpand\tfl@upperfirst\tfl@floatname s |
| 664 |
}% |
| 665 |
} |
| 666 |
% \end{macrocode} |
| 667 |
%\end{macro} |
| 668 |
% |
| 669 |
%\begin{macro}{\tfl@trivfloat} |
| 670 |
% The internal macro which does the work. The \cs{edef} here makes sure |
| 671 |
% that the name and extension are correct. |
| 672 |
% \begin{macrocode} |
| 673 |
\newcommand*{\tfl@trivfloat}{% |
| 674 |
\stepcounter{tfl@float@cnt}% |
| 675 |
\tfl@generate@ext |
| 676 |
\tfl@make@names |
| 677 |
\begingroup |
| 678 |
\edef\@tempa{% |
| 679 |
\endgroup |
| 680 |
\expandafter\noexpand\tfl@make@execute{% |
| 681 |
\expandafter\noexpand\csname tfl@make@\tfl@make@pkg\endcsname |
| 682 |
{\tfl@floatname}{\tfl@ext}% |
| 683 |
}% |
| 684 |
}% |
| 685 |
\@tempa |
| 686 |
} |
| 687 |
% \end{macrocode} |
| 688 |
%\end{macro} |
| 689 |
% |
| 690 |
%\begin{macro}{\tfl@uppercase} |
| 691 |
%\begin{macro}{\tfl@uppercase@aux} |
| 692 |
%\changes{v1.3a}{2007/08/22}{New macro} |
| 693 |
% To get the correct kerning, a customised version of |
| 694 |
% \cs{MakeUppercase} is needed. The use of |
| 695 |
% \cs{DeclareRobustCommand} here is essential. The change here is that |
| 696 |
% the upper-cased letter is available outside of the group, hence using |
| 697 |
% \cs{tfl@uppercase@aux} rather than \cs{reserved@a} as in the original. |
| 698 |
% \begin{macrocode} |
| 699 |
\newcommand*{\tfl@uppercase}{} |
| 700 |
\DeclareRobustCommand*{\tfl@uppercase}[1]{% |
| 701 |
{% |
| 702 |
\def\i{I}% |
| 703 |
\def\j{J}% |
| 704 |
\def\reserved@a##1##2{\let##1##2\reserved@a}% |
| 705 |
\expandafter\reserved@a\@uclclist\reserved@b{\reserved@b\@gobble}% |
| 706 |
\protected@edef\tfl@uppercase@aux{\uppercase{#1}}% |
| 707 |
\expandafter}% |
| 708 |
\tfl@uppercase@aux |
| 709 |
} |
| 710 |
\newcommand*{\tfl@uppercase@aux}{} |
| 711 |
% \end{macrocode} |
| 712 |
%\end{macro} |
| 713 |
%\end{macro} |
| 714 |
%\begin{macro}{\tfl@upperfirst} |
| 715 |
%\changes{v1.2}{2007/08/20}{Made names change case correctly} |
| 716 |
%\changes{v1.3}{2007/08/21}{Replaces \cs{tfl@genname} and |
| 717 |
% \cs{tfl@gennamea}} |
| 718 |
%\changes{v1.3}{2007/08/21}{New macro} |
| 719 |
%\changes{v1.3a}{2007/08/22}{Uses modified version of |
| 720 |
% \cs{MakeUppercase}} |
| 721 |
% As suggested by Ulrich Diez, this is an improved method for making |
| 722 |
% case changes than the previous version (v1.2). Notice that it does |
| 723 |
% mean that the user is responsible for the case of everything except |
| 724 |
% the first letter. |
| 725 |
% \begin{macrocode} |
| 726 |
\newcommand*{\tfl@upperfirst}[1]{% |
| 727 |
\protect\@gobble\noexpand\tfl@uppercase#1% |
| 728 |
} |
| 729 |
% \end{macrocode} |
| 730 |
%\end{macro} |
| 731 |
% |
| 732 |
%\begin{macro}{\trivfloat} |
| 733 |
%\changes{v1.3}{2007/08/21}{Removed redundant numeral-based code} |
| 734 |
%\changes{v1.4}{2009/04/23}{Extended to accept a comma-separated list} |
| 735 |
% The user \cs{trivfloat} macro works by looping over each new float and |
| 736 |
% calling the internal macro \cs{tfl@trivfloat} |
| 737 |
% \begin{macrocode} |
| 738 |
\newcommand*{\trivfloat}[1]{% |
| 739 |
\@for\tfl@floatname:=#1\do{% |
| 740 |
\tfl@trivfloat |
| 741 |
}% |
| 742 |
} |
| 743 |
\@onlypreamble\trivfloat |
| 744 |
% \end{macrocode} |
| 745 |
%\end{macro} |
| 746 |
% |
| 747 |
%\begin{macro}{\tfl@bgroup} |
| 748 |
%\begin{macro}{\tfl@egroup} |
| 749 |
%\begin{macro}{\tfl@name@format} |
| 750 |
% When using \pkg{babel} in French, the caption format gets changed. |
| 751 |
% This has to be tested twice: once to see if \pkg{babel} was loaded |
| 752 |
% before \pkg{trivfloat} and once afterwards. |
| 753 |
% \begin{macrocode} |
| 754 |
\newcommand*{\tfl@bgroup}{} |
| 755 |
\let\tfl@bgroup\relax |
| 756 |
\newcommand*{\tfl@egroup}{} |
| 757 |
\let\tfl@egroup\relax |
| 758 |
\newcommand*{\tfl@name@format}{} |
| 759 |
\let\tfl@name@format\relax |
| 760 |
\AtBeginDocument{% |
| 761 |
\@ifpackageloaded{babel}{% |
| 762 |
\iflanguage{french}{% |
| 763 |
\let\floatc@plain\FB@makecaption |
| 764 |
\let\tfl@bgroup\bgroup |
| 765 |
\let\tfl@egroup\egroup |
| 766 |
\let\tfl@name@format\scshape |
| 767 |
}{}% |
| 768 |
}{}% |
| 769 |
}% |
| 770 |
%</package> |
| 771 |
% \end{macrocode} |
| 772 |
%\end{macro} |
| 773 |
%\end{macro} |
| 774 |
%\end{macro} |
| 775 |
% |
| 776 |
%\Finale |