summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/trivfloat/trivfloat.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2007-06-17 23:25:09 +0000
committerKarl Berry <karl@freefriends.org>2007-06-17 23:25:09 +0000
commit511b03aa4ca8c27384178598e449388afd251f9c (patch)
treefe616d9c6c6435dc49ad53bfce073e692784a130 /Master/texmf-dist/source/latex/trivfloat/trivfloat.dtx
parent01d27f3a5e3fe5d21a3d5aec43fd2a489783f881 (diff)
new package trivfloat (11jun07)
git-svn-id: svn://tug.org/texlive/trunk@4462 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/trivfloat/trivfloat.dtx')
-rw-r--r--Master/texmf-dist/source/latex/trivfloat/trivfloat.dtx271
1 files changed, 271 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/trivfloat/trivfloat.dtx b/Master/texmf-dist/source/latex/trivfloat/trivfloat.dtx
new file mode 100644
index 00000000000..77bce625633
--- /dev/null
+++ b/Master/texmf-dist/source/latex/trivfloat/trivfloat.dtx
@@ -0,0 +1,271 @@
+% \iffalse meta-comment
+%
+% Copyright (C) 2007 by
+% Joseph Wright <joseph.wright@morningstar2.co.uk>
+%
+% Released under the GNU General Public License v2
+% See http://www.gnu.org/licenses/gpl.txt
+%
+% This work consists of the main source file chemextra.dtx
+% and the derived files
+%
+%<*driver>
+\documentclass{ltxdoc}
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+%\OnlyDescription
+\usepackage[T1]{fontenc}
+\usepackage[english,UKenglish]{babel}
+\usepackage{mathpazo,booktabs,array,url}
+\usepackage{\jobname}
+\begin{document}
+ \DocInput{\jobname.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \CheckSum{107}
+%
+% \CharacterTable
+% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+% Digits \0\1\2\3\4\5\6\7\8\9
+% Exclamation \! Double quote \" Hash (number) \#
+% Dollar \$ Percent \% Ampersand \&
+% Acute accent \' Left paren \( Right paren \)
+% Asterisk \* Plus \+ Comma \,
+% Minus \- Point \. Solidus \/
+% Colon \: Semicolon \; Less than \<
+% Equals \= Greater than \> Question mark \?
+% Commercial at \@ Left bracket \[ Backslash \\
+% Right bracket \] Circumflex \^ Underscore \_
+% Grave accent \` Left brace \{ Vertical bar \|
+% Right brace \} Tilde \~}
+%
+% \GetFileInfo{\jobname.sty}
+%
+% \changes{v1.0}{2007/06/09}{Initial public release}
+%
+% \DoNotIndex{\@eha,\@ne,\advance,\begingroup,\csname,\def,\edef}
+% \DoNotIndex{\else,\end,\endcsname,\endgroup,\expandafter,\fi}
+% \DoNotIndex{\ifcase,\jobname,\MakeLowercase,\MakeUppercase}
+% \DoNotIndex{\MessageBreak,\NeedsTeXFormat,\newcommand,\newcount}
+% \DoNotIndex{\noexpand,\or,\PackageError,\PackageInfo}
+% \DoNotIndex{\PackageWarning,\ProvidesPackage,\RequirePackage}
+% \DoNotIndex{\romannumeral,\x}
+%
+% \title{Quick floats in LaTeX}
+% \author{Joseph Wright%
+% \thanks{E-mail: joseph.wright@morningstar2.co.uk}}
+% \date{\filedate}
+%
+% \maketitle
+%
+% \begin{abstract}
+%
+% The |trivfloat| package provides a quick method for defining new
+% float types in LaTeX. A single command sets up a new float in the
+% same style as the LaTeX kernel |figure| and |table| float types.
+%
+% \end{abstract}
+%
+% \section{Introduction}
+%
+% The LaTeX kernel provides the |figure| and |table| floating
+% environment, but does not provide an easy method for defining new
+% float types. This problem is addressed by the |float| package,
+% which provides an array of commands to create new float types.
+% However, the one command missing is a quick-and-dirty one to
+% set up a new float type with no customisation. This is addressed
+% by the |trivfloat| package.
+%
+% \section{Usage}
+%
+% \DescribeMacro{\trivfloat}
+% \DescribeMacro{\listoffloat-names}
+% The package provides a single command to produce the new float
+% type, |\trvifloat|. This takes a single argument
+% \marg{float-name}, which will be the name of the new floating
+% environment. The new environment can be used as normal; the new
+% floats should behave exactly the same as |figure| and |table|
+% environments. The command |\listof|\meta{float-name}|s| is also
+% provided.
+%
+% \StopEventually{}
+%
+% \iffalse
+%<*package>
+% \fi
+%
+% \section{Implementation}
+%
+% \subsection{Setup code}
+%
+% The first part of the package is concerned with basic
+% identification and loading support packages.
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{trivfloat}
+ [2007/06/09 v1.0 Quick floats in LaTeX]
+\RequirePackage{float}
+% \end{macrocode}
+%
+% \subsection{Internal macros}
+%
+% \begin{macro}{\tfl@floatcount}
+% A new counter is needed to track how many floats have been
+% generated by |trivfloat|.
+% \begin{macrocode}
+\newcount\tfl@floatcount%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\tfl@genext}
+% \begin{macro}{\tfl@ext@i}
+% Each float type needs a list to store entries when generating
+% a contents listing. Rather than try complex things with the
+% initial characters of the float name, an arbitrary file extension
+% is used. Note that |lof|, |log| and |lot| are taken by default,
+% so we don't use them. Also notice that if people try to make too
+% many new float types, then extension |xxx| will be used. This is
+% very unlikely, but odd things might happen so we warn them.
+% \begin{macrocode}
+\def\tfl@genext{%
+ \expandafter\def\csname tfl@ext@\romannumeral\tfl@floatcount%
+ \expandafter\endcsname{%
+ \ifcase\tfl@floatcount%
+ \PackageError{trivfloat}%
+ {Something's wrong here --- Contact the package author!}%
+ \@eha%
+ \or % 1
+ loa%
+ \or % 2
+ lob%
+ \or % 3
+ loc%
+ \or % 4
+ lod%
+ \or % 5
+ loe%
+ \or % 6
+ loh%
+ \or % 7
+ loi%
+ \or % 8
+ loj%
+ \or % 9
+ lok%
+ \or % 10
+ lol%
+ \or % 11
+ lom%
+ \or % 12
+ lon%
+ \or % 13
+ loo%
+ \or % 15
+ loq%
+ \or % 16
+ lor%
+ \or % 17
+ los%
+ \or % 18
+ lou%
+ \or % 19
+ lov%
+ \or % 20
+ low%
+ \or % 21
+ lox%
+ \or % 22
+ loy%
+ \or % 23
+ loz%
+ \else % 24 or more
+ \PackageWarning{trivfloat}%
+ {I've run out of extensions \MessageBreak%
+ I'm using \jobname.xxx to list all future floats}%
+ xxx%
+ \fi%
+ }%
+}%
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\tfl@gennamea}
+% \begin{macro}{\tfl@genname}
+% \begin{macro}{\tfl@name@i}
+% The conversion of the supplied float name to a form suitable for
+% using as a title is achieved here. We strip off the first letter,
+% convert to uppercase, then convert the rest to lowercase. Thanks
+% to Martin Heller for the method to strip the first letter off.
+% \begin{macrocode}
+\def\tfl@gennamea#1#2\end{%
+ \expandafter\def\csname tfl@name@\romannumeral\tfl@floatcount%
+ \expandafter\endcsname{%
+ \MakeUppercase{#1}%
+ \MakeLowercase{#2}%
+ }%
+}%
+\def\tfl@genname#1{%
+ \tfl@gennamea#1\end%
+}%
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\tfl@list}
+% \begin{macro}{\listoffloat-names}
+% An auxiliary function is needed to define the
+%|\listof\emph{float-name}s| macros. This is to ensure that
+% expansion occurs properly.
+% \begin{macrocode}
+\def\tfl@list#1#2#3{%
+ \newcommand*{#1}{\listof{#2}{#3}}%
+}%
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{User space macros}
+%
+% \begin{macro}{\trivfloat}
+% The only user-facing macro we need is |\trivfloat|. This does the
+% work of setting up the new float type. Thanks to Heiko Oberdiek for
+% the method to expand arguments correctly. Notice that a single
+% command for the extension would work. However, the float name does
+% need different commands for each float. So for consistency, both
+% have numerals appended.
+% \begin{macrocode}
+\newcommand*{\trivfloat}[1]{%
+ \advance\tfl@floatcount\@ne%
+ \tfl@genext%
+ \tfl@genname{#1}%
+ \PackageInfo{trivfloat}%
+ {Listing all floats of type #1 in \jobname.%
+ \csname tfl@ext@\romannumeral\tfl@floatcount\endcsname}%
+ \begingroup%
+ \edef\x{\endgroup%
+ \noexpand\newfloat{#1}{tbp}{%
+ \csname tfl@ext@\romannumeral\tfl@floatcount\endcsname%
+ }%
+ \noexpand\floatname{#1}{%
+ \expandafter\noexpand%
+ \csname tfl@name@\romannumeral\tfl@floatcount\endcsname%
+ }%
+ \noexpand\tfl@list{\csname listof#1s\endcsname}{#1}{%
+ List of \expandafter\noexpand%
+ \csname tfl@name@\romannumeral\tfl@floatcount\endcsname s%
+ }%
+ }%
+ \x%
+}%
+% \end{macrocode}
+% \end{macro}
+%
+% \iffalse
+%</package>
+% \fi
+% \PrintChanges
+% \PrintIndex
+% \Finale