summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/bropd
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-11-10 00:47:21 +0000
committerKarl Berry <karl@freefriends.org>2012-11-10 00:47:21 +0000
commit66d38b59401f47f68453dae0772d40329da9704e (patch)
tree062fd0453e9b05b68b2a8dd0bd9631dd7b3f882d /Master/texmf-dist/source/latex/bropd
parent723027aa71581306fc669ced6dd3f027f3be8bb4 (diff)
bropd (9nov12)
git-svn-id: svn://tug.org/texlive/trunk@28222 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/bropd')
-rw-r--r--Master/texmf-dist/source/latex/bropd/bropd.dtx186
1 files changed, 143 insertions, 43 deletions
diff --git a/Master/texmf-dist/source/latex/bropd/bropd.dtx b/Master/texmf-dist/source/latex/bropd/bropd.dtx
index 0d809486e86..7cdca792709 100644
--- a/Master/texmf-dist/source/latex/bropd/bropd.dtx
+++ b/Master/texmf-dist/source/latex/bropd/bropd.dtx
@@ -22,31 +22,40 @@ bropd.pdf.
\input docstrip
\keepsilent
\expandafter\preamble\thepreamble\endpreamble
+\askforoverwritefalse
\generate{\file{bropd.sty}{\from{bropd.dtx}{}}}
\endgroup
\documentclass{ltxdoc}
-\usepackage{bropd,ifpdf}
+\usepackage{bropd,color,ifpdf}
+\DoNotIndex{\def}
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
\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}}
+\def\auth{Benjamin Tatlock}
+\author{\auth\thanks{\texttt{\kern2.5em\textcolor{white}
+{\char101\char109\char97\char105\char108}\kern-5em\auth\kern-4em\char46\kern
+3.5em\char64\textcolor{white}{bropd}\kern-1em\char108\kern-1em\char105\
+\kern-2em\char109\char97\kern1em\char46\textcolor{white}
+{\char111\char114\char103}\kern-2em\ com}}}
\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.
+in alternate forms.
\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.
+alterations to the rest of an equation. Commands for typing ordinary and partial
+differentials are also created, with two optional concise forms for partial
+derivatives. Equations can therefore be written 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.
@@ -63,28 +72,34 @@ 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}|
+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}|.
+differentials:\[u_t=6uu_x-u_{xxx}\]If the optional argument is not a positive
+integer, the default form is reverted to, as with \verb|\pd[n]xy|:\[\pd[n]xy\]A
+second alternative form is produced when the option \verb|pdalt| is
+specified:\[\partial_tu=6u\partial_xu-\partial_{xxx}u\]The syntax for partial
+differentials is extended to allow higher order terms such
+as\[\pd{u}{x,x,t}\]to be easily typeset with \verb|\pd{u}{x,x,t}|. When applying
+a partial derivative to a longer term, the first argument can be left blank and
+the longer string written as an additional argument, as demonstrated by
+\verb|\pd{}{z}{x+y}| which results in\[\pd{}{z}{x+y}.\]To prevent brackets from
+being placed after a partial differential with an empty numerator, use
+\verb|!| for the first argument, for example, \verb|\pd{!}{x}|:\[\pd{!}{x}\]
\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}.\]
+\verb|\br{x-y}\br{Q-\frac12\br{P+\br{x-1}\br{\br{a+b}\br{u+c}-\od st}}}|, which
+results in\[\br{x-y}\br{Q-\frac12\br{P+\br{x-1}\br{\br{A+B}\br{u+c}-\od st}}}.\]
+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{E+p}u_i}|
+produces\[\pd Et+\sum_{i=1}^3\pd{}{x_i}{\br{E+p}u_i}\]by default. With
+\verb|pdshort|, the same input instead
+creates\[E_t+\sum_{i=1}^3\br{\br{E+p}u_i}_{x_i},\]while with \verb|pdalt| the
+output is\[\partial_tE+\sum_{i=1}^3\partial_{x_i}\br{\br{E+p}u_i}.\]
\StopEventually{\typeout{**************************************************}
\typeout{*}
\typeout{* To finish the installation, you have to move the}
@@ -98,31 +113,46 @@ or, with \verb|pdshort|,\[E_t+\sum_{i=1}^3\br{\br{E+p}u_i}_{x_i}.\]
\clearpage
\DocInput{bropd.dtx}
\clearpage
+\PrintChanges
\Finale
%</batchfile>
% \fi
% \section{Implementation}
% Announce the name, package version and \LaTeXe\ requirement
+% \changes{v1.0}{2012/11/04}{Initial version}
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{bropd}
-[2012/11/04 1.0 automated typing of brackets and differential operators]
+[2012/11/08 1.1 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
+\newif\if@bropd@a\newif\if@bropd@b\newif\if@bropd@s\newif\if@bropd@u
\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{pdshort}{\@bropd@atrue\@bropd@ufalse}
+\DeclareOption{pdalt}{\@bropd@atrue\@bropd@utrue}
\DeclareOption{sans}{\@bropd@strue}\ProcessOptions
% \end{macrocode}
+% Define character for \verb|\pd| with empty numerator and no brackets following
+% \begin{macrocode}
+\def\@bropd@t{!}
+% \end{macrocode}
+% \begin{macro}{\@bropd@g}
% Internal command for default partial differential form
% \begin{macrocode}
-\newcommand\@bropd@g[4]{\def\@bropd@h{#1}
+\def\@bropd@g#1#2#3#4{\def\@bropd@h{#1}
+% \end{macrocode}
+% Create numerator
+% \begin{macrocode}
+\ifx\@bropd@o\@bropd@t\let\@bropd@o\empty\fi
+% \end{macrocode}
+% Reset counters
+% \begin{macrocode}
\ifx\@bropd@h\empty
\setcounter{@bropd@c}0\setcounter{@bropd@d}1
\let\@bropd@h\empty
@@ -132,9 +162,9 @@ or, with \verb|pdshort|,\[E_t+\sum_{i=1}^3\br{\br{E+p}u_i}_{x_i}.\]
% \begin{macrocode}
\@for\@bropd@i:=#3\do{\stepcounter{@bropd@c}}
\frac{#4\ifnum\value{@bropd@c}>1
-^{\arabic{@bropd@c}}\fi#2}
+^{\arabic{@bropd@c}}\fi\@bropd@o}
% \end{macrocode}
-% Cycle through each term for the denominator. If a term is the same as the
+% 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{
@@ -154,14 +184,18 @@ or, with \verb|pdshort|,\[E_t+\sum_{i=1}^3\br{\br{E+p}u_i}_{x_i}.\]
\else
% \end{macrocode}
% If optional argument provided, display partial differential to stated order
+% \changes{v\fileversion}\filedate{Fixed higher order differentials with
+% denominators containing commands}
% \begin{macrocode}
-\frac{#4^{#1}#2}{#4#3^{#1}}
+\frac{#4^{#1}\@bropd@o}{#4\noexpand#3^{#1}}
\fi}
% \end{macrocode}
-% Internal command for brackets. Evaluate terms within brackets to determine
+% \end{macro}
+% \begin{macro}{\@bropd@j}
+% Internal command for brackets. Evaluate terms within brackets to determine
% the highest bracket level
% \begin{macrocode}
-\newcommand\@bropd@j[1]{\setcounter{@bropd@f}0
+\def\@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}}
@@ -186,7 +220,9 @@ or, with \verb|pdshort|,\[E_t+\sum_{i=1}^3\br{\br{E+p}u_i}_{x_i}.\]
\if@bropd@a
\let\@bropd@l\empty
% \end{macrocode}
-% External bracket command
+% \end{macro}
+% \begin{macro}{\br}
+% External command for brackets
% \begin{macrocode}
\newcommand\br[1]{\let\@bropd@m\@bropd@l
\@bropd@j{\let\@bropd@l\empty#1\let\@bropd@l\@bropd@m}
@@ -198,15 +234,22 @@ or, with \verb|pdshort|,\[E_t+\sum_{i=1}^3\br{\br{E+p}u_i}_{x_i}.\]
\fi
\let\@bropd@l\empty
\@bropd@n}
+\if@bropd@u
% \end{macrocode}
-% External command for alternative partial differential command
+% \end{macro}
+% \begin{macro}{\@bropd@q}
+% Internal command for first alternative partial differential command
+% \changes{v\fileversion}\filedate{Added second alternative form for partial
+% differentials}
% \begin{macrocode}
-\newcommand\pd[3][]{\def\@bropd@h{#1}
+\def\@bropd@q#1#2#3{\def\@bropd@h{#1}
\ifx\@bropd@h\empty
\@bropd@bfalse
\else
% \end{macrocode}
% Default partial differential if character provided as optional argument
+% \changes{v\fileversion}\filedate{Allowed partial differential with empty
+% numerator without need for bracket command after}
% \begin{macrocode}
\if!\ifnum9<1#1!\else_\fi
\@bropd@bfalse
@@ -214,12 +257,48 @@ or, with \verb|pdshort|,\[E_t+\sum_{i=1}^3\br{\br{E+p}u_i}_{x_i}.\]
\@bropd@btrue
\fi
\fi
-\if@bropd@b\@bropd@g{#1}{#2}{\noexpand#3}\partial
+\ifx\@bropd@o\@bropd@t
+\@bropd@btrue\let\@bropd@o\empty
+\fi
+\if@bropd@b\@bropd@g{#1}\@bropd@o{\noexpand#3}\partial
+\else
+% \end{macrocode}
+% Construct alternate form partial differential
+% \begin{macrocode}
+\partial_{\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}
+\@bropd@o
+\fi}
+\else
+% \end{macrocode}
+% Internal command for second alternative partial differential command
+% \begin{macrocode}
+\def\@bropd@q#1#2#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
+\ifx\@bropd@o\@bropd@t
+\@bropd@btrue\let\@bropd@o\empty
+\fi
+\if@bropd@b\@bropd@g{#1}\@bropd@o{\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
@@ -228,26 +307,46 @@ or, with \verb|pdshort|,\[E_t+\sum_{i=1}^3\br{\br{E+p}u_i}_{x_i}.\]
\repeat
\fi}
\ifx\@bropd@o\empty
-\let\@bropd@l\@bropd@p\else{#2}{_{\@bropd@p}}\fi\fi}
+\let\@bropd@l\@bropd@p\else{\@bropd@o}{_{\@bropd@p}}\fi\fi}
+\fi
\else
% \end{macrocode}
-% External command for default partial differentials
+% Internal command for default partial differentials
% \begin{macrocode}
-\newcommand\pd[3][]{\@bropd@g{#1}{#2}{\noexpand#3}\partial}
+\def\@bropd@q#1#2#3{\@bropd@g{#1}{#2}{\noexpand#3}\partial}
% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\br}
% External command for brackets
% \begin{macrocode}
\newcommand\br[1]{\@bropd@j{#1}\@bropd@k}
\fi
% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\pd}
+% \changes{v\fileversion}\filedate{Brackets automatically added after empty
+% numerator}
+% \begin{macrocode}
+\newcommand\pd[3][]{\def\@bropd@o{#2}
+\ifx\@bropd@o\empty
+\let\@bropd@v\br
+\else
+\let\@bropd@v\empty
+\fi
+\@bropd@q{#1}{#2}{#3}\@bropd@v}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\@bropd@r}
% Format ordinary differential based on font type
% \begin{macrocode}
\if@bropd@s
-\newcommand\@bropd@r{\mathsf{d}}
+\def\@bropd@r{\mathsf d}
\else
-\newcommand\@bropd@r{\mathrm{d}}
+\def\@bropd@r{\mathrm d}
\fi
% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\od}
% External command for ordinary differentials
% \begin{macrocode}
\newcommand\od[3][]{\def\@bropd@h{#1}
@@ -255,4 +354,5 @@ or, with \verb|pdshort|,\[E_t+\sum_{i=1}^3\br{\br{E+p}u_i}_{x_i}.\]
{\@bropd@r#3\ifx\@bropd@h\empty\else^{#1}\fi}}
\endinput
% \end{macrocode}
+% \end{macro}
% \endinput