Skip to content

Commit

Permalink
Update the package to v0.18. This adds some commands I have found use…
Browse files Browse the repository at this point in the history
…ful, and slightly modifies a couple of the hard-coded formatting choices.
  • Loading branch information
jcoo092 committed Jul 13, 2021
1 parent 793df2a commit b10f505
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 41 deletions.
5 changes: 3 additions & 2 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
%%
%% This is a generated file.
%%
%% Copyright (C) 2020 by James Cooper, University of Auckland <jcoo092@aucklanduni.ac.nz>
%% Copyright (C) 2021 by James Cooper, University of Auckland <jcoo092@aucklanduni.ac.nz>
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
Expand All @@ -19,7 +19,7 @@
%% version 2005/12/01 or later.
%%
%%cpsystems LaTeX package
%%Copyright (C) 2020 by James Cooper, University of Auckland <jcoo092@aucklanduni.ac.nz>
%%Copyright (C) 2021 by James Cooper, University of Auckland <jcoo092@aucklanduni.ac.nz>
%%
%%The goal of this work is to provide a self-contained, easy-to-use LaTeX package that eases the typesetting of cP systems, a variant of Membrane Computing/P systems created by Dr. Radu Nicolescu and collaborators in the early 2010s. Please refer to the package documentation for instructions on its use. To the best of my knowledge, it is compatible with all LaTeX2e distributions which are reasonably up-to-date, as well as all classes (and likely all or almost all packages) that are typically used for publishing material on P systems.
%%
Expand All @@ -30,6 +30,7 @@
%%Constructive pull requests, creation of issues for bugs, and suggestions for improvements are very welcome.
%%
%%This package was originally created to assist me while writing a paper on cP systems which should also largely re-appear in my PhD dissertation. While you are certainly free to peruse and use this package, if you don't know what Membrane Computing/P systems is, this package is unlikely to be of much use to you.
% Also be aware that some of the commands included in the package aren't currently documented outside of section \ref{sec:implementation}. The commands exist and are used, but I haven't had the spare time to write about them properly yet.
\endinput
%%
%% End of file `README.txt'.
134 changes: 107 additions & 27 deletions cpsystems.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
%<package>\NeedsTeXFormat{LaTeX2e}[2011/06/27]
%<package>\ProvidesPackage{cpsystems}
%<*package>
[2021/03/17 v0.17 Package to aid in typesetting cP systems
[2021/07/14 v0.18 Package to aid in typesetting cP systems
rulesets, following Nicolescu's standard style]
%</package>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{cpsystems}[2021/03/17 v0.11]
\usepackage{cpsystems}[2021/07/14 v0.18]
\usepackage{fancyvrb}
\usepackage[hidelinks]{hyperref}
\EnableCrossrefs
Expand All @@ -64,7 +64,8 @@
%</driver>
% \fi
%
% \changes{0.17}{2020/12/28}{Remove the ending dot from \texttt{cpterm}. Adjust \texttt{cpsend} and \texttt{cprecv} to use a single internal base rule. Removed the \texttt{cps} command, to avoid potential conflicts with other packages. I have found defining cP systems as a glossary term to be a superior alternative anyway. Changed \texttt{cpresetrulenumber} to make use of \texttt{cpchangerulenumber}, instead of replicating the functionality.}
% \changes{0.18}{2021/07/14}{Added in \texttt{cprulecustnum}, \texttt{cpantirecv}, \texttt{cpantisend}, \texttt{cptuple}, \texttt{cptupetemplate}, \texttt{cponce}, \texttt{cpmaxpar}, \texttt{cpset}. Adjusted the arraystretch for rules slightly (from 1.0 to 1.1). Prefixed \texttt{changerulenumber} and \texttt{resetrulenumber} with \texttt{cp}. }
% \changes{0.17}{2021/03/17}{Remove the ending dot from \texttt{cpterm}. Adjust \texttt{cpsend} and \texttt{cprecv} to use a single internal base rule. Removed the \texttt{cps} command, to avoid potential conflicts with other packages. I have found defining cP systems as a glossary term to be a superior alternative anyway. Changed \texttt{cpresetrulenumber} to make use of \texttt{cpchangerulenumber}, instead of replicating the functionality.}
% \changes{0.16}{2020/12/28}{Added in the \texttt{cpruleinline} and \texttt{cpfuncms} macros, since I had already created them and am using them in a paper I am writing.}
% \changes{0.15}{2020/12/27}{Introduced use of perfectcut to provide automatically-resizing brackets. Also added an explanation and example for \texttt{cpterm}. Unfortunately, this also breaks linebreaks inside \texttt{cpfunc} macros for the time being...}
% \changes{0.14}{2020/12/27}{Add minimum LaTeX2e version to package specification. Change many of the \texttt{newcommand} declarations to use the \texttt{newcommand*} style, making them ``short commands'', which (apparently) throw warnings if there is a paragraph break detected in their use -- the ones modified aren't expected to have paragraph breaks in them. Also, added in the \texttt{cps}, \texttt{cpundig} and \texttt{cpempty} convenience macros.}
Expand Down Expand Up @@ -97,11 +98,13 @@
% \newpage
%
% \section{Introduction}
% This is a package to assist authors in writing papers on cP~systems, a particular variant of P~systems that was created by Dr. Radu Nicolescu, along with a number of collaborators, in the early 2010s. This document assumes you have a working knowledge of cP~systems and how they should look when fully typeset. It makes no attempt to explain the theory of cP~systems, nor why they are set out in the fashion that they. If you would like further information on cP~systems, please see \cite{Nicolescu2018}, or \cite{Paun2002} for an excellent (albeit somewhat old) introduction to P~systems generally.
% This is a package to assist authors in writing papers on cP~systems, a particular variant of P~systems that was created by Dr. Radu Nicolescu, along with a number of collaborators, in the early 2010s. This document assumes you have a working knowledge of cP~systems and how they should look when fully typeset. It makes no attempt to explain the theory of cP~systems, nor why they are set out in the fashion that they are. If you would like further information on cP~systems, please see \cite{Nicolescu2018}, or \cite{Paun2002} for an excellent (albeit somewhat old) introduction to P~systems generally.
%
% This package was originally created by James Cooper to help with typesetting a specific paper on cP~systems (specifically one about modelling Belief Propagation in cP~systems). The same commands had historically been copied from paper to paper, and across sections within papers, as most of them weren't even formed into proper \LaTeX{} macros. This was, of course, extremely error prone, with formatting errors (and worse) sometimes making it into published articles. The commands in this package in many cases are no less verbose than simply typing out the commands inside the macros. They are more `robust'\footnote{Note that \LaTeX{} has its own, different, concept of ``robust''.}, however, in that by using the defined macros the exact same commands are applied each time so there is greater consistency throughout the paper.\footnote{It is also hoped, perhaps vainly, that this package could eventually become \emph{the} standard way to set out cP~systems, assuring consistency across different papers by different authors.} If the macro is mistyped, the \LaTeX{} engine itself will report the error. They also hopefully should add greater structure to a paper and prove useful in editing the paper.
%
% Note that, at present, this package is \emph{not} available on CTAN, and instead may only be retrieved from the author's academic GitHub account (see the URL listed in this document's title). Once it has been sufficiently developed and stabilised, and/or there is consistent demand for such a package beyond the author's immediate research group, it likely will be added to CTAN, but there is no timeframe nor guarantee in place for that.
% Note that, at present, this package is \emph{not} available on CTAN, and instead may only be retrieved from the author's academic GitHub account (see the URL listed in this document's title). Once it has been sufficiently developed and stabilised, and/or there is consistent demand for such a package beyond the author's immediate research group, it likely will be added to CTAN, but there is no timeframe nor guarantee in place for that.
%
% Also be aware that some of the commands included in the package aren't currently documented outside of section \ref{sec:implementation}. The commands exist and are used, but I haven't had the spare time to write about them properly yet.
%
% \section{Usage}
%
Expand Down Expand Up @@ -228,11 +231,6 @@
% A parameter-less convenience macro for inserting the correctly-formatted cP~systems `unitary digit' in rules.
%
% \noindent
% \DescribeMacro{\cps}
% |\cps|
% A parameter-less convenience macro for inserting the correctly-formatted way to write out ``cP~systems'' (i.e. ``|cP~systems|''). Used both because it is slightly shorter, and because it ensures consistency.
%
% \noindent
% \DescribeMacro{\cpempty}
% |\cpempty|
% A parameter-less convenience macro for inserting the correctly-formatted empty functor symbol (which is actually just a |\lambda|). Mostly used so that intent is clear in the rules specifications, but also partly in case someone ends up changing how empty functors are specified.
Expand Down Expand Up @@ -367,7 +365,7 @@
% If, for some reason, you \emph{don't} want your ruleset floating, or to have a caption or label, you dont actually need to use the |cprulesetfloat| environment. |cpruleset| is all you need for laying out rules. Just, the results probably won't be as good:
%
% \begin{Verbatim}[gobble=1,frame=lines,labelposition=topline,label=Code to produce the unlabelled non-floating cpruleset,tabsize=2]
% \resetrulenumber
% \cpresetrulenumber
% \begin{cpruleset}
% \cprule{s_1}{\cpfunc{v}{v(R)Y}}{1}{s_2}{\cpfunc{s}{r(R)~u(Y)~
% \cpfunc{p}{h(R)p()}}~c(\lambda)}
Expand All @@ -392,7 +390,7 @@
% \end{cpruleset}
% \end{Verbatim}
%
% \resetrulenumber
% \cpresetrulenumber
%\begin{cpruleset}
% \cprule{s_1}{\cpfunc{v}{v(R)Y}}{1}{s_2}{\cpfunc{s}{r(R)~u(Y)~
% \cpfunc{p}{h(R)p()}}~c(\lambda)}
Expand Down Expand Up @@ -501,7 +499,7 @@
% \begin{description}
% \cpterm{v}{A functor containing very vacuous varieties of vegetables}
% \cpterm{s}{A functor containing simply sublime serpentine sausages}
% \cpterm{f}{A fiendish \& frightening flash of the fraught folly of including your own full stop.}
% \cpterm{f}{A fiendish \& frightening flash of the fraught folly of including your own full stop. Except, the behaviour changed and now |\cpterm| no longer puts a `.' at the end of every term, since there were occassions when it would be a bad thing.}
% \cpterm{a}{a is for \texttt{atom}. To quote Radioactive Man: Up and atom!}
% \cpterm{s_1}{The starting state, wherein one states the obvious, subtly}
% \end{description}
Expand All @@ -511,15 +509,15 @@
% \begin{description}
% \cpterm{v}{A functor containing very vacuous varieties of vegetables}
% \cpterm{s}{A functor containing simply sublime serpentine sausages}
% \cpterm{f}{A fiendish \& frightening flash of the fraught folly of including your own full stop.}
% \cpterm{f}{A fiendish \& frightening flash of the fraught folly of including your own full stop. Except, the behaviour changed and now \texttt{cpterm} no longer puts a `.' at the end of every term's description, since there were occassions when it would be a bad thing.\texttrademark}
% \cpterm{a}{a is for \texttt{atom}. To quote Radioactive Man: Up and atom!}
% \cpterm{s_1}{The starting state, wherein one states the obvious, subtly}
% \end{description}
%
%
% \StopEventually{\PrintIndex}
%
% \section{Implementation}
% \section{\label{sec:implementation}Implementation}
% This section presents the actual implementation of the package. For the most part you probably won't need to refer to it, but every so often you might, especially to work out some error that \LaTeX{} is throwing at you, based on what the commands defined within become once they have been substituted into your document.
%
% \iffalse
Expand Down Expand Up @@ -571,7 +569,7 @@
% \begin{macrocode}
\newenvironment{cpruleset}
{\begin{framed}\begin{adjustwidth}{-1.0em}{-1.0em}
\renewcommand{\arraystretch}{1.0}\[\begin{array}{lllllr}}
\renewcommand{\arraystretch}{1.1}\[\begin{array}{lllllr}}
{\end{array}\]\end{adjustwidth}\end{framed}}
% \end{macrocode}
% \end{environment}
Expand All @@ -585,6 +583,29 @@
% \end{environment}
%
% \subsection{Macros}
%
% \subsubsection{cP systems definitions}
%
% \begin{macro}{\cptuple}
% A convenience for stating the definition of a cP~system. The first parameter is the subscript to \(\Pi\), while the next six are T, A, O, R, S, and \(\Bar{s}\).
% \begin{macrocode}
\newcommand*{\cptuple}[7]{
\[
\cpfunc{\Pi_{#1}}{#2, #3, #4, #5, #6, #7}
\]
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cptupletemplate}
% A convenience for stating the definition of a cP~system. The template tuple that is usually stated as how a cP~system is defined.
% \begin{macrocode}
\newcommand*{\cptupletemplate}{
\cptuple{cP}{T}{A}{O}{R}{S}{\Bar{s}}
}
% \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Rules}
%
Expand All @@ -594,7 +615,7 @@
% \begin{macrocode}
\newcommand{\cprule}[5]{
\refstepcounter{cpsystems@RuleNum}
\cpsystems@basecprule{#1}{#2}{#3}{#4}{#5}{(\arabic{cpsystems@RuleNum})}
\cpsystems@basecprule{#1}{#2}{#3}{#4}{#5}{\hspace{4.0em}(\arabic{cpsystems@RuleNum})}
}
% \end{macrocode}
% \end{macro}
Expand All @@ -617,6 +638,16 @@
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cprulecustnum}
% Mostly the same as a regular |\cprule|, but takes the rule number to display as an extra parameter. This also does \emph{not} increment the rule counter. I'm yet to work out how you could make references to these rule numbers. This is currently basically just a quick hack to permit the display of alternatives of pre-existing rules, and right now everything must be updated manually.
% \begin{macrocode}
\newcommand*{\cprulecustnum}[6]{
\cpsystems@basecprule{#1}{#2}{#3}{#4}{#5}{#6}
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\cppromoter}
% For specifying promoters as part of a rule.
% \begin{macrocode}
Expand Down Expand Up @@ -657,27 +688,69 @@
}
% \end{macrocode}
% \end{macro}
%
% % \begin{macro}{\changerulenumber}
%
% \begin{macro}{\cpantisend}
% Encapsulate an antiport `send' in cP~systems.
% First argument is the object(s) to be sent, and the second argument is the name of the channel the object(s) shall be sent on.
% \begin{macrocode}
\newcommand*{\cpantisend}[2]{
\cpsystems@basecpsendrecv{#1}{#2}{!!}
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\cpantirecv}
% Encapsulate an antiport `receive' in cP~systems.
% First argument is the object(s) to be received, and the second argument is the name of the channel the object(s) shall be received on.
% \begin{macrocode}
\newcommand*{\cpantirecv}[2]{
\cpsystems@basecpsendrecv{#1}{#2}{??}
}
% \end{macrocode}
% \end{macro}
%
%
% % \begin{macro}{\cpchangerulenumber}
% Change the rules counter to whatever positive integer you specify.
% There's likely an upper limit to what numbers you can set (and you may even be able to use negative numbers (you'd have to look into the details of \LaTeX{}/\TeX{}'s counter system to be sure)), but that number has not been found as of yet, and is probably higher than the number of rules you should include in any one paper.
% \begin{macrocode}
\newcommand*{\changerulenumber}[1]{
\newcommand*{\cpchangerulenumber}[1]{
\setcounter{cpsystems@RuleNum}{#1}
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\resetrulenumber}
% \begin{macro}{\cpresetrulenumber}
% Reset the rules counter, i.e. make it zero again, so that the next rule in the document will receive the number 1.
% \begin{macrocode}
\newcommand*{\resetrulenumber}{
\changerulenumber{0}
\newcommand*{\cpresetrulenumber}{
\cpchangerulenumber{0}
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\cponce}
% A minor convenience macro, to typeset the `exactly once' rule mode symbol in the ``correct'' way in rules.
% \begin{macrocode}
\newcommand*{\cponce}{{\scriptstyle 1}}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\cpmaxpar}
% A minor convenience macro, to typeset the `maximally parallel' rule mode symbol in the ``correct'' way in rules.
% \begin{macrocode}
\newcommand*{\cpmaxpar}{{\scriptstyle +}}
% \end{macrocode}
% \end{macro}
%
%
%
%
%
% \subsubsection{Objects Groups}
%
%
Expand All @@ -689,6 +762,14 @@
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cpset}
% Used for presenting a list of objects that are meant to be in the same set. Currently doesn't get used much, might be removed in the future.
% \begin{macrocode}
\newcommand*{\cpset}[1]{\perfectunary{IncreaseHeight}{\{}{\}}{#1}}
% \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Miscellaneous}
%
Expand Down Expand Up @@ -754,7 +835,7 @@
% For writing out promoters and inhibitors in a |cpruleset| environment.
% \begin{macrocode}
\newcommand{\cpsystems@cpprominhi}[2]{
\trim@spaces@noexp{& & & & ~ \hspace{0.5cm} ~ #1 ~ #2 & \\}
\trim@spaces@noexp{& & & & ~ \hspace{1em} ~ #1 ~ #2 & \\}
}
% \end{macrocode}
% \end{macro}
Expand All @@ -776,8 +857,7 @@
% \item Restoring support for line breaks inside |cpfunc| commands -- it seems to be unavoidable at times, but doesn't play nicely with the resizing brackets.
% \item Change to a different, more modern way of declaring |cpruleset| environments that doesn't rely on the |array| environment. There's nothing wrong with |array|, but it's probably more low-level that I actually need, and doesn't come with some conveniences (I imagine).
% \item A way to use cross-references to refer to rule numbers in the rulesets.
% \item Commands to write an individual rule inline in text, or in a separate paragraph. Either way, outside of a |cpruleset| environment.
% \item The ability to specify an optional parameter to the |cpruleset| stating the desired amount of array stretch to use. Currently it is hard-coded as \texttt{-1.0em}.
% \item The ability to specify optional parameters to the |cpruleset| stating the desired amount of arraystretch and adjustwidth to use. Currently they are hard-coded as \texttt{1.1em} \texttt{-1.0em}, respectively.
% \item Provide the ability to specify a printed name for |cprulesetfloat| and |cpobjectsfloat| besides `Ruleset' and `Objects Group'.
% \item Make the package available via CTAN.
% \item Eliminate the extraneous symbols in the index (it is unclear why they are appearing, when they have been specifically excluded using the normal method for \texttt{.dtx} files).
Expand Down
Binary file modified cpsystems.pdf
Binary file not shown.
Loading

0 comments on commit b10f505

Please sign in to comment.