diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/onlyamsmath |
Initial commit
Diffstat (limited to 'macros/latex/contrib/onlyamsmath')
-rw-r--r-- | macros/latex/contrib/onlyamsmath/ChangeLog | 21 | ||||
-rw-r--r-- | macros/latex/contrib/onlyamsmath/Makefile | 63 | ||||
-rw-r--r-- | macros/latex/contrib/onlyamsmath/README | 37 | ||||
-rw-r--r-- | macros/latex/contrib/onlyamsmath/onlyamsmath.dtx | 337 | ||||
-rw-r--r-- | macros/latex/contrib/onlyamsmath/onlyamsmath.ins | 22 | ||||
-rw-r--r-- | macros/latex/contrib/onlyamsmath/onlyamsmath.pdf | bin | 0 -> 212638 bytes | |||
-rw-r--r-- | macros/latex/contrib/onlyamsmath/onlyamsmathtest.tex | 88 |
7 files changed, 568 insertions, 0 deletions
diff --git a/macros/latex/contrib/onlyamsmath/ChangeLog b/macros/latex/contrib/onlyamsmath/ChangeLog new file mode 100644 index 0000000000..5df2279385 --- /dev/null +++ b/macros/latex/contrib/onlyamsmath/ChangeLog @@ -0,0 +1,21 @@ +2016/12/18 0.20 Harald Harders + Added switch nodollardollar again (prevent from changing catcode + to avoid issues with TikZ/PGF) + +2012/01/01 0.10 Harald Harders + Explicitly state date and version in \ProvidesPackage statement + Update e-mail address + Update documentation + +2001/09/23 0.04 Harald Harders + Removed code that forbids \[...\] + +2001/09/22 0.03 Harald Harders + Changed definition of \dollarcode, by David Kastrup + Removed switches dollardollar and nodollardollar + +2001/09/21 0.02 Harald Harders + Added switch nodollardollar + +2001/09/21 0.01 Harald Harders + First version diff --git a/macros/latex/contrib/onlyamsmath/Makefile b/macros/latex/contrib/onlyamsmath/Makefile new file mode 100644 index 0000000000..91a129aefe --- /dev/null +++ b/macros/latex/contrib/onlyamsmath/Makefile @@ -0,0 +1,63 @@ +VERSION=`grep -e '\\[.*\\]' onlyamsmath-v.tex | sed 's/ \\[[0-9/]* *\\([v0-9]*\\)\\.\\([0-9]*\\).*\\]/\\1_\\2/'` + +.SUFFIXES: .sty .ins .dtx .pdf + + +.ins.sty: + pdflatex $< + +.dtx.pdf: + pdflatex $< + pdflatex $< + makeindex -s gind.ist $(*D)/$(*F) + makeindex -s gglo.ist -o $(*D)/$(*F).gls $(*D)/$(*F).glo + pdflatex $< + +all: onlyamsmath onlyamsmath.pdf message + +onlyamsmathtest.pdf: + pdflatex onlyamsmathtest + + +onlyamsmath: + pdflatex onlyamsmath.ins + + + +clean: + @-rm -f onlyamsmath.{glo,gls,idx,ilg,ind,aux,log,toc} + @-rm -f onlyamsmathtest.{log,aux} + @-rm -f *~ + +distclean: clean + @-rm -f onlyamsmath.{sty,pdf,ps} + @-rm -f onlyamsmathtest.{pdf,ps} + +tar: all clean + @echo Generate onlyamsmath-$(VERSION).tar.gz + @-rm -f onlyamsmath-$(VERSION).tar.gz + @tar czCf .. onlyamsmath-$(VERSION).tar.gz \ + onlyamsmath/README \ + onlyamsmath/ChangeLog \ + onlyamsmath/Makefile \ + onlyamsmath/onlyamsmath.{dtx,ins,pdf} \ + onlyamsmath/onlyamsmathtest.tex + +zip: all clean + @echo Generate onlyamsmath-$(VERSION).zip + mkdir -p tex/latex/onlyamsmath + mkdir -p doc/latex/onlyamsmath + mkdir -p source/latex/onlyamsmath + cp onlyamsmath.sty tex/latex/onlyamsmath + cp README ChangeLog onlyamsmath.pdf onlyamsmathtest.tex doc/latex/onlyamsmath + cp onlyamsmath.dtx onlyamsmath.ins Makefile source/latex/onlyamsmath + @rm -f onlyamsmath-$(VERSION).zip + @zip -r onlyamsmath-$(VERSION).zip source/ tex/ doc/ + rm -rf source/ tex/ doc/ + +message: + @echo "Please copy onlyamsmath.sty to a directory" + @echo "in the LaTeX search path" + @echo "Then run \`latex onlyamsmathtest' to see an example" + + diff --git a/macros/latex/contrib/onlyamsmath/README b/macros/latex/contrib/onlyamsmath/README new file mode 100644 index 0000000000..91b5b4ab01 --- /dev/null +++ b/macros/latex/contrib/onlyamsmath/README @@ -0,0 +1,37 @@ +onlyamsmath.sty +=============== + +This package inhibits the usage of plain TeX and on demand of +standard LaTeX math environments. +This is useful for class writers who want to force their clients to +use the environments provided by the amsmath package. + + +Copyright 2001, 2012, 2016 Harald Harders + +This program can be redistributed and/or modified under the terms +of the LaTeX Project Public License Distributed from CTAN +archives in directory macros/latex/base/lppl.txt; either +version 1 of the License, or any later version. + + + +Installation: + +automatic: - run make. + - copy onlyamsmath.sty to a place where LaTeX can find it. + - run texhash or the corresponding command of your distribution. + +by hand: - execute pdflatex on onlyamsmath.ins + - execute pdflatex on onlyamsmath.dtx (2x) + - execute makeindex -s gind.ist onlyamsmath + - execute makeindex -s gglo.ist -o onlyamsmath.gls onlyamsmath.glo + - execute pdflatex on onlyamsmath.dtx + - copy onlyamsmath.sty to a place LaTeX can find it + - run texhash or the corresponding command of your distribution + + +2012-01-01 +Harald Harders +harald.harders@gmx.de + diff --git a/macros/latex/contrib/onlyamsmath/onlyamsmath.dtx b/macros/latex/contrib/onlyamsmath/onlyamsmath.dtx new file mode 100644 index 0000000000..d1861e83f9 --- /dev/null +++ b/macros/latex/contrib/onlyamsmath/onlyamsmath.dtx @@ -0,0 +1,337 @@ +% \iffalse meta comment +% File: onlyamsmath.dtx Copyright (C) 2001, 2012, 2016 Harald Harders +% \fi +% +% \iffalse +% +%<*driver> +\documentclass[fleqn]{ltxdoc} +\usepackage{amsmath} +\newlength{\tempdima}% +\makeatletter +\renewenvironment{table}[1][]{% + \@float{table}[#1]% + \centering% + \setlength{\tempdima}{\abovecaptionskip}% + \setlength{\abovecaptionskip}{\belowcaptionskip}% + \setlength{\belowcaptionskip}{\tempdima}% + }{% +\end@float +} +\makeatother +\newcommand{\PrintBibliography}{% +\begin{thebibliography}{9} +\bibitem{amsmath1999} + {\em User's Guide for the amsmath Package}. + \newblock American Mathematical Society, 1999/12/13. +\end{thebibliography} +} +\EnableCrossrefs +\CodelineIndex +\DoNotIndex{\def,\edef,\let,\newcommand,\newenvironment,\newcounter} +\DoNotIndex{\setcounter,\space,\begingroup,\endgroup} +\CodelineNumbered +\RecordChanges +\CheckSum{98} +\input{onlyamsmath-v.tex} +\GetFileInfo{onlyamsmath-v.tex} +\title{The \texttt{onlyamsmath} package} +\author{Harald Harders\\\texttt{harald.harders@gmx.de}} +\date{Version \fileversion, \filedate, printed \today} +\begin{document} + \DocInput{onlyamsmath.dtx} +\end{document} +%</driver> +% \fi +% +% \changes{0.20}{2016/12/18}{Added switch \texttt{nodollardollar} again +% (prevent from changing catcode to avoid issues with TikZ/PGF)}% +% \changes{0.10}{2012/01/01}{Explicitly state date and version in +% \cs{ProvidesPackage} statement} +% \changes{0.10}{2012/01/01}{Update documentation} +% \changes{0.10}{2012/01/01}{Update e-mail address} +% \changes{0.01}{2001/09/21}{First version} +% +% \maketitle +% \begin{abstract} +% \noindent +% This package inhibits the usage of plain \TeX\ and on demand of +% standard \LaTeX\ math environments. +% This is useful for class writers who want to force their clients to +% use the environments provided by the amsmath package. +% \end{abstract} +% +% \tableofcontents +% +% \section*{Copyright} +% Copyright 2001, 2012, 2016 Harald Harders. +% +% This program can be redistributed and/or modified under the terms +% of the LaTeX Project Public License Distributed from CTAN +% archives in directory macros/latex/base/lppl.txt; either +% version 1 of the License, or any later version. +% +% \section{Usage of the package} +% +% Just load the package using |\usepackage[|options|]{onlyamsmath}|. +% If no option is given only the plain \TeX\ environment |$$|\dots|$$| +% is ``destroyed''. +% This environment leads to centred equations even with the global +% option |fleqn| (\emph{f}orce \emph{l}eft \emph{eq}uatio\emph{n}s) +% switched on: +% $$ +% a=b\,. +% $$ +% +% \DescribeMacro{eqnarray} +% One further option is \verb|eqnarray| to switch off +% the |eqnarray| and |eqnarray*| environments that add an unwished +% space before and after the aligned part of the formula as shown +% here: +% \begin{eqnarray*} +% a&=&b\,. +% \end{eqnarray*} +% A better result is achieved using the |align| environment provided +% by |amsmath.sty|: +% \begin{align*} +% a&=b\,. +% \end{align*} +% +% \DescribeMacro{all} +% The most brutal option is |all| that inhibits the writer to use any +% of the \TeX\ and \LaTeX\ math environments for non-inlined equations +% I know (|$$|\dots|$$|, |eqnarray|, |eqnarray*|, |displaymath|. +% The inlined mathematical modes (|$|\dots|$|, |\(|\dots|\)|) still +% work. +% +% Then instead use the environments provided by |amsmath.sty|: +% |equation|, |align|, |gather|, |flalign|, |multiline|, |alignat|, +% and |split|. All environments except |split| have a starred +% variant. See the User's Guide of the |amsmath| package for further +% details \cite{amsmath1999}. +% +% \DescribeMacro{error} +% There are two more options that control the behaviour of the package +% if you still use one of the ``forbidden'' environments. +% If using |error| which is the default \LaTeX\ generates an error +% message that reminds you to use the environments of the |amsmath| +% package. +% +% \DescribeMacro{warning} +% If using |warning| \LaTeX\ only produces warnings and proceeds. +% +% \DescribeMacro{nodollardollar} +% If |nodollardollar| is used, the |$| catcode is not changed. +% This way, the plain \TeX\ |$$| macro can still be used. +% This option helps to avoid issues with recent versions of TikZ/PGF but might +% have other side effects. +% +% \section*{Acknowledgement} +% +% David Kastrup (David.Kastrup@t-online.de) has +% written the part handling |$$|. +% I just have changed the call of the command producing the error +% message. +% Since I do not understand his code please don't ask me things +% regarding it. +% +% Reinhard Kotucha has reported the problem with recent TikZ/PGF and also +% identified that changing the |$| catcode caused the issues. +% The class option |nodollardollar| has been introduced to resolve this +% incompatibility. +% +% \StopEventually{\PrintBibliography \PrintChanges \PrintIndex} +% +% \section{The implementation} +% +% Package header: +% \begin{macrocode} +%<package>\ProvidesPackage{onlyamsmath} +%<version>\ProvidesFile{onlyamsmath-v.tex} +%<package,version> [2016/12/18 v0.20 Destroy the standard math environments] +% \end{macrocode} +% \iffalse +%<*package> +% \fi +% Load |amsmath| package: +% \begin{macrocode} +\RequirePackage{amsmath} +% \end{macrocode} +% \subsection{Options} +% All options set a boolean variable which is named simular to the +% option name. +% +% \changes{0.02}{2001/09/21}{Added switch \texttt{nodollardollar}}% +% \changes{0.03}{2001/09/22}{Removed switches \texttt{dollardollar} +% and \texttt{nodollardollar}}% +% Define the |eqnarray| option: +% \begin{macrocode} +\newif\ifonlyams@eqnarray +\DeclareOption{eqnarray}{\onlyams@eqnarraytrue} +% \end{macrocode} +% Define the |all| option: +% \begin{macrocode} +\newif\ifonlyams@all +\DeclareOption{all}{ + \onlyams@alltrue + \onlyams@eqnarraytrue +} +% \end{macrocode} +% Define the |error| and |warning| options: +% \begin{macrocode} +\newif\ifonlyams@error +\onlyams@errortrue +\DeclareOption{error}{\onlyams@errortrue} +\DeclareOption{warning}{\onlyams@errorfalse} +% \end{macrocode} +% Define the |nodollardollar| option: +% \begin{macrocode} +\newif\ifonlyams@nodollardollar +\DeclareOption{nodollardollar}{\onlyams@nodollardollartrue} +% \end{macrocode} +% Set the default options: +% \begin{macrocode} +\ExecuteOptions{error} +% \end{macrocode} +% Process the options: +% \begin{macrocode} +\ProcessOptions\relax +% \end{macrocode} +% \subsection{Commands} +% +% \begin{macro}{\onlyams@error} +% Define a command that produces the error resp.\ warning messages. +% The argument specifies the name of the environment that produced the +% message. +% \begin{macrocode} +\newcommand{\onlyams@error}[1]{% + \ifonlyams@error + \PackageError{onlyamsmath}{Environment #1 used}{Please use only the + environments provided by the amsmath package.}% + \else + \PackageWarning{onlyamsmath}{Environment #1 used, please use + \MessageBreak only the environments provided by the amsmath + \MessageBreak package}% + \fi +} +% \end{macrocode} +% \end{macro} +% \changes{0.04}{2001/09/23}{Removed code that forbids +% \texttt{\textbackslash [}\dots\texttt{\textbackslash ]}}% +% +% Here follows the part that is only executed when one of the options +% |eqnarray| or |all| is used: +% \begin{macrocode} +\ifonlyams@eqnarray +% \end{macrocode} +% \begin{macro}{\onlyams@eqnarray} +% Copy the original |\eqnarray| command which is called by the commands +% |\begin{eqnarray}| and |\begin{eqnarray*}| to be able to call it +% after producing the correspondig error message: +% \begin{macrocode} + \let\onlyams@eqnarray\eqnarray +% \end{macrocode} +% \end{macro} +% \begin{environment}{eqnarray} +% Redefine the |\eqnarray| command: +% \begin{macrocode} + \def\eqnarray{% +% \end{macrocode} +% First generate an error or warning message: +% \begin{macrocode} + \onlyams@error{eqnarray or eqnarray*}% +% \end{macrocode} +% Then call the original |eqnarray| environment: +% \begin{macrocode} + \onlyams@eqnarray} +\fi +% \end{macrocode} +% \end{environment} +% Here follows the part that is only executed when the option |all| is +% used: +% \begin{macrocode} +\ifonlyams@all +% \end{macrocode} +% \begin{environment}{displaymath} +% Redefine the |\displaymath| command: +% \begin{macrocode} + \def\displaymath{% +% \end{macrocode} +% First generate an error or warning message: +% \begin{macrocode} + \onlyams@error{displaymath}% +% \end{macrocode} +% Then call the |\[| environment which normally is called by the +% |displaymath| environment: +% \begin{macrocode} + \[} +% \end{macrocode} +% \end{environment} +% \begin{macrocode} +\fi +% \end{macrocode} +% Redefine the |$$| environment. +% This part wass written by David Kastrup. Please don't ask me anything +% about it. +% \changes{0.03}{2001/09/22}{Changed definition of +% \texttt{\textbackslash dollarcode}, by David Kastrup}% +% \begin{macro}{\dollarcode} +% \begin{macrocode} +\def\dollarcode{\ifx\protect\@typeset@protect + \expandafter\futurelet\expandafter\next\expandafter\checkdsp + \else \expandafter$\fi} +% \end{macrocode} +% \end{macro} +% \begin{macrocode} +\begingroup +\lccode`\~=`\$ +\lowercase{\endgroup\let~}\dollarcode +% \end{macrocode} +% \begin{macro}{\defdsp} +% \begin{macrocode} +\def\checkdsp{\ifx\next\dollarcode\expandafter\dspcomplain + \else\expandafter$\fi} +% \end{macrocode} +% \end{macro} +% Now comes the part that I understand and in which I have made +% changes. +% \begin{macro}{\dspcomplain} +% This command controls the complaint when using |$$|. +% \begin{macrocode} +\def\dspcomplain#1{% +% \end{macrocode} +% If mathmode is active the code has found the second |$$| of the +% environment. +% The complaint has already made and it is not necessary to do +% generate one. +% The environment has to be closed by using |\]|: +% \begin{macrocode} + \ifmmode + \expandafter \]% + \else +% \end{macrocode} +% If the mathmode isn't active the first |$$| of a mathematical +% environment has been found. +% First generate the warning or error message: +% \begin{macrocode} + \onlyams@error{$$ $$}% +% \end{macrocode} +% Then start the mathmode by using |\[|: +% \begin{macrocode} + \expandafter \[ + \fi} +% \end{macrocode} +% \end{macro} +% Activate the complaining behaviour at |\begin{document}| to ensure +% that packages that internally use |$$| can do that without an error: +% \begin{macrocode} +\ifonlyams@nodollardollar +\else + \AtBeginDocument{\catcode`\$=13 } +\fi +% \end{macrocode} +% \iffalse +%</package> +% \fi +% \Finale + diff --git a/macros/latex/contrib/onlyamsmath/onlyamsmath.ins b/macros/latex/contrib/onlyamsmath/onlyamsmath.ins new file mode 100644 index 0000000000..209e3e6ff1 --- /dev/null +++ b/macros/latex/contrib/onlyamsmath/onlyamsmath.ins @@ -0,0 +1,22 @@ +\def\batchfile{onlyamsmath.ins} +\input docstrip.tex +\preamble + + onlyamsmath package + + Copyright 2001, 2012, 2016 Harald Harders + + This program can be redistributed and/or modified under the terms + of the LaTeX Project Public License Distributed from CTAN + archives in directory macros/latex/base/lppl.txt; either + version 1 of the License, or any later version. + + harald.harders@gmx.de + +\endpreamble +% Files +%%%%%%%%%%%%%%%%%%%%%% +\generateFile{onlyamsmath.sty}{f}{\from{onlyamsmath.dtx}{package}} +\generateFile{onlyamsmath-v.tex}{f}{\from{onlyamsmath.dtx}{version}} + +\Msg{* Fertig} diff --git a/macros/latex/contrib/onlyamsmath/onlyamsmath.pdf b/macros/latex/contrib/onlyamsmath/onlyamsmath.pdf Binary files differnew file mode 100644 index 0000000000..4954a638b4 --- /dev/null +++ b/macros/latex/contrib/onlyamsmath/onlyamsmath.pdf diff --git a/macros/latex/contrib/onlyamsmath/onlyamsmathtest.tex b/macros/latex/contrib/onlyamsmath/onlyamsmathtest.tex new file mode 100644 index 0000000000..9f7d29afda --- /dev/null +++ b/macros/latex/contrib/onlyamsmath/onlyamsmathtest.tex @@ -0,0 +1,88 @@ +\documentclass[fleqn]{article} +\usepackage[all,warning]{onlyamsmath} +%\usepackage[all]{onlyamsmath} + +\begin{document} +\author{Harald Harders} +\title{Test of the package onlyamsmath.sty} + +\maketitle +\tableofcontents +\listoffigures + +\section{A section title with an embedded equation $\alpha$} + +Normal inlined equations $a^2+b^2=c^2$ should work. + +Formulae in figures were a problem in version 0.1 and 0.2. +Test wheather they work now in Fig.~\ref{fig:example}. +\begin{figure} + \centering + Test + \caption{Here we have formulae $\alpha$, $\beta$, $\vec{a}$.\dots} + \label{fig:example} +\end{figure} + +\subsection{Allowed \texttt{amsmath} environments} + +The \verb|align| environment is part of \verb|amsmath.sty| and +therefor works, too: +\begin{align} + \sin^2x + \cos^2x &=1\,,\\ + \tan\alpha &= \frac{\sin\alpha}{\cos\alpha}\,. +\end{align} +\verb|equation| is redefined and allowed: +\begin{equation} + \sin^2x + \cos^2x = 1\,. +\end{equation} +\verb|equation*| is defined by \verb|amsmath.sty| and allowed: +\begin{equation*} + \sin^2x + \cos^2x = 1\,. +\end{equation*} +\verb|gather|: +\begin{gather} + \sin^2x + \cos^2x =1\,,\\ + \tan\alpha = \frac{\sin\alpha}{\cos\alpha}\,. +\end{gather} +\verb|gather*|: +\begin{gather*} + \sin^2x + \cos^2x =1\,,\\ + \tan\alpha = \frac{\sin\alpha}{\cos\alpha}\,. +\end{gather*} +\verb|multiline|: +\begin{multline} + \sin^2x + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 \\ + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + \cos^2x =1\,. +\end{multline} +\verb|multiline*|: +\begin{multline*} + \sin^2x + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 \\ + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + \cos^2x =1\,. +\end{multline*} +\verb|\[| is redefined and works: +\[ + \sin^2x + \cos^2x = 1\,. +\] + + + +\subsection{Forbidden \TeX\ and \LaTeX\ environments} + +\verb|eqnarray| is forbidden: +\begin{eqnarray} + \sin^2x + \cos^2x &=& 1\,. +\end{eqnarray} +\verb|eqnarray*| is also forbidden: +\begin{eqnarray*} + \sin^2x + \cos^2x &=& 1\,. +\end{eqnarray*} +Same for \verb|displaymath|: +\begin{displaymath} + \sin^2x + \cos^2x = 1\,. +\end{displaymath} +And of course \verb|$$| (thanks to David Kastrup): +$$ + \sin^2x + \cos^2x = 1\,. +$$ + +\end{document} |