summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/bropd
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-11-05 22:22:14 +0000
committerKarl Berry <karl@freefriends.org>2012-11-05 22:22:14 +0000
commitf63d5d0d6e975dd39c2a0f552930c31a1b610ce2 (patch)
tree80fd0282dd01d9e04f3b5414202f1eca9dc7e9a5 /Master/texmf-dist/source/latex/bropd
parent64f608b9332fd05ba825ad7990566164b40b9f23 (diff)
brodp -> bropd
git-svn-id: svn://tug.org/texlive/trunk@28182 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/bropd')
-rw-r--r--Master/texmf-dist/source/latex/bropd/bropd.dtx258
1 files changed, 258 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/bropd/bropd.dtx b/Master/texmf-dist/source/latex/bropd/bropd.dtx
new file mode 100644
index 00000000000..0d809486e86
--- /dev/null
+++ b/Master/texmf-dist/source/latex/bropd/bropd.dtx
@@ -0,0 +1,258 @@
+% \iffalse The license starting on line four applies to this file
+%<*batchfile>
+{\obeylines\obeyspaces \gdef\thepreamble{
+
+Copyright 2012 by Benjamin Tatlock
+
+This work may be distributed and/or modified under the conditions of the
+LaTeX Project Public License, either version 1.3 of this license or (at your
+option) any later version. The latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+and version 1.3 or later is part of all distributions of LaTeX version
+2005/12/01 or later.
+
+This work has the LPPL maintenance status `maintained'.
+
+The Current Maintainer of this work is Benjamin Tatlock.
+
+This work consists of the file bropd.dtx and the derived files bropd.sty and
+bropd.pdf.
+}}
+\begingroup
+\input docstrip
+\keepsilent
+\expandafter\preamble\thepreamble\endpreamble
+\generate{\file{bropd.sty}{\from{bropd.dtx}{}}}
+\endgroup
+\documentclass{ltxdoc}
+\usepackage{bropd,ifpdf}
+\GetFileInfo{bropd.sty}
+\title{The \textsf{bropd} package\thanks{This documentation corresponds to
+\textsf{bropd}~v\fileversion, dated \filedate.}}
+\author{Benjamin Tatlock}
+\newenvironment{verba}{\begin{verbatim}}{\end{verbatim}}
+\begin{document}
+\maketitle
+\begin{abstract}
+The \textsf{bropd} package simplifies the process of writing differential
+operators and brackets in \LaTeX. The commands facilitate the easy manipulation
+of equations involving brackets and allow partial differentials to be expressed
+in an alternate form.
+\end{abstract}
+\section{Introduction}
+The \textsf{bropd} package introduces a bracket command that automatically
+selects parentheses, square brackets or braces as appropriate based on the
+number of brackets. As such, brackets can be freely added and removed without
+alterations to the rest an equation. A command for writing ordinary and partial
+differentials is also created with an optional concise form for typesetting
+partial derivatives. This allows equations to be typed in a standard form and
+their style altered globally at a later date.
+\section{Usage}
+This section outlines the use of the three commands provided by the
+\textsf{bropd} package.
+\subsection{Brackets}
+The bracket command replaces \verb|\left(| and \verb|\right)| with the single
+command, \verb|\br| to produce brackets in a math environment. The input
+\verb|\br{x}| produces\[\br{x}.\]When nested, the type of bracket is determined
+automatically, for example, \verb|r=\br{\br{x-a}^2+\br{y-b}^2}^{\frac{1}{2}}|
+results in\[r=\br{\br{x-a}^2+\br{y-b}^2}^{\frac{1}{2}}.\]
+\subsection{Differential operators}
+\subsubsection{Ordinary differential}
+The \verb|\od| command produces ordinary differentials, such as \verb|\od{y}{x}|
+which is displayed as\[\od{y}{x}.\]The order of the differential can be
+specified as an optional argument, illustrated here with the command
+\verb|\od[2]{u}{x}=-\omega^2u| which results in\[\od[2]{u}{x}=-\omega^2u.\]When
+using \verb|\od| with a sans-serif font, the package should be loaded with the
+optional argument \verb|sans|.\subsubsection{Partial differential}The command
+\verb|\pd| follows the same form as \verb|\od|, but instead produces partial
+differentials. By default \verb|\pd{u}{t}=6u\pd{u}{x}-\pd[3]{u}{x}|
+produces\[\pd{u}{t}=6u\pd{u}{x}-\pd[3]{u}{x}.\]Loading the package with the
+option \verb|pdshort| results in an alternative format for partial
+differentials:\[u_t=6uu_x-u_{xxx}\]Note that when using this form, the
+\verb|\br| function \emph{must} follow \verb|\pd| when the first argument is
+left empty, as demonstrated by \verb|\pd{}{z}\br{x+y}| which results
+in\[\br{x+y}_z.\]If the optional argument is not a positive integer, the default
+form is reverted to, as with \verb|\pd[n]xy|:\[\pd[n]xy\]The syntax for partial
+differentials is extended to allow the second order term such
+as\[\pd{u}{x,t}\]to be easily typeset with \verb|\pd{u}{x,t}|.
+\subsection{Further examples}
+Combining the commands provided by this package allows more complex terms to be
+written concisely. The \verb|\br| allows equations with multiple brackets to be
+constructed and manipulated quickly and easily. An example of this is
+\verb|\br{x-y}\br{Q-\frac12\br{P+\br{x-1}\br{\br{A+B}\br{u+c}-t}}}|, which
+results in\[\br{x-y}\br{Q-\frac12\br{P+\br{x-1}\br{\br{A+B}\br{u+c}-t}}}.\]
+The form of the partial differentials written with the \verb|\pd| command can be
+changed at any time.\verb|\pd Et+\sum_{i=1}^3\pd{}{x_i}\br{\br{E+p}u_i}|
+produces\[\pd Et+\sum_{i=1}^3\pd{}{x_i}\br{\br{E+p}u_i}\]
+or, with \verb|pdshort|,\[E_t+\sum_{i=1}^3\br{\br{E+p}u_i}_{x_i}.\]
+\StopEventually{\typeout{**************************************************}
+\typeout{*}
+\typeout{* To finish the installation, you have to move the}
+\typeout{* following file into a directory searched by TeX:}
+\typeout{*}
+\typeout{* \space\space bropd.sty}
+\typeout{*}
+\typeout{* Documentation is in bropd.\ifpdf pdf\else dvi\fi.}
+\typeout{*}
+\typeout{**************************************************}\end{document}}
+\clearpage
+\DocInput{bropd.dtx}
+\clearpage
+\Finale
+%</batchfile>
+% \fi
+% \section{Implementation}
+% Announce the name, package version and \LaTeXe\ requirement
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{bropd}
+[2012/11/04 1.0 automated typing of brackets and differential operators]
+% \end{macrocode}
+% Initiate conditionals and counters
+% \begin{macrocode}
+\newif\if@bropd@a\newif\if@bropd@b\newif\if@bropd@s
+\newcounter{@bropd@c}\newcounter{@bropd@d}
+\newcounter{@bropd@e}\newcounter{@bropd@f}
+% \end{macrocode}
+% Provide optional arguments for alternative form partial differential and
+% sans-serif fonts
+% \begin{macrocode}
+\DeclareOption{pdshort}{\@bropd@atrue}
+\DeclareOption{sans}{\@bropd@strue}\ProcessOptions
+% \end{macrocode}
+% Internal command for default partial differential form
+% \begin{macrocode}
+\newcommand\@bropd@g[4]{\def\@bropd@h{#1}
+\ifx\@bropd@h\empty
+\setcounter{@bropd@c}0\setcounter{@bropd@d}1
+\let\@bropd@h\empty
+% \end{macrocode}
+% Determine order of partial derivative and display as power of partial if
+% greater than one
+% \begin{macrocode}
+\@for\@bropd@i:=#3\do{\stepcounter{@bropd@c}}
+\frac{#4\ifnum\value{@bropd@c}>1
+^{\arabic{@bropd@c}}\fi#2}
+% \end{macrocode}
+% Cycle through each term for the denominator. If a term is the same as the
+% previous, add to counter, otherwise print along with counter value
+% \begin{macrocode}
+{\@for\@bropd@i:=#3\do{
+\ifx\@bropd@i\@bropd@h
+\stepcounter{@bropd@d}
+\else
+\@bropd@h
+\ifnum\value{@bropd@d}>1
+^{\arabic{@bropd@d}}
+\fi
+#4\setcounter{@bropd@d}1
+\fi
+\let\@bropd@h\@bropd@i}
+\@bropd@h
+\ifnum\value{@bropd@d}>1
+^{\arabic{@bropd@d}}\fi}
+\else
+% \end{macrocode}
+% If optional argument provided, display partial differential to stated order
+% \begin{macrocode}
+\frac{#4^{#1}#2}{#4#3^{#1}}
+\fi}
+% \end{macrocode}
+% Internal command for brackets. Evaluate terms within brackets to determine
+% the highest bracket level
+% \begin{macrocode}
+\newcommand\@bropd@j[1]{\setcounter{@bropd@f}0
+{\renewcommand{\br}[1]{\stepcounter{@bropd@e}{##1}
+\ifnum\value{@bropd@e}>\value{@bropd@f}
+\setcounter{@bropd@f}{\value{@bropd@e}}
+\fi
+\addtocounter{@bropd@e}{-1}}\sbox0{$#1$}}
+\loop
+\ifnum\value{@bropd@f}>2
+\addtocounter{@bropd@f}{-3}
+\repeat
+% \end{macrocode}
+% Detemine bracket type for current level
+% \begin{macrocode}
+\ifnum\value{@bropd@f}>0
+\ifnum\value{@bropd@f}>1
+\def\@bropd@k{\left\lbrace#1\right\rbrace}
+\else
+\def\@bropd@k{\left[#1\right]}
+\fi
+\else
+\def\@bropd@k{\left(#1\right)}
+\fi}
+\if@bropd@a
+\let\@bropd@l\empty
+% \end{macrocode}
+% External bracket command
+% \begin{macrocode}
+\newcommand\br[1]{\let\@bropd@m\@bropd@l
+\@bropd@j{\let\@bropd@l\empty#1\let\@bropd@l\@bropd@m}
+\ifx\@bropd@l\empty
+\def\@bropd@n{\@bropd@k}
+\else
+\let\@bropd@m\@bropd@l
+\def\@bropd@n{\@bropd@k_{\@bropd@m}}
+\fi
+\let\@bropd@l\empty
+\@bropd@n}
+% \end{macrocode}
+% External command for alternative partial differential command
+% \begin{macrocode}
+\newcommand\pd[3][]{\def\@bropd@h{#1}
+\ifx\@bropd@h\empty
+\@bropd@bfalse
+\else
+% \end{macrocode}
+% Default partial differential if character provided as optional argument
+% \begin{macrocode}
+\if!\ifnum9<1#1!\else_\fi
+\@bropd@bfalse
+\else
+\@bropd@btrue
+\fi
+\fi
+\if@bropd@b\@bropd@g{#1}{#2}{\noexpand#3}\partial
+\else
+% \end{macrocode}
+% Construct alternate form partial differential
+% \begin{macrocode}
+\def\@bropd@o{#2}
+\def\@bropd@p{\ifx\@bropd@h\empty
+\@for\@bropd@i:=#3\do\@bropd@i\else\setcounter{@bropd@c}0
+\loop
+\ifnum\value{@bropd@c}<#1
+#3\stepcounter{@bropd@c}
+\repeat
+\fi}
+\ifx\@bropd@o\empty
+\let\@bropd@l\@bropd@p\else{#2}{_{\@bropd@p}}\fi\fi}
+\else
+% \end{macrocode}
+% External command for default partial differentials
+% \begin{macrocode}
+\newcommand\pd[3][]{\@bropd@g{#1}{#2}{\noexpand#3}\partial}
+% \end{macrocode}
+% External command for brackets
+% \begin{macrocode}
+\newcommand\br[1]{\@bropd@j{#1}\@bropd@k}
+\fi
+% \end{macrocode}
+% Format ordinary differential based on font type
+% \begin{macrocode}
+\if@bropd@s
+\newcommand\@bropd@r{\mathsf{d}}
+\else
+\newcommand\@bropd@r{\mathrm{d}}
+\fi
+% \end{macrocode}
+% External command for ordinary differentials
+% \begin{macrocode}
+\newcommand\od[3][]{\def\@bropd@h{#1}
+\frac{\@bropd@r\ifx\@bropd@h\empty\else^{#1}\fi#2}
+{\@bropd@r#3\ifx\@bropd@h\empty\else^{#1}\fi}}
+\endinput
+% \end{macrocode}
+% \endinput