diff options
author | Norbert Preining <norbert@preining.info> | 2020-07-24 03:02:43 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2020-07-24 03:02:43 +0000 |
commit | 48c502455fb3c2b9214390662ee706a10dea0818 (patch) | |
tree | 172fac4c70c250d0031153337f94a55d03ae1112 /macros | |
parent | 30da6c04d79973253114bab2567b4fd1d2edd0d0 (diff) |
CTAN sync 202007240302
Diffstat (limited to 'macros')
-rw-r--r-- | macros/latex/contrib/exesheet/README.md | 33 | ||||
-rw-r--r-- | macros/latex/contrib/exesheet/exesheet.dtx | 1489 | ||||
-rw-r--r-- | macros/latex/contrib/exesheet/exesheet.ins | 56 | ||||
-rw-r--r-- | macros/latex/contrib/exesheet/exesheet.pdf | bin | 0 -> 234223 bytes | |||
-rw-r--r-- | macros/latex/contrib/membranecomputing/README.md | 26 | ||||
-rw-r--r-- | macros/latex/contrib/membranecomputing/membranecomputing.pdf | bin | 0 -> 267458 bytes | |||
-rw-r--r-- | macros/latex/contrib/membranecomputing/membranecomputing.sty | 599 | ||||
-rw-r--r-- | macros/latex/contrib/membranecomputing/membranecomputing.tex | 486 |
8 files changed, 2689 insertions, 0 deletions
diff --git a/macros/latex/contrib/exesheet/README.md b/macros/latex/contrib/exesheet/README.md new file mode 100644 index 0000000000..f04b134515 --- /dev/null +++ b/macros/latex/contrib/exesheet/README.md @@ -0,0 +1,33 @@ +# The exesheet class and package - Typesetting exercise or exam sheets + + +## Presentation + +The exesheet package is used for typesetting exercise or exam sheets. +In addition, the exesheet class loads the schooldocs package. + +The package provides: +- macros to mark out exercises and subparts, +- specific settings for enumeration lists, +- environments for questions and answers, with conditional display, +- macros for marking scheme with detailed comments. + + +## Installation + +- run LaTeX on exesheet.ins, you obtain the files exesheet.cls and exesheet.sty, +- if then you run LaTeX + dvips + ps2pdf on exesheet.dtx you get the file exesheet.pdf which is also in the archive, +- put the files exesheet.cls, exesheet.sty and exesheet.pdf in your TeX Directory Structure. + + +## Author + +Antoine Missier + +Email: antoine.missier@ac-toulouse.fr + + +## License + +Released under the LaTeX Project Public License v1.3 or later. +See http://www.latex-project.org/lppl.txt diff --git a/macros/latex/contrib/exesheet/exesheet.dtx b/macros/latex/contrib/exesheet/exesheet.dtx new file mode 100644 index 0000000000..c703f6434b --- /dev/null +++ b/macros/latex/contrib/exesheet/exesheet.dtx @@ -0,0 +1,1489 @@ +% \iffalse meta-comment +% +% Copyright (C) 2020 by Antoine Missier <antoine.missier@ac-toulouse.fr> +% ---------------------------------------------------------------------- +% +% This file 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. +% +% \fi +% +% \iffalse +%<*driver> +\ProvidesFile{exesheet.dtx} +%</driver> +%<class|package>\NeedsTeXFormat{LaTeX2e}[2005/12/01] +%<class>\ProvidesClass{exesheet} +%<package>\ProvidesPackage{exesheet} +%<*class|package> + [2020/07/22 v1.0 .dtx exesheet file] +%</class|package> +% +%<*driver> +\documentclass{ltxdoc} +% uncomment the following lines if you want to use the exesheet class instead of ltxdoc +%\usepackage{doc} +%\AtBeginDocument{\MakeShortVerb{\|}} +%\providecommand\marg[1]{{\ttfamily\{}\meta{#1}{\ttfamily\}}} +%\providecommand\oarg[1]{{\ttfamily[}\meta{#1}{\ttfamily]}} +\usepackage[notoc]{exesheet} +\usepackage{schooldocs} +\usepackage[utf8]{inputenc} +\usepackage[T1]{fontenc} +\usepackage[english]{babel} +\usepackage{lmodern} +\usepackage{multicol} +\usepackage{hyperref} +\usepackage{sectsty} +\usepackage{pstricks} +\psset{unit=1cm} +\geometry{textwidth=355pt,vmarginratio=1:1,hmarginratio=3:2} +% altered by schoodocs, now very close from the default geometry used by ltxdoc + +\newcommand{\ds}{\displaystyle} +\newcommand{\bs}{\textbackslash} +\newcommand{\TODO}{\textcolor{green}{TODO}} + +\definecolor{darkbrown}{rgb}{0.5,0.1,0.1} +\allsectionsfont{\sffamily\color{darkbrown}} +\renewcommand{\labelexercisestyle}{\rmfamily\color{black}} +\renewcommand{\labelsubpartstyle}{\rmfamily\color{black}} +\renewcommand{\annexstyle}{\rmfamily\color{black}\MakeUppercase} +\renewcommand{\correctionstyle}{\rmfamily\color{correctioncolor}} + +\displaypts +%\diplaynotes gives a non desired margin ratio here +% following instructions simulate \displaynotes without altering the margin ratio +\setlength{\marginparwidth}{\oddsidemargin} +\addtolength{\marginparwidth}{1in} +\addtolength{\marginparwidth}{-\marginparsep} +\setlength{\marginparwidth}{0.8\marginparwidth} +\setboolean{marginpoints}{true} +\setboolean{marginfullnotes}{true} + +\DisableCrossrefs +%\CodelineIndex +%\RecordChanges + +\title{The \textsf{exesheet} class and package}%\thanks{This document +% corresponds to \textsf{exesheet}~\fileversion, dated \filedate.}} +%\author{Antoine Missier \\ \texttt{antoine.missier@ac-toulouse.fr}} +\subject{Antoine Missier \\ + \texttt{antoine.missier@ac-toulouse.fr}} +\date{July 22, 2020, \fileversion} +\hypersetup{% + colorlinks, + linkcolor=blue, + pdftitle={exesheet}, + pdfsubject={LaTeX class and package}, + pdfauthor={Antoine Missier} + } +\begin{document} + \DocInput{exesheet.dtx} +\end{document} +%</driver> +% \fi +% +% \CheckSum{637} +% +% \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 \~} +% +% +% \changes{v0.0}{2010/09/01}{Initial personal version} +% \changes{v0.9}{2020/01/02}{Initial documentation in french} +% \changes{v1.0}{2020/07/22}{Initial public version with documentation in english} +% +% \GetFileInfo{exesheet.dtx} +% +% \maketitle +% \tableofcontents +% +% \section{Introduction} +% +% The \textsf{exesheet} \emph{package} is used for typesetting exercise or exam sheets. +% In addition, the \textsf{exesheet} \emph{class} loads the \textsf{schooldocs} package. +% This one makes adjustments for margins and title and defines various layout styles +% with particular header and footer, appropriate for exercise sheets (among others). +% See the \textsf{schooldocs} documentation for more details. +% The \textsf{exesheet} \emph{class} is based on \textsf{article} +% and has the same options. +% +% Many other packages are dedicated to exercise sheets. +% Most propose to encapsulate each exercise in an environment +% while \textsf{exesheet} begins each exercise with the |\exercise| command, +% which works like a subsection (with same features) +% and is suitable for documents consisting exclusively of exercises. +% The package provides also alternative formatting, +% more relevant for short exercises. +% +% Another specificity of the \textsf{exesheet} package is specific settings +% for enumeration lists, different from \LaTeX\ standard settings, +% usefull for the numbering of questions or answers inside an exercise. +% +% Other packages provide often more or less elaborate mechanisms +% to manage the placement of answers. +% \textsf{exesheet} has no such ambitions: +% for all exercises of the sheet, we can display subject only, +% answer anly or both, but always at the place they are inserted +% in the source file. On the other hand this choice may be very flexible: +% we can do a correct version for all exercises together, or a correct version per exercise, +% per part (subpart of exercise), per question, per sub-question. +% +% Finally the original fonctionality of this package is the display of a detailed marking scheme, +% with optional explanations, in the margin of exercise answers. +% +% There are two possible options: \texttt{notoc} (see \ref{par:notoc}) +% and \texttt{nosetlist} (see \ref{par:nosetlist}). +% +%\medskip +% In the current document, a frame is used to highlight +% examples beside the rest of the documentation. +% +% \section{Titles} +% \subsection{The \texttt{\bs exercise} command} + +% \DescribeMacro{\exercise} +% Each exercise begins with the |\exercise|\oarg{opt} command. +% This command typesets \textbf{\exercisename}, as a document +% subsection, followed by automatic numbering, +% unique for the whole document. +% The optional parameter \meta{opt} is used to put additional text +% on the same title line, for example to precise a subject or a marking scheme. +% |\exercise[ (to begin)]| yields: +% +% \exercise[ (to begin)] +% \psframe(-0.25,1.3)(12.75,-0.4) +% Try to use this first command now, it's easy. +% +% \bigskip +% To bring additional text closer to the exercise number, +% we can use the |\unskip| command +% which eliminates preceding space, see the following example, obtained with +% |\exercise[\unskip : calculation]|: +% \exercise[\unskip: calculation] +% \psframe(-0.25,1.3)(12.75,-0.4) +% Calculate $1+1$. +% +% \bigskip +% \DescribeMacro{\exercisename} +% The word \emph{\exercisename} has automatic translation in a few languages\footnote{Translation +% is currently integrated into the package for the following languages: French, +% German, Spanish, Italian, Portuguese.} +% when the \textsf{babel} package is loaded. +% It can be redefined, with |\renewcommand|, which should be placed +% after |\begin{document}|, or else we can use macros from the \textsf{babel} package (allowing dynamic language change), e.g.\\ +% |\addto\captionssweedish{\def\exercisename{\"Ovning}}| (in the preamble). +% +% \DescribeMacro{\labelexercise} +% This command calls |\exercisename| following by the exercise number. +% It can be redefined. For example, to add a period after the exercise number: +% |\renewcommand{\labelexercise}{\exercisename~\theexercise.}| +% +% \DescribeMacro{\theexercise} +% To change only the numbering type, redefine +% the |\theexercise| command, based on the |exercise| counter. +% +% \DescribeMacro{\labelexercisestyle} +% This macro (which is empty by default) allows to define a particular style +% for exercise titles. In the present document, we defined in the preamble: +% |\renewcommand{\labelexercisestyle}{\rmfamily\color{black}}|\footnote{In the +% present document, to highlight real sections and subsections titles, +% their color and font have been modified with the +% \texttt{\bs allsectionsfont} macro from the \textsf{sectsty} package.}. +% +% \bigskip +% \DescribeMacro{\exercise*} +% The starred version |\exercise*|\oarg{opt}\marg{label} +% allows to choose another \meta{label} for a particular exercise +% and removes the numbering. For instance: +% |\exercise*[(Fermat theorem)]{Problem}| yields: +% +% \exercise*[(Fermat theorem)]{Problem} +% \psframe(-0.25,1.3)(12.75,-0.7) +% Proove that there are no positive integers $x, y, z$ such that $x^n+y^n=z^n$ +% for any integer $n$ greater than 2. +% +% \subsection{The \texttt{\bs subpart} command} +% +% \DescribeMacro{\subpart} +% An exercise may contain several parts that we obtain +% with the |\subpart|\oarg{opt} command, typeset like a subsubsection. +% \exercise +% \subpart[(preliminary)] +% \psframe(-0.25,1.95)(12.75,-1.9) +% First of all, prepare your cup of tea. +% \subpart +% Now you are ready to make the current exercise. +% +% \bigskip +% \DescribeMacro{\thesubpart} +% By default, the subpart numbering uses letters : A, B, C, etc. +% This numbering type can be redefined with the |\thesubpart| command based on +% the |subpart| counter, for instance |\renewcommand\thesubpart{\arabic{subpart}}|. +% +% \DescribeMacro{\subpartname} \DescribeMacro{\labelsubpart} +% \DescribeMacro{\labelsubpartstyle} +% As for |\exercise|, the |\subpart| command +% uses |\subpartname| (with automatic translation in a few languages +% if \textsf{babel} is loaded), +% |\labelsubpart| and |\labelsubpartstyle|, which are editable. +% \pagebreak +% +% \DescribeMacro{\subpart*} +% Like |\exercise*|, the starred version |\subpart*|\oarg{opt}\marg{label} +% allows to freely typeset the subpart \marg{label}, for instance +% |\subpart*{First part}|. +% +% \subsection{The \texttt{\bs annex} command} +% \DescribeMacro{\annex} +% The |\annex|\oarg{opt} command typesets the title \textbf{ANNEX}, in uppercase letters, centred +% and in the subsection style, +% with an optional parameter, added on the same line. +% +% \vspace{-\baselineskip} +% \noindent\psframe(-0.25,-0.25)(12.75,-1.25) +% \annex[(to return)] +% +% \DescribeMacro{\annexname} +% The word \emph{\annexname} has automatic translation in a few languages +% if \textsf{babel} package is loaded. +% It can be extended to other languages or modified by redifining |\annexname|. +% +% \DescribeMacro{\annexstyle} +% The annex title style is set by the |\annexstyle| macro, +% defined as follows: |\newcommand\annexstyle{\MakeUppercase}|. +% This command may be redefined as one wants. +% +% \subsection{Exercise titles in table of contents +% (notoc package option)} \label{par:notoc} +% \DescribeMacro{notoc} +% By default, the titles \emph{\exercisename}, \emph{\subpartname} or \emph{\annexname}, +% appear in the table of contents +% (or in the pdf file summary when \textsf{hyperref} package is used). +% To avoid this, you can set the boolean \texttt{notoc} to \texttt{true} +% or call the \textsf{exesheet} package (or class) with \texttt{notoc} option. +% But notice that title optional arguments will always be ignored in the table of contents. +% +% \subsection{Short exercises: the \texttt{\bs exe} command} +% \DescribeMacro{\exe} +% The |\exe| command starts an exercise by the abbreviation \textbf{\exname}.\ followed by the exercise number, +% without using sectioning commands, and the exercise body begins on the same +% line. An exercise starts a new paragraph without indentation. +% +% \exe This is a short exercise who +% can contain several paragraphs or questions however. +% +% \noindent\psframe(-0.25,1.4)(12.75,-1.2) +% \indent Here for example starts a new paragraph. +% \exe This is another short exercise. +% +% \bigskip +% \DescribeMacro{\exname} \DescribeMacro{\exlabel} \DescribeMacro{\exsepmark} +% The abbreviation \emph{\exname} may be changed by +% redefining |\exname|. +% The |\exlabel| macro calls |\exname| following by a period then the exercise number, +% and |\exsepmark| typesets a long dash. +% We may change these features by redefining these commands. +% +% \bigskip +% \DescribeMacro{\exe*} +% The starred version prints no separator as shown below: +% +% \vspace{-\baselineskip} +% \noindent\psframe(-0.25,-0.35)(12.75,-1.2) +% \exe* Another short exercise without separator. +% +% \subsection{The \texttt{\bs points} command} +% \DescribeMacro{\points} +% The |\points|\marg{pts} command displays the number of points awarded to an exercise. +% It is intended to be entered in the optional argument of the +% |\exercise| command\footnote{This command which has to be used +% in the optional argument of \texttt{\bs exercise}, as several others presented below, is incompatible with +% the \textsf{memoir} class which redefines section commands.}. +% |\exercise[\points{5}]| yields: +% \exercise[\points{5}] +% \psframe(-0.25,1.3)(12.75,-0.4) +% Try to read this whole document without drinking tea and you get five points. +% +% \bigskip +% \DescribeMacro{\pointsname} \DescribeMacro{\pointname} +% Like before, the words \emph{points} and in the singular \emph{point} +% (if \meta{pts} is inferior to 2) +% get automatic translation (with \textsf{babel}) in a few languages +% and are modifiables. +% +% \DescribeMacro{\pointsstyle} \DescribeMacro{pointscolor} +% The style used by the |\points| command may be redefined with |\pointsstyle|. +% The color is set by |pointscolor| with the |\definecolor| command +% (from the \textsf{xcolor} package by Uwe Kern, loaded by \textsf{exesheet}), +% for instance: \\ |\definecolor{pointscolor}{named}{blue}|. +% +% +% \section{Enumerations and lists} +% +% \subsection{List settings (nosetlist package option)} \label{par:nosetlist} +% Enumeration lists are intended to represent questions and sub-questions +% inside exercises. For a good highlight, +% labels are typeset in bold. +% Moreover, they are left aligned, at the start of the line, +% without indentation, and the vertical space between items +% is increased compared with \LaTeX\ standard lists. +% These settings are done by the |\setlist| command\footnote{Labels +% may also be changed by the \texttt{\bs labelenumi} and \texttt{\bs labelenumii} commands.} +% from the \textsf{enumitem} package by Javier Bezos. +% Lists with \texttt{itemize} environment are kept in their default configuration\footnote{The +% \texttt{french} otion of the \textsf{babel} package +% alters \texttt{itemize} lists behavior and uses long dash +% as labels for each list level. +% This behavior is problematic when mathematics follows the dash +% symbol because the latter may be confused wih the minus sign. +% Modifications of the \texttt{french} option (which supersedes \texttt{frenchb} +% of \textsf{babel}) are canceled to restore \LaTeX\ default settings.}. +% +% \vspace{-\baselineskip} +% \noindent\psframe(-0.25,-0.35)(12.75,-3.9) +% \exercise +% \begin{enumerate} +% \item First question +% \begin{enumerate} +% \item First sub-question +% \item Second sub-question +% \end{enumerate} +% \item Second question +% \end{enumerate} +% +% \DescribeMacro{nosetlist} +% We can avoid enumeration list modifications and restore the \LaTeX\ default settings by passing the option +% \texttt{nosetlist} to the \texttt{exesheet} class or package. +% +% \subsection{List of exercises : the \texttt{exenumerate} environment} +% \DescribeEnv{exenumerate} +% When an exercise sheet is made of short independant exercises, +% it would be ill-advised to display the complete title \emph{\exercisename} for each. +% In addition to the |\exe| command, previously presented, +% we provide an even lighter solution with the |exenumerate| environment, which is only an enumeration list in which +% spaces between items are further increased compared with those of \texttt{enumerate}. +% Here is an example (the main list is an \texttt{exenumerate} environment but +% sublists are produced with regular \texttt{enumerate} environments): +% +% \vspace{-\baselineskip} +% \noindent\psframe(-0.25,-0.3)(12.75,-7.05) +% \begin{exenumerate} +% \item Translate the following sentences in english: +% \begin{enumerate} +% \item Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi. +% \item Nam lacus libero, pretium at, lobortis vitae, ultricies et, tellus. +% \end{enumerate} +% \item Translate the following sentence in german: +% \par Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet magna, +% vitae ornare odio metus a mi. +% \item Translate the following sentences in french: +% \begin{enumerate} +% \item Cum sociis natoque penatibus +% et magnis dis parturient montes, nascetur ridiculus mus. +% \item Nulla ullamcorper vestibulum turpis. +% \end{enumerate} +% \end{exenumerate} +% The environment takes an optional parameter, like \texttt{enumerate}, which enables, among others, +% to typeset alternative list labels, e.g. +% |\begin{exenumerate}[A.]|. +% There are many other options (see the \textsf{enumitem} package documentation). +% +% \subsection{Items aligned by lines: \texttt{tablenum}} +% \DescribeEnv{tablenum} +% \DescribeEnv{tablenuma} +% \DescribeEnv{tablitem} +% These three environments are used to typeset short questions (\texttt{tablenum}), +% sub-questions (\texttt{tablenuma}) or \texttt{itemize} lists (\texttt{tablitem}) +% on the same line. They have the same syntax: +% |\begin{tablenum}|\oarg{opt}|(|\meta{cols}|)|. +% The \meta{cols} parameter is the number of columns used by the environment. It must be +% \emph{in parentheses}. This parameter can be omitted, then its value is 2. +% As for classic lists, each item begins with the |\item| command. +% +% These three environments are defined by the +% |\NewTasks| macro, from the \textsf{tasks} package by Clemens Niederberger. +% They take an optional argument \meta{opt} +% explained in the documentation of this package, +% e.g.\ |counter-format=tsk[r])| gives a roman numbering +% following by a closing parenthesis. +% There are also many possibilities to place items in an original way, +% for instance, the |\item*| command allows to +% specify the number of columns the item is supposed to span. +% In the following example, +% the five |\item| are placed in order between +% |\begin{tablenum}(3)| and |\end{tablenum}|. +% Notice that numbering is made line by line. +% +% \exercise +% \psframe(-0.25,1.3)(12.75,-2.7) +% Give the derivative of the following functions: +% \begin{tablenum}(3) +% \item $\ds f(x) = \frac{1-x^2}{\mathrm{e}^x +\mathrm{e}^{-x}}$, +% \item $\ds g(x) = \ln \left( \frac{1-x}{1+x^2}\right)$, +% \item $\ds h(x) = \int_{0}^{1}\mathrm{e}^{xy}\, \mathrm{d}y$, +% \item $\ds k(x) = \sum_{i=1}^{\infty}\frac{1}{x^i}$, +% \item $\ds l(x) = \int_{\frac{1}{x}}^{x}\frac{1}{\ln t}\, \mathrm{d}t$. +% \end{tablenum} +% +% For \texttt{tablenuma}, labels are +% letters (a, b, c, \ldots) surrounded +% by parentheses. This cannot be modified globally +% (except by redefining the environment with |\RenewTasks|). +% If the \textsf{exesheet} package is called with option \texttt{nosetlist}, +% labels of \texttt{tablenum} and \texttt{tablenuma} environments +% are displayed in normal font with indentation, as for +% \texttt{enumerate}. +% +% \subsection{Items aligned by columns: \texttt{colsenum}} +% \DescribeEnv{colsenum} +% To get numbering of items by columns, we have the +% \texttt{colsenum} environment: |\begin{colsenum}|\oarg{opt}\marg{cols}. +% The mandatory parameter is the number of columns +% and the optional one will be passed to \texttt{enumerate}, +% allowing, for example, to change the type of numbering (a, A, etc.). +% To use this environment, we have to load the +% \textsf{multicol} package in the preamble. +% +% \exercise +% \psframe(-0.25,1.3)(12.75,-2.65) +% Give the derivative of the following functions: +% \begin{colsenum}{3} +% \item $\ds f(x) = \frac{1-x^2}{\mathrm{e}^x +\mathrm{e}^{-x}}$, +% \item $\ds g(x) = \ln \left( \frac{1-x}{1+x^2}\right)$, +% \item $\ds h(x) = \int_{0}^{1}\mathrm{e}^{xy}\, \mathrm{d}y$, +% \item $\ds k(x) = \sum_{i=1}^{\infty}\frac{1}{x^i}$, +% \item $\ds l(x) = \int_{\frac{1}{x}}^{x}\frac{1}{\ln t}\, \mathrm{d}t$. +% \end{colsenum} +% \DescribeEnv{colsenum*} +% We will notice that, on each line, items are not necessarily well +% aligned, what can produce inelegant effects. +% On the other hand, the \texttt{colsenum} environment doesn't try to align columns +% from the bottom by adjusting space between items. +% If we want to get this +% (which is the default option in \textsf{multicol}) we have the +% \texttt{colsenum*} environment (same syntax than \texttt{colsenum}). +% Here what we get in that case, with the same exercise. +% +% \exercise +% \psframe(-0.25,1.3)(12.75,-2.65) +% Give the derivative of the following functions: +% \begin{colsenum*}{3} +% \item $\ds f(x) = \frac{1-x^2}{\mathrm{e}^x +\mathrm{e}^{-x}}$, +% \item $\ds g(x) = \ln \left( \frac{1-x}{1+x^2}\right)$, +% \item $\ds h(x) = \int_{0}^{1}\mathrm{e}^{xy}\, \mathrm{d}y$, +% \item $\ds k(x) = \sum_{i=1}^{\infty}\frac{1}{x^i}$, +% \item $\ds l(x) = \int_{\frac{1}{x}}^{x}\frac{1}{\ln t}\, \mathrm{d}t$. +% \end{colsenum*} +% We can see that these alignments are less good than those +% obtained by numbering of items by line. The numbering of items by columns +% may nevertheless be preferable when there are many items with variable heights, +% and a number of items which can be different from one column to the other. +% Moreover, an advantage of \texttt{colsenum} is that the choice of labels +% is automatic depending on the list level (and the language), +% unlike \texttt{tablenum} or \texttt{tablenuma}. +% +% \DescribeEnv{colsitem} +% \DescribeEnv{colsitem*} +% For \texttt{itemize} lists, the environment \texttt{colsitem} +% produces items aligned by columns rather than by lines as for +% \texttt{tablitem}: +% |\begin{colsitem}|\oarg{opt}\marg{cols}. The optional parameter, +% which is passed to the underlying \texttt{itemize} environment, allows to change the item label (bullet by default). +% And, as for \texttt{colsenum*}, the \texttt{colsitem*} environment +% produces an alignment of columns from the bottom. +% +% \section{Questions and solutions} +% +% \subsection{The \texttt{questions} and \texttt{answers} environments} +% \DescribeEnv{questions} \DescribeEnv{answers} +% The package provides the two environments \texttt{questions} and \texttt{answers} +% to make appear or disappear questions and answers of exercises. +% Display is controlled by two booleans: \texttt{questions} and \texttt{answers}. +% Their default value is \texttt{true}. +% +% \DescribeMacro{\questionsonly} \DescribeMacro{\answersonly} +% The |\questionsonly| command allows to display the questions without the answers +% and |\answersonly| displays the solutions without the questions\footnote{Of course +% we can also assign the booleans \texttt{questions} and \texttt{answers} +% directly with the \LaTeX\ command \texttt{\bs setboolean}.}. +% +% \bigskip +% \DescribeMacro{\correctionstyle} \DescribeMacro{correctioncolor} +% \DescribeMacro{\correctionname} +% In the case (by default) where questions and answers are displayed both, +% answers are then typeset in the style +% |\correctionstyle|, which uses the color \texttt{correctioncolor}. +% This color may be choosen with the |\definecolor| macro +% (by default |\definecolor{correctioncolor}{rgb}{0,0.2,0.6}| = kind of dark blue). +% Moreover, in that case, +% the title \textbf{\correctionname} is displayed at the beginning +% of the \texttt{answers} environment. +% It is defined by the |\correctionname| macro (with translation in a few languages +% and that we can change:\footnote{Except for English, if you want to change package keywords you have to do it \emph{after} \texttt{\bs begin\{document\}} +% because \textsf{babel} will modify these definitions at the end of the preamble.} +% for example we may prefer \emph{Solution} +% than \emph{\correctionname}). +% The style defined by |\correctionstyle| will apply to the title +% but also to the whole environment. +% Here an example. +% +% \vspace{-\baselineskip} +% \noindent\psframe(-0.25,-0.25)(12.75,-6.6) +% \exercise[\points{3}] \label{points} +% \begin{questions} +% \begin{enumerate} +% \item Is the \textsf{exesheet} package useful ? +% \item Ins't there any other packages that deal with exercises ? +% \end{enumerate} +% \end{questions} +% \begin{answers} +% \begin{enumerate} +% \item Yes, the \textsf{exesheet} package is very useful. +% \item There are many other packages that deal with exercices, and +% give the ability to produce separatly questions and solutions, for example +% \textsf{exercise} by Paul Pichaureau, \textsf{exercises} by Roger Jud, +% \textsf{exsheets} (superseded by \textsf{xsim}) by Clemens Niederberger, +% \textsf{exframe} by Niklas Beisert, +% \textsf{exam} by Philip Hirschhorn, +% \textsf{answers} by Mike Piff and Joseph Wright, +% \textsf{probsoln} by Nicola Talbot, etc. +% \end{enumerate} +% \end{answers} +% +% \DescribeMacro{\points} +% When only answers are displayed, the text color remains black, +% the word \emph{\correctionname} is not displayed and the +% |\points| macro is patched to suppress the display of points. +% An extended solution for a variable display of points will be disussed +% in section \ref{totalpoints} with the |\totalpoints| macro. +% +% \subsection{More about \texttt{answers} environment} +% Internally, we have used the |\comment| and |\endcomment| macros +% from the \textsf{versions} package by Uwe Lück. +% Other excellent packages allow to manage +% selectively piece of code. Let us mention +% \textsf{verbatim} by Rainer Schöpf, \textsf{comment} by Victor Eijkhout, +% \textsf{version} by Donald Arseneau and Stephen Bellantoni, +% \textsf{optional} by Donald Arseneau +% and \textsf{codesection} by Matthias Pospiech. +% +% The \textsf{versions} package used provides furthermore +% the |\includeversion|\marg{env} and +% |\excludeversion|\marg{env} macros who allow to make appear or disappear +% any environment \meta{env} and these optional environments +% may be nested\footnote{The \textsf{codesection} package also allows +% such nesting, including in the preamble, +% as well as the \textsf{optional} package, but the latter only manages short optional code.}. +% +% However the \texttt{questions} and \texttt{answers} environments +% perform another task, not only making appear or disappear piece of text. +% Indeed, there is a problem with the title \emph{\correctionname}. +% In which format to typeset it and at which level to put it in the table of contents +% (or in the summary of the pdf file)? +% In fact it depends on which level the environment has been nested. +% We can make a single \texttt{answers} environment for all the +% exercises of the sheet or an \texttt{answers} environment +% for each exercise, for each exercise part, for each question or sub-question. +% In fact, the typeset of the title \emph{\correctionname} +% and his level in the table of contents will be adjusted automatically. +% +% \DescribeEnv{\oarg{level}} +% Nevertheless, we can imagine twisted situations in which +% the title level will not be correctly calculated. +% It is then possible to force the level of the title \emph{\correctionname} +% with |\begin{answers}|\oarg{level}. +% The optional \meta{level} parameter is defined as follows: +% 1 for section level titles, +% 2 for subsections (like \emph{\exercisename}), +% 3 for subsubsections (like \emph{\partname}), +% another number for lower levels +% (then they will not appear in the table of contents). +% +% \bigskip +% \DescribeMacro{answers*} +% The starred version \texttt{answers*} allows to make the title +% \textbf{\correctionname} completely disappear. +% +% \subsection{The \texttt{\bs question} command} +% \DescribeMacro{\question} +% Instead of the \texttt{questions} and \texttt{answers} environments, +% we can also use the simple |\question|\marg{ques}\marg{ans} macro +% in which display of \meta{ques} and \meta{ans} arguments +% is controlled by the same previous commands |\questionsonly| and |\answersonly|. +% It can be more readable (in the source code) when questions and answers are short. +% In the case of displaying both questions and answers, +% the \emph{\correctionname} title will appear on a new line, in bold, +% as for levels lower than subsubsection in the \texttt{answers} environment +% (and without entries in the table of contents). +% But this command doesn't work with \texttt{verbatim} inside. +% +% \section{Marginal notes for marking scheme} +% +% The \textsf{exesheet} package allows the display of a marking +% scheme with comments and explanations for answers. +% +% \pagebreak +% \subsection{The \texttt{\bs pts} command} +% \DescribeMacro{\pts} +% When exercises are typeset with the |\exe| macro, +% or as a list with the \texttt{exenumerate} environment, +% the marking scheme is displayed in the margin, on the line where +% we put the |\pts|\marg{num} command (in general the first line of the exercise). +% The \meta{num} parameter is the number of points assigned to the exercise. +% +% \vspace{-\baselineskip} +% \noindent\psframe(-3.5,-0.25)(12.75,-2) +% \exe \pts{3} The first exercise with marking sheme. +% \exe \pts{1.5} The second one. +% +% \bigskip +% \DescribeMacro{\ptsname} \DescribeMacro{\ptname} +% \DescribeMacro{ptscolor} \DescribeMacro{\ptsstyle} +% The abbreviation \textsf{\ptsname} (or \textsf{\ptname} +% when the number of points is inferior to 2) +% is automatically added thanks to the macro |\ptsname| or |\ptname| +% (translated in a few languages if \textsf{babel} is loaded). +% The display color of the points is defined by \texttt{ptscolor} which can be changed +% with |\definecolor|: by default |\definecolor{ptscolor}{named}{red}|. +% The display style is defined by |\ptsstyle|. +% +% \DescribeMacro{\displaypts} +% The display of the marking scheme, as above, is internally controlled by the +% \texttt{marginpts} boolean. +% The |\displaypts| command, which has to be placed in the preamble, defines \texttt{marginpts} to \texttt{true}, +% places marginal notes to the left (and not to the right which +% is the default behavior of \LaTeX) +% and shifts the text body right to increase the left margin compared +% with the right one, with a ratio 3:2, +% as it is in the present document. +% This ratio is defined by the +% |geometry| macro from the \textsf{geometry} package (by Hideo Umeki) and is valid for the whole document. +% +% \subsection{The \texttt{\bs totalexe}, \texttt{\bs note} and \texttt{\bs totalpoints} commands} +% \label{totalpoints} +% \DescribeMacro{\totalexe} +% \DescribeMacro{\note} +% To give a more detailed marking sheme, the \textsf{exesheet} package +% provides some extended commands: +% |\totalexe|\marg{num} to display the total number of points of an exercise +% and especially |\note|\oarg{pts}\marg{comment}, +% to indicate some marking detail in answers. +% The optional parameter \meta{pts} is the number of points of the question +% and the mandatory parameter \meta{comment} is used to give details about the marking scheme. +% Below the title has been obtained with |\exercise[\totalexe{4}]| +% and the first comment with \\ +% |\note[1]{0,5 for the anti-derivative\\0,5 for simplification of $\ln$}|. +% +% \exercise[\totalexe{4}] \label{totalexe} +% \begin{questions} +% \psframe(-3.5,1.3)(12.75,-3.1) +% For each following question, say if the assertion is true or false. +% Justify the answer carefully. +% \begin{tablenum} +% \item $\ds \int_{0}^{\sqrt{3}}\frac{1}{x+\sqrt{3}} \,\mathrm{d}x = \ln 2$, +% \item $\ds \int_{2}^{\mathrm{e}} \frac{1}{x\ln x} \,\mathrm{d}x = -\ln 2$, +% \item* The function $F$ defined on $\mathbf{R}$ by +% $F(x) = \ds \int_{0}^{x}\frac{1}{,t^2+t+1}\,\mathrm{d} t$, is increasing on $\mathbf{R}$. +% \end{tablenum} +% \end{questions} +% +% \begin{answers} +% \vspace{-\baselineskip} +% \noindent\psframe(-4.7,0.9)(12.75,-10.25) +% \begin{enumerate} +% \item \note[1]{0,5 for the anti-derivative\\0,5 for simplification of $\ln$} +% We calculate: +% \[ \int_{0}^{\sqrt{3}}\frac{1}{x+\sqrt{3}}\,\mathrm{d}x +% = \bigg[ \ln\left(x+\sqrt{3}\right) \bigg]_0^{\sqrt{3}} +% = \ln\left(2\sqrt{3}\right)-\ln \sqrt{3} +% = \ln\left(\frac{2 \sqrt{3}}{\sqrt{3}}\right) +% =\ln 2. +% \] +% \textbf{TRUE}. +% +% \item \note[1.5]{1 for the anti-derivative \\0.5 for the integral value \\[2ex] +% we could also see that $\frac{1}{x \ln x} >0$ on $[2, \mathrm{e}]$ +% while $-\ln2<0$ +% } +% We have $\ds\frac{1}{x \ln x}= \frac{\frac{1}{x}}{\ln x}= \frac{u'(x)}{u(x)}$ +% with $u(x)=\ln x$, which is positive on $[2, \mathrm{e}]$. Hence +% +% \[ \int_{2}^{\mathrm{e}}\frac{1}{x \ln x}\,\mathrm{d}x +% = \Big[ \ln(\ln x) \Big]_2^\mathrm{e} +% = \ln(\ln \mathrm{e})-\ln(\ln2)= \ln1 -\ln(\ln2)=-\ln(\ln2). +% \] +% \textbf{FALSE}. +% +% \item \note*{1.5} +% The function $F$ defined on $\mathbf{R}$ by +% \[ F(x)= \int_{0}^{x}\frac{1}{t^2+t+1}\, \mathrm{d}t \] +% is derivable on $\mathbf{R}$ and its derivative is such that +% $F'(x)=\frac{1}{x^2+x+1}$. +% \note{0.5 for $F'$\\1 for the sign of $F'$ and conclusion} +% The denominator is a quadratic polynomial, always positive because its discriminant is +% $\Delta=-3 <0$. +% Thus $F$ is increasing on $\mathbf{R}$. \\ +% \textbf{TRUE}. +% \end{enumerate} +% \end{answers} +% In the comment of answer 2, a wider vertical space is produced at line break +% with the optional argument |\\[2ex]|\footnote{When a marginal note at the end of a page, +% is followed by another one at the top of the next page, +% the latter is shifted down. +% We can raise this note, by adding at the line break +% a negative vertical space : \texttt{\bs note*\{\bs\bs[-5ex] 2\}}.}. +% The last comment, not placed beside the number of points of answer 3, +% has been produced by placing on the first line after the formula: +% |\note{0.5 for $F'$\\1 for the sign of $F'$ and conclusion}|. +% +% \DescribeMacro{\note*} +% If we don't want to add comment, we have the +% |\note*|\marg{pts} command (better thant |\note|\oarg{pts}|{}|), +% used here in answer 3: |\note*{1.5}|. +% +% \DescribeMacro{markingcolor} \DescribeMacro{\markingstyle} \DescribeMacro{\ptsboxlength} +% The display color of the points, in |\totalexe| and |\note|, +% is defined by \texttt{markingcolor} +% and the style by |\markingstyle|, which are modifiables. +% The oval box produced by |\totalexe| is obtained with the |\ovalbox| command +% of the \textsf{fancybox} package by Timothy Van Zandt, +% with corner arcs set by |\cornersize{1}|. +% The box length is not adjusted to content but depends of the value +% of |\ptsboxlength| in order to keep a uniform appearance +% from one exercise to the other. +% +% \DescribeMacro{notecolor} \DescribeMacro{\notestyle} \DescribeMacro{\noteragged} +% Comment notes are typeset by default in a dark green color +% defined by |\definecolor{notecolor}{rgb}{0.0,0.4,0.0}|. +% The style of the comment is set by the |\notestyle| macro and itself uses the +% |\noteragged| macro. The latter is set by default as |\raggedleft| +% to obtain a \emph{right} alignment (what is customary for notes +% in the left margin). +% +% \DescribeMacro{\displaypoints} +% Display of points and comments is optional. It is internally controlled by the booleans +% \texttt{marginpoints} and \texttt{marginfullnotes}. +% The |\displaypoints| macro, to place in the preamble, sets \texttt{marginpoints} +% to \texttt{true}, chooses the left margin for display marginal notes +% and sets the ratio between left and right margins to 3:2\footnote{So +% that the effect on the margin ratio is correct, the +% \texttt{\bs displaypoints} macro must be placed after other commands that could alter the page geometry, for example the \texttt{\bs pagestyle} +% of the \textsf{schooldocs} package.}. +% Points will then be displayed without the comments. +% +% \DescribeMacro{\displaynotes} +% The |\displaynotes|\oarg{align} macro, to be placed also in the preamble, +% defines both booleans to \texttt{true} and allows then the complete display of points and comments. +% The ratio between left/right margins is then set to 5/1\footnote{The +% present document kept a ratio of 3/2 because +% the \textsf{ltxdoc} class, used here, leaves large enough margins +% and previous examples are not concerned with display of comments.}. +% The optional parameter \meta{align} is used to define alignment: +% |\raggedleft| by default, but we could use |\centering| or +% |\raggedright| (not recommended in left margin). +% +% \DescribeMacro{\displaynotesright} +% The |\displaynotesright|\oarg{align} macro displays a detailed marking scheme +% with comments in the right margin, with the same type of settings +% as |\displaynotes| but an optional parameter \meta{align} set by default +% to |\raggedleft|. +% +% \bigskip +% \DescribeMacro{\totalpoints} +% The |\totalpoints|\marg{num} macro is intended +% to replace |\points| when using a detailed marking scheme. +% When the scale is not displayed (\texttt{marginpoints} boolean to \texttt{false}), +% it uses |\points| and when the scale is displayed, +% it uses |\totalexe|. +% For example, in the exercise \ref{totalexe}, we should use +% |\totalpoints| rather than |\totalexe|, +% because, when the detailed marking scheme is not displayed, the total points will be typeset +% as in the exercise \ref{points} rather than in the margin. +% +% +% +% \StopEventually{} +% +% \section{Implementation} +% +% \subsection{Class and package basic instructions} +% The \texttt{exesheet} class is based on the \texttt{article} class +% and gives it all its options, except explicit options +% \texttt{notoc} and \texttt{nosetlist}. +% +% \begin{macrocode} +%<*class> +\DeclareOption{notoc}{\PassOptionsToPackage{notoc}{exesheet}} +\DeclareOption{nosetlist}{\PassOptionsToPackage{nosetlist}{exesheet}} +\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}} +\ProcessOptions \relax +\LoadClass{article} +\RequirePackage{exesheet} +\RequirePackage{schooldocs} +%</class> +% \end{macrocode} +% +% Then we define initialization instructions of the \textsf{exesheet} package. +% +% \medskip +% The \texttt{shortlabel} option in the \textsf{enumitem} package allows to use labels like in +% the \textsf{enumerate} package e.g. 1., a), A. etc. +% +% \begin{macrocode} +%<*package> +\RequirePackage{ifthen} +\newboolean{notoc} +\newboolean{nosetlist} +\DeclareOption{notoc}{\setboolean{notoc}{true}} +\DeclareOption{nosetlist}{\setboolean{nosetlist}{true}} +\ProcessOptions \relax +\RequirePackage{xcolor} +\RequirePackage[shortlabels]{enumitem} +\RequirePackage{tasks} +\RequirePackage{versions} +%\@ifpackageloaded{doc}{}{\RequirePackage{verbatim}} +\RequirePackage{geometry} +\RequirePackage{fancybox} + +% \end{macrocode} +% +% \subsection{Internationalization} +% Here we define the keywords and their translation in French, German, Spanish +% Italian, Portuguese, thanks to the |\addto\captions|\meta{language} macro +% of the \textsf{babel} package. +% +% Translations are placed in a macro |\exetranslate| because, if +% \textsf{exesheet} is called before \textsf{babel} (this is necessarily the case for the +% \textsf{exesheet} class), then these translations should only happen +% after having loaded the \textsf{babel} package, therefore the |\AtBeginDocument|. +% On the other hand, if the package is loaded \emph{after} \textsf{babel}, +% |AtBeginDocument{\exetranslate}| doesn't work, curiously. +% But calling immediately |\exetranslate| works in that case. +% +% Accented characters cannot be used here because they are not recognized +% if \textsf{inputenc} is loaded after \textsf{exesheet}, +% despite the |\AtBeginDocument|. So we have used the basic \LaTeX\ commands to produce them. +% +% \TODO: give the choice to use \textsf{polyglossia} instead of \textsf{babel}; +% see the \textsf{translations} or \textsf{multilang} packages. +% +% \begin{macrocode} +\def\exercisename{Exercise} +\def\subpartname{Part} +\def\annexname{Annex} +\def\exname{Ex} +\def\pointsname{points} +\def\pointname{point} +\def\correctionname{Correction} +\def\ptsname{pts} +\def\ptname{pt} + +\newcommand\exetranslate{% + \@ifpackageloaded{babel}{% + \addto\captionsfrench{% + \def\exercisename{Exercice} + \def\subpartname{Partie} + \def\annexname{Annexe} + \def\exname{Ex} + \def\pointsname{points} + \def\pointname{point} + \def\correctionname{Correction} + \def\ptsname{pts} + \def\ptname{pt} + } + \addto\captionsgerman{% + \def\exercisename{\"Ubung} + \def\subpartname{Teil} + \def\annexname{Anhang} + \def\exname{\"Ub} + \def\pointsname{Punkte} + \def\pointname{Punkt} + \def\correctionname{Verbesserung} + \def\ptsname{Pkte} + \def\ptname{Pkt} + } + \addto\captionsspanish{% + \def\exercisename{Ejercicio} + \def\subpartname{Parte} + \def\annexname{Anexo} + \def\exname{Ej} + \def\pointsname{puntos} + \def\pointname{punto} + \def\correctionname{Correcci\'on} + \def\ptsname{ptos} + \def\ptname{pot} + } + \addto\captionsitalian{% + \def\exercisename{Esercizio} + \def\subpartname{Parte} + \def\annexname{Ansesso} + \def\exname{Es} + \def\pointsname{punti} + \def\pointname{punto} + \def\correctionname{Correzione} + \def\ptsname{pti} + \def\ptname{pt} + } + \addto\captionsportuges{% + \def\exercisename{Exerc\'icio} + \def\subpartname{Parte} + \def\annexname{Anexo} + \def\exname{Ex} + \def\pointsname{pontos} + \def\pointname{ponto} + \def\correctionname{Corre\c c\~ao} + \def\ptsname{pts} + \def\ptname{pt} + } + }{} + } + +\AtBeginDocument{\exetranslate} % if loaded before babel +\exetranslate % necessary when loaded after babel + +% \end{macrocode} +% +% \subsection{Colors} +% The color \texttt{pointscolor} is used by the macro |\points| +% and \texttt{markingcolor} by the macros |\totalexe|, |\note*| +% and also for the optional argument of |\note|; +% \texttt{notecolor} is used by the mandatory argument of |\note|. +% +% \begin{macrocode} +\definecolor{pointscolor}{named}{red} +\definecolor{ptscolor}{named}{red} +\definecolor{markingcolor}{named}{red} +\definecolor{notecolor}{rgb}{0.0, 0.4, 0.0} % kind of dark green +\definecolor{correctioncolor}{rgb}{0,0.2,0.6} % kind of dark blue + +% \end{macrocode} +% +% \medskip +% \subsection{Titles} +% The \texttt{exercise} counter numbers exercises for the whole document +% regardless of any section. +% To reset the counter at some point, just write |\setcounter{exercise}{0}| +% and if we want an automatic reset at each section, +% add in the preamble \\ +% |\makeatletter \@addtoreset{exercise}{section} \makeatother|. +% +% The parts counter depends on \texttt{exercise} and is reset +% at each new exercise. +% +% The |\labelexercisestyle| and |\labelsubpartstyle| commands +% are empty, but allow to customize the style, for instance:\\ +% |\renewcommand\labelexercisestyle{\sffamily}|. +% +% By default, the table of contents displays the titles of exercises and parts. +% The \texttt{notoc} boolean is used to modify this behavior. +% If we want to display only exercise titles but not parts, +% we can place in the preamble |\setcounter{tocdepth}{2}|. +% +% \begin{macro}{\exercise} +% \begin{macrocode} +\newcounter{exercise} + +\newcommand{\labelexercise}{\exercisename~\theexercise} +\newcommand{\labelexercisestyle}{} +\newcommand*{\@exercise}[1][]{% + \refstepcounter{exercise} + \subsection*{\labelexercisestyle\labelexercise\ #1} + \ifthenelse{\boolean{notoc}}{}{ + \addcontentsline{toc}{subsection}{\labelexercise} + } + } +\newcommand*{\@@exercise}[2][]{% + \subsection*{\labelexercisestyle #2 #1} + \setcounter{subpart}{0} % resets the parts counter + \ifthenelse{\boolean{notoc}}{}{ + \addcontentsline{toc}{subsection}{#2} + } + } +\newcommand{\exercise}{\@ifstar{\@@exercise}{\@exercise}} + +% \end{macrocode} +% \end{macro} +% \begin{macro}{\subpart} +% \begin{macrocode} +\newcounter{subpart}[exercise] % +\renewcommand{\thesubpart}{\Alph{subpart}} + +\newcommand{\labelsubpart}{\subpartname~\thesubpart} +\newcommand{\labelsubpartstyle}{} +\newcommand*{\@subpart}[1][]{% + \refstepcounter{subpart}% + \subsubsection*{\labelsubpartstyle\labelsubpart\ #1} + \ifthenelse{\boolean{notoc}}{}{ + \addcontentsline{toc}{subsubsection}{\labelsubpart} + } + } +\newcommand*{\@@subpart}[2][]{% + \subsubsection*{\labelsubpartstyle #2 #1} + \ifthenelse{\boolean{notoc}}{}{ + \addcontentsline{toc}{subsubsection}{#2} + } + } +\newcommand{\subpart}{\@ifstar{\@@subpart}{\@subpart}} + +% \end{macrocode} +% \end{macro} +% \begin{macro}{\annex} +% \begin{macrocode} +\newcommand{\annexstyle}{\MakeUppercase} +\newcommand*{\annex}[1][]{% + \subsection*{\mbox{}\hfill\annexstyle{\annexname} #1\hfill\mbox{}} + \ifthenelse{\boolean{notoc}}{}{ + \addcontentsline{toc}{subsection}{\annexname} + } + } + +% \end{macrocode} +% \end{macro} +% \begin{macro}{\exe} +% \begin{macrocode} +\newcommand{\exlabel}{\exname.~\theexercise} +\newcommand{\exsepmark}{---} +\newcommand{\@exe}{\textbf{\exlabel~\exsepmark}~} +\newcommand{\@@exe}{\textbf{\exlabel}~} +\newcommand{\exe}{\bigskip\par\noindent\refstepcounter{exercise} + \@ifstar{\@@exe}{\@exe} + } + +% \end{macrocode} +% \end{macro} +% \begin{macro}{\points (ini)} +% \begin{macrocode} +\newcommand{\pointsstyle}{% + \small\mdseries\sffamily\color{pointscolor}\fbox} +\newcommand*{\points}[1]{\hfill + \pointsstyle{#1~% + \ifthenelse{\lengthtest{#1 cm < 2cm}}{\pointname}{\pointsname}% + } + } + +% \end{macrocode} +% Percent symbols are necessary to avoid spaces between the +% |\fbox| and its inner text. +% Note that, without |\lengthtest|, the test |#1 < 2| doesn't work with decimal numbers. +% % \end{macro} +% +% \subsection{Enumerations and lists} +% +% When using \textsf{babel} with the \texttt{french} option\footnote{The \texttt{french} option +% of \textsf{babel} superseeds the \texttt{frenchb} option.}, +% \texttt{itemize} lists are modified with the same dash label for each list level. These modifications are cancelled here to restore default \LaTeX\ \texttt{itemize} lists (labels and spaces). +% As for |\exetranslate|, +% we have create the |\standardfrenchlists| command who must be called into +% |AtBeginDocument| or not, depending on whether +% \textsf{exesheet} is loaded before \textsf{babel} or after. +% +% The |\setlist| command comes from the \textsf{enumitem} package +% (|\setenumerate| is deprecated). By default |itemsep=1ex| for lists of first level, +% and |leftmargin=1.5em| allows to align labels on the start of lines. +% +% \begin{macrocode} +\newcommand\standardfrenchlists{% + \@ifpackagewith{babel}{frenchb}{ + \frenchbsetup{StandardLists=true}}{} + \@ifpackagewith{babel}{french}{ + \@ifundefined{frenchsetup}{ + \frenchbsetup{StandardLists=true}}{ + \frenchsetup{StandardLists=True}} + }{} + } +\ifthenelse{\boolean{nosetlist}}{}{ + \AtBeginDocument{% if loaded before babel package + \standardfrenchlists} + \standardfrenchlists % necessary when loaded after babel + \setlist[enumerate]{font=\bfseries} + \setlist[enumerate,1]{topsep=1.5ex plus 1ex minus 1ex,leftmargin=1.5em} + } + +% \end{macrocode} +% \begin{macro}{\exenumerate} +% \begin{macrocode} +\newenvironment{exenumerate}[1][]{% + \setlist[enumerate]{font=\bfseries} + \setlist[enumerate,1]{leftmargin=1.5em, + itemsep=3ex plus 1ex minus 1ex,topsep=3ex plus 1ex minus 1ex} + \setlist[enumerate,3]{noitemsep,nolistsep} + \setlist[itemize]{noitemsep,nolistsep} + \begin{enumerate}[#1] + }{\end{enumerate}} + +% \end{macrocode} +% \end{macro} +% \DescribeEnv{tablenum} \DescribeEnv{tablenuma} +% The |\NewTasks| command comes from the \textsf{tasks} package. +% It allows to define the environments \texttt{tablenum}, \texttt{tablenuma} +% and \texttt{tablitem}. +% The horizontal spaces are adjusted to get a good alignment with +% items of other \texttt{enumerate} (or \texttt{itemize}) environments. +% +% \begin{macrocode} +\ifthenelse{\boolean{nosetlist}}{ + \NewTasks[counter-format=tsk[1]., + column-sep=1em, + after-item-skip=0.5ex plus 0.5ex minus 0.5ex]{tablenum}[\item](2) + \NewTasks[counter-format=(tsk[a]), + column-sep=1em,label-align=right, + item-indent=2.15em,label-width=1.6em,label-offset=0.5em, + after-item-skip=0.5ex plus 0.5ex minus 0.5ex]{tablenuma}[\item](2) + }{% by default + \NewTasks[counter-format=tsk[1].,label-format=\bfseries, + column-sep=1em,label-align=right, + item-indent=1.5em,label-width=1em,label-offset=0.5em, + after-item-skip=0.5ex plus 0.5ex minus 0.5ex]{tablenum}[\item](2) + \NewTasks[counter-format=(tsk[a]),label-format=\bfseries, + column-sep=1em,label-align=right, + item-indent=2.15em,label-width=1.6em,label-offset=0.5em, + after-item-skip=0.5ex plus 0.5ex minus 0.5ex]{tablenuma}[\item](2) + } + +% \end{macrocode} +% \DescribeEnv{tablitem} +% \begin{macrocode} +\NewTasks[label=\labelitemi, + label-align=right, + item-indent=2.3333em,label-offset=0.5em, + after-item-skip=0.5ex plus 0.5ex minus 0.5ex]{tablitem}[\item](2) + +% \end{macrocode} +% \DescribeEnv{colsenum} \DescribeEnv{colsenum*} +% \begin{macrocode} +\newenvironment{colsenum}[2][]{% + \setlength{\multicolsep}{2ex} + \raggedcolumns % default is \flushcolumns + \begin{multicols}{#2} % #2 = number of columns + \begin{enumerate}[#1] % #1 = options of enumerate + }{ + \end{enumerate} + \end{multicols} +} + +\newenvironment{colsenum*}[2][]{% + \setlength{\multicolsep}{2ex} + \begin{multicols}{#2} % #2 = number of columns + \begin{enumerate}[#1] % #1 = options of enumerate + }{ + \end{enumerate} + \end{multicols} +} + +% \end{macrocode} +% \DescribeEnv{colsitem} \DescribeEnv{colsitem*} +% \begin{macrocode} +\newenvironment{colsitem}[2][]{% + \setlength{\multicolsep}{2ex} + \raggedcolumns + \begin{multicols}{#2} + \begin{itemize}[#1] + }{ + \end{itemize} + \end{multicols} +} + +\newenvironment{colsitem*}[2][]{% + \setlength{\multicolsep}{2ex} + \begin{multicols}{#2} + \begin{itemize}[#1] + }{ + \end{itemize} + \end{multicols} +} + +% \end{macrocode} +% +% \subsection{Questions and answers} +% +% \DescribeMacro{\questionsonly} \DescribeMacro{\answersonly} +% The \texttt{questions} and \texttt{answers} booleans +% control the display of corresponding environments. +% When created, a boolean has the \texttt{false} value by default, +% but we define them to \texttt{true}. +% The |\questionsonly| and |\answersonly| macros are used as user interface +% to display only one of the two environments. +% \begin{macrocode} +\newboolean{questions} +\newboolean{answers} +\setboolean{questions}{true} +\setboolean{answers}{true} +\newcommand{\questionsonly}{ + \setboolean{questions}{true}\setboolean{answers}{false}} +\newcommand{\answersonly}{ + \setboolean{questions}{false}\setboolean{answers}{true}} + +% \end{macrocode} +% +% \begin{environment}{questions} +% It is the |\comment| and |\endcomment| macros, provided by the \textsf{versions} package, +% that allow the magic of conditional displays (we can also find them in the \textsf{verbatim} or \textsf{version} packages). +% The noteworthy \textsf{codesection} package, allows to encapsulate +% optional code between the macros |\BeginCodeSection|\marg{skip} and |\EndCodeSection|\marg{skip}, +% both in the text body and in the preamble, +% but these macros cannot be used inside an environment +% as we did here for |\comment| and |\endcomment|. +% \begin{macrocode} +\newcounter{exe@ini} +\newcounter{subpart@ini} + +\newenvironment{questions}{ + \ifthenelse{\boolean{questions}}{ + \setcounter{exe@ini}{\value{exercise}} + \setcounter{subpart@ini}{\value{subpart}} + }{\comment}}% + {\ifthenelse{\boolean{questions}}{}{\endcomment}} + +% \end{macrocode} +% \end{environment} +% \begin{environment}{answers} +% The internal macro |\set@toclevel| calculates the title level +% of the word \emph{\correctionname} to display at the start of an +% \texttt{answers} environment (when \texttt{questions} and \texttt{answers} are +% displayed together). The principle is to compare the state of the counters +% \texttt{exercise} and \texttt{subpart} with those saved at the time of +% the call of \texttt{questions}. The |\@enumdepth| counter indicates the +% \texttt{enumerate} list level in which we are (0 = out of lists). +% The optional parameter of the \texttt{answers} environment allows to force this title level. +% \begin{macrocode} +\newcounter{@toclevel} +\newcommand{\set@toclevel}[1][]{ + \ifthenelse{\equal{#1}{}}{ + \ifthenelse{\value{exercise} > \value{exe@ini}}{ + \setcounter{@toclevel}{1} + }{\ifthenelse{\equal{\the\@enumdepth}{0}}{ + % we're not in an enumerate environment + \ifthenelse{\(\value{subpart} > \value{subpart@ini}\) + \or \(\value{subpart} = 0\)}{ + \setcounter{@toclevel}{2} + }{\setcounter{@toclevel}{3}} + }{\setcounter{@toclevel}{4}}} + }{\setcounter{@toclevel}{#1}}} + +\newcommand{\correctionstyle}{\color{correctioncolor}} + +\newenvironment{answers}[1][]{% #1 is the optional level + \ifthenelse{\boolean{answers}}{% + \ifthenelse{\boolean{questions}}{% + \set@toclevel[#1] + \ifthenelse{\value{@toclevel} = 1}{ + \section*{\correctionstyle\correctionname} + \ifthenelse{\boolean{notoc}}{}{ + \addcontentsline{toc}{section}{\correctionname}} + \setcounter{exercise}{0} + }{\ifthenelse{\value{@toclevel} = 2}{% + \subsection*{\correctionstyle\correctionname} + \ifthenelse{\boolean{notoc}}{}{ + \addcontentsline{toc}{subsection}{\correctionname}} + \setcounter{subpart}{0} + }{\ifthenelse{\value{@toclevel} = 3}{% + \subsubsection*{\correctionstyle\correctionname} + \ifthenelse{\boolean{notoc}}{}{ + \addcontentsline{toc}{subsubsection}{ + \correctionname}} + }{\par\textbf{\correctionstyle\correctionname}\par + }% + }% + }% + \correctionstyle% + }{}% + }{\comment} +}{\ifthenelse{\boolean{answers}}{}{\endcomment}} + +\newenvironment{answers*}{\ifthenelse{\boolean{answers}}{}{\comment}}% + {\ifthenelse{\boolean{answers}}{}{\endcomment}} + +% \end{macrocode} +% In the \texttt{answers} environment, if we place |\correctionstyle| +% before |\subsubsection|, the preceding vertical space may be too wide. +% +% \end{environment} +% \begin{macro}{\question} +% \begin{macrocode} +\newcommand{\question}[2]{% + \ifthenelse{\boolean{questions}}{#1}{} + \bgroup + \ifthenelse{\boolean{answers}}{ + \ifthenelse{\boolean{questions}}{ + \ifx#2\empty\else + \par\correctionstyle\textbf{\correctionname}\par + \fi + }{} + #2}{} + \egroup + } + +% \end{macrocode} +% \end{macro} +% \begin{macro}{\points (patched)} +% \begin{macrocode} +\let\@oldpoints\points +\renewcommand*{\points}[1]{% + \ifthenelse{\boolean{questions}}{\@oldpoints{#1}}{}} + +% \end{macrocode} +% \end{macro} +% +% \subsection{Marginal notes} +% +% The commands |\displaypts|, |\displaypoints| and |\displaynotes| +% change the ratio between left and right margins\footnote{So +% that the effect on the margin ratio is correct, these +% macros must be called, in the preamble, after other commands that also could alter the page geometry.}. +% +% \DescribeMacro{\pts} \DescribeMacro{\displaypts} +% \begin{macrocode} +\newboolean{marginpts} +\newcommand*{\pointmark}[1]{% + \ifthenelse{\lengthtest{#1 cm < 2cm}}{#1 \ptname}{#1 \ptsname}} +\newcommand{\ptsstyle}[1]{% + \footnotesize\centering\sffamily\color{ptscolor} (#1)} +\newcommand*{\pts}[1]{% + \ifthenelse{\boolean{marginpts}}{% + \mbox{}% + \marginpar{\hspace{0pt}% + \ptsstyle{\pointmark{#1}}}% + }{}% + \ignorespaces + } +\newcommand{\displaypts}{% + \reversemarginpar + \geometry{hmarginratio=3:2} + \setboolean{marginpts}{true} + } + +% \end{macrocode} +% +% \begin{macro}{\totalexe} +% In the following macros using +% |\marginpar|, percent symbols and |\ignorespaces| are necessary to avoid too much space in the text (or the margin) +% where these macros are inserted. +% \begin{macrocode} +\newlength{\ptsboxlength} +\setlength{\ptsboxlength}{3.1em} +\cornersize{1} +\newcommand*{\totalexe}[1]{% + \ifthenelse{\boolean{marginpoints}}{% + \mbox{}% + \marginpar{\markingstyle{\ovalbox{% + \makebox[\ptsboxlength]{\pointmark{#1}}}% + }}% + }{}% + \ignorespaces + } + +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\note} +% The booleans \texttt{marginpoints} and \texttt{marginfullnotes} control +% the display of marginal notes. If \texttt{marginpoints} is \texttt{false}, +% \texttt{marginfullnotes} will be ignored. +% The |\noteragged| command is initialized outside |\displaynotes| +% such that we can use the |\note| command without |\displaynotes| (see further). +% \begin{macrocode} +\newboolean{marginpoints} +\newboolean{marginfullnotes} + +\newcommand{\markingstyle}[1]{\hspace{0pt}\footnotesize\sffamily% + \centering\color{markingcolor}\textbf{#1}} +\newcommand{\noteragged}{\raggedleft} +\newcommand{\notestyle}[1]{\hspace{0pt}\footnotesize\sffamily% + \noteragged\noindent\color{notecolor} #1} +\newcommand{\@note}[2][]{% + \ifthenelse{\boolean{marginpoints}}{% + \mbox{}% + \marginpar{% + \ifthenelse{\equal{#1}{}}{}{\markingstyle{#1}\\}% + \ifthenelse{\boolean{marginfullnotes}}{\notestyle #2}{}% + }% + }{}% + \ignorespaces + } +\newcommand{\@@note}[1]{% + \ifthenelse{\boolean{marginpoints}}{% + \mbox{}% + \marginpar{\markingstyle{#1}}% + }{}% + \ignorespaces + } +\newcommand{\note}{\@ifstar{\@@note}{\@note}} + +% \end{macrocode} +% \end{macro} +% +% \DescribeMacro{\displaypoints} \DescribeMacro{\displaynotes} +%\DescribeMacro{\displaynotesright} +% In |\displaynotes|, the additional length \texttt{1\,in} matches +% the default free space to the left of |\oddsidemargin|. +% +% \begin{macrocode} +\newcommand{\displaypoints}{% + \reversemarginpar + \geometry{hmarginratio=3:2} + \setboolean{marginpoints}{true} + } + +\newcommand*{\displaynotes}[1][\raggedleft]{% + \reversemarginpar + \renewcommand{\noteragged}{#1} + \geometry{hmarginratio=5:1} + \setlength{\marginparwidth}{\oddsidemargin} + \addtolength{\marginparwidth}{1in} + \addtolength{\marginparwidth}{-\marginparsep} + \setlength{\marginparwidth}{0.8\marginparwidth} + \setboolean{marginpoints}{true} + \setboolean{marginfullnotes}{true} + } + +\newcommand*{\displaynotesright}[1][\raggedright]{% + \normalmarginpar + \renewcommand{\noteragged}{#1} + \geometry{hmarginratio=1:5} + \setlength{\marginparwidth}{\paperwidth} + \addtolength{\marginparwidth}{-\textwidth} + \addtolength{\marginparwidth}{-\oddsidemargin} + \addtolength{\marginparwidth}{-\marginparsep} + \addtolength{\marginparwidth}{-1in} + \setlength{\marginparwidth}{0.8\marginparwidth} + \setboolean{marginpoints}{true} + \setboolean{marginfullnotes}{true} + } +% \end{macrocode} +% The formatting of marginal notes can possibly be made more regular +% with the \textsf{ragged2e} package, not loaded by \textsf{exesheet}. +% We will then have to enter, as an optional parameter of |\displaypoints|: +% |\RaggedLeft|, |\Centering|, |\RaggedRight| or |justifying|. +% +% \begin{macro}{\totalpoints} +% \begin{macrocode} +\newcommand{\totalpoints}{% + \ifthenelse{\boolean{marginpoints}}{\totalexe}{\points}} +%</package> +% \end{macrocode} +% \end{macro} +% +% \Finale +\endinput diff --git a/macros/latex/contrib/exesheet/exesheet.ins b/macros/latex/contrib/exesheet/exesheet.ins new file mode 100644 index 0000000000..37b10a4848 --- /dev/null +++ b/macros/latex/contrib/exesheet/exesheet.ins @@ -0,0 +1,56 @@ +%% +%% Copyright (C) 2020 by Antoine Missier <antoine.missier@ac-toulouse.fr> +%% +%% This file 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. +%% + +\input docstrip.tex +\keepsilent + +\usedir{tex/latex/exesheet} + +\preamble + +This is a generated file. + +Copyright (C) 2020 by Antoine Missier <antoine.missier@ac-toulouse.fr> + +This file 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. + +\endpreamble + +\generate{\file{exesheet.cls}{\from{exesheet.dtx}{class}} + \file{exesheet.sty}{\from{exesheet.dtx}{package}}} + +\obeyspaces +\Msg{*************************************************************} +\Msg{* *} +\Msg{* To finish the installation you have to move the following *} +\Msg{* files into a directory searched by TeX: *} +\Msg{* *} +\Msg{* exesheet.cls exesheet.sty *} +\Msg{* *} +\Msg{* To produce the documentation run the file exesheet.dtx *} +\Msg{* through LaTeX + dvips + ps2pdf *} +\Msg{* *} +\Msg{* Happy TeXing! *} +\Msg{* *} +\Msg{*************************************************************} + +\endbatchfile diff --git a/macros/latex/contrib/exesheet/exesheet.pdf b/macros/latex/contrib/exesheet/exesheet.pdf Binary files differnew file mode 100644 index 0000000000..3783421f5a --- /dev/null +++ b/macros/latex/contrib/exesheet/exesheet.pdf diff --git a/macros/latex/contrib/membranecomputing/README.md b/macros/latex/contrib/membranecomputing/README.md new file mode 100644 index 0000000000..70a87c6b6a --- /dev/null +++ b/macros/latex/contrib/membranecomputing/README.md @@ -0,0 +1,26 @@ +membranecomputing - a LaTeX package for the Membrane Computing +community. It comprises the definition of P systems, rules and +some concepts related to languages and computational +complexity usually needed for Membrane Computing research. + +Written by David Orellana Martín <dorellana@us.es> + +No dependencies other than the standards ifthen and xstring packages. +See membranecomputing.pdf for full documentation + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright and license +% ===================== +% +% Copyright (C) 2020 David Orellana Martín +% +% 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. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ No newline at end of file diff --git a/macros/latex/contrib/membranecomputing/membranecomputing.pdf b/macros/latex/contrib/membranecomputing/membranecomputing.pdf Binary files differnew file mode 100644 index 0000000000..8fc5b20098 --- /dev/null +++ b/macros/latex/contrib/membranecomputing/membranecomputing.pdf diff --git a/macros/latex/contrib/membranecomputing/membranecomputing.sty b/macros/latex/contrib/membranecomputing/membranecomputing.sty new file mode 100644 index 0000000000..bb513168d5 --- /dev/null +++ b/macros/latex/contrib/membranecomputing/membranecomputing.sty @@ -0,0 +1,599 @@ +%% +%% Copyright 2020 David Orellana Martín +% +% 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 David Orellana Martín +% +% This work consists of the file membranecomputing.sty. + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{membranecomputing}[2020/07/23 Membrane Computing v0.1] + +% Require Packages + +\RequirePackage{ifthen} +\RequirePackage{xstring} + +% Declare options + +\newboolean{membranecomputing@blackboard} +\setboolean{membranecomputing@blackboard}{false} +\DeclareOption{blackboard}{ + \setboolean{membranecomputing@blackboard}{true} +} +\DeclareOption{traditional}{ + \setboolean{membranecomputing@blackboard}{false} +} +\ProcessOptions\relax + +% Declare counters +\newcounter{membranecomputing@membrane} +\newcounter{membranecomputing@imembrane} +\newcounter{membranecomputing@element} + +% Declare auxiliary commands + +\newcommand{\membranecomputing@iden}[1]{#1} +\newcommand{\lhsC}{} +\newcommand{\rhsC}{} +\newcommand{\lhsL}{} +\newcommand{\rhsL}{} +\newcommand{\lhsP}{} +\newcommand{\rhsP}{} +\newcommand{\lhsIC}{} +\newcommand{\rhsIC}{} +\newcommand{\lhsIL}{} +\newcommand{\rhsIL}{} +\newcommand{\lhsIP}{} +\newcommand{\rhsIP}{} +\newcommand{\lhsOC}{} +\newcommand{\rhsOC}{} +\newcommand{\lhsE}{} +\newcommand{\lhsS}{} +\newcommand{\rhsS}{} +\newcommand{\rhsD}{} + +\newcommand{\arrow}{} +\newcommand{\labelSub}{} +\newcommand{\labelSubL}{} +\newcommand{\labelSubR}{} +\newcommand{\polW}{} +\newcommand{\polP}{} +\newcommand{\polWL}{} +\newcommand{\polPL}{} +\newcommand{\polWR}{} +\newcommand{\polPR}{} +\newcommand{\formattedRule}{} + +\exploregroups \expandarg + +\newcommand{\formatRule}[4]{ + \renewcommand{\arrow}{\ensuremath{\IfStrEq{#1}{written}{\rightarrow}{\, --> \,}}} + \IfStrEqCase{#2} + {% BEGIN CASES + {rewriting} + {%BEGIN IF REWRITING + \renewcommand{\formattedRule}{#3 \arrow #4} + }% END IF REWRITING + {single} + {% BEGIN IF SINGLE + \renewcommand{\formattedRule}{#3 \arrow #4} + }% END IF SINGLE + {multiple} + {% BEGIN IF MULTIPLE + \renewcommand{\formattedRule}{#3 \arrow #4} + }% END IF MULTIPLE + {paren} + {% BEGIN IF PAREN + \renewcommand{\formattedRule}{#3 / #4} + }% END IF PAREN + }% END CASES + \ensuremath{\IfStrEq{#1}{written}{\formattedRule}{\mathtt{\formattedRule}}} +} + +% Commands that depend on the kind of letters +\ifthenelse{\boolean{membranecomputing@blackboard}}{ % + \newcommand{\workingalphabet}{\ensuremath{O}} + \newcommand{\inputalphabet}{\ensuremath{E}} + \newcommand{\initmultiset}[1]{\ensuremath{w_{#1}}} + \newcommand{\ruleset}[1]{\ensuremath{R_{#1}}} + \newcommand{\probabilitiesset}[1]{\ensuremath{p_{#1}}} +}{ + \newcommand{\workingalphabetspiking}{\ensuremath{O}} + \newcommand{\workingalphabet}{\ensuremath{\Gamma}} + \newcommand{\inputalphabet}{\ensuremath{\Sigma}} + \newcommand{\initmultiset}[1]{\ensuremath{\mathcal{M}_{#1}}} + \newcommand{\ruleset}[1]{\ensuremath{\mathcal{R}_{#1}}} + \newcommand{\probabilitiesset}[1]{\ensuremath{\rho_{#1}}} +} + +% Commands that do not depend on the kind of letters +\newcommand{\labelset}{\ensuremath{H}} +\newcommand{\membranestructure}{\ensuremath{\mu}} +\newcommand{\neuron}[1]{\ensuremath{\sigma_{#1}}} +\newcommand{\compartment}[1]{\ensuremath{C_{#1}}} +\newcommand{\agent}[1]{\ensuremath{B_{#1}}} +\newcommand{\iin}{\ensuremath{i_{in}}} +\newcommand{\iout}{\ensuremath{i_{out}}} +\newcommand{\degree}{\ensuremath{q}} +\newcommand{\syn}{\ensuremath{syn}} +\newcommand{\yes}{\ensuremath{\mathtt{yes}}} +\newcommand{\no}{\ensuremath{\mathtt{no}}} +\newcommand{\initEnvironment}{\ensuremath{v_{E}}} + +% Shortcuts +\newcommand{\wa}{\workingalphabet} +\newcommand{\ia}{\inputalphabet} +\newcommand{\ls}{\labelset} +\newcommand{\ms}{\membranestructure} +\newcommand{\im}{\initmultiset} +\newcommand{\rs}{\ruleset} +\newcommand{\ps}{\probabilitiesset} +\newcommand{\vE}{\initEnvironment} + +\newcommand{\psystem}[5][nonrecognizer] +{% BEGIN COMMAND PSYSTEM + \IfEqCase{#3} + {% BEGIN CASES + {transition} + {% BEGIN IF TRANSITION + \ensuremath{\Pi_{#4} = \left(\wa, \ifthenelse{\equal{#1}{recognizer}}{\Sigma, }{} \ifthenelse{\equal{#2}{cell}}{\ms, }{} \im{1}, \dots, \im{\ifthenelse{\equal{#5}{}}{\degree}{#5}}, (\rs{1}, \ps{1}), \dots, (\rs{\ifthenelse{\equal{#5}{}}{\degree}{#5}}, \ps{\ifthenelse{\equal{#5}{}}{\degree}{#5}}), \ifthenelse{\equal{#1}{recognizer}}{\iin, }{} \iout \right)} + }% END IF TRANSITION + {activemembranes} + {% BEGIN IF ACTIVEMEMBRANES + \ensuremath{\Pi_{#4} = \left(\wa, \ifthenelse{\equal{#1}{recognizer}}{\Sigma, }{} \ifthenelse{\equal{#2}{cell}}{\ms, }{} \im{1}, \dots, \im{\ifthenelse{\equal{#5}{}}{\degree}{#5}}, \rs{1}, \dots, \rs{\ifthenelse{\equal{#5}{}}{\degree}{#5}}, \ifthenelse{\equal{#1}{recognizer}}{\iin, }{} \iout \right)} + }% END IF ACTIVEMEMBRANES + {symportantiport} + {% BEGIN IF SYMPORTANTIPORT + \ensuremath{\Pi_{#4} = \left(\wa, \ifthenelse{\equal{#1}{recognizer}}{\Sigma, }{} \mathcal{E}, \ifthenelse{\equal{#2}{cell}}{\ms, }{} \im{1}, \dots, \im{\ifthenelse{\equal{#5}{}}{\degree}{#5}}, \ifthenelse{\equal{#2}{cell}}{\rs{1}, \dots, \rs{\ifthenelse{\equal{#5}{}}{\degree}{#5}}}{\rs}, \ifthenelse{\equal{#1}{recognizer}}{\iin, }{} \iout \right)} + }% END IF SYMPORTANTIPORT + {spiking} + {% BEGIN IF SPIKING + \ensuremath{\Pi_{#4} = \left(\ifthenelse{\boolean{membranecomputing@blackboard}}{\wa}{\workingalphabetspiking}, \neuron{1}, \dots, \neuron{\ifthenelse{\equal{#5}{}}{\degree}{#5}}, \syn, \ifthenelse{\equal{#1}{recognizer}}{\iin, }{} \iout \right)} + }% END IF SPIKING + {kernel} + {% BEGIN IF KERNEL + \ensuremath{k\Pi_{#4} = \left(\wa, \ifthenelse{\equal{#2}{cell}}{\ms, }{} \compartment{1}, \dots, \compartment{\ifthenelse{\equal{#5}{}}{\degree}{#5}}, \ifthenelse{\equal{#1}{recognizer}}{\iin, }{} \iout \right)} + }% END IF KERNEL + {colony} + {% BEGIN IF COLONY + \ensuremath{\Pi_{#4} = \left(\wa, \ifthenelse{\equal{#1}{recognizer}}{\Sigma, }{} e, f, \vE, \agent{1}, \dots, \agent{\ifthenelse{\equal{#5}{}}{\degree}{#5}}, \ifthenelse{\equal{#1}{recognizer}}{\iin, }{}\right)} + }% END IF COLONY + }% END CASES + [\PackageError{psystem}{Undefined option to psystem: #3}] +}% END COMMAND PSYSTEM + +\newcommand{\wrule}[5][multiple]{\mcrule[written]{#1}{#2}{#3}{#4}{#5}} +\newcommand{\prule}[5][multiple]{\mcrule[plingua]{#1}{#2}{#3}{#4}{#5}} + +\newcommand{\mcrule}[6][written] +{% BEGIN COMMAND RULE + \IfEqCase{#2} + {% BEGIN CASES TYPE + {rewriting} + {% BEGIN IF REWRITING + \renewcommand{\lhsC}{} + \renewcommand{\rhsC}{} + \formatRule{#1}{#2}{#5}{#6} + }% END IF REWRITING + {single} + {% BEGIN IF SINGLE + \renewcommand{\lhsC}{} + \renewcommand{\rhsC}{} + \renewcommand{\lhsL}{} + \renewcommand{\rhsL}{} + \renewcommand{\lhsP}{} + \renewcommand{\rhsP}{} + \StrFindGroup{#5}{1}[\lhsC] + \StrFindGroup{#6}{1}[\rhsC] + \StrFindGroup{#5}{2}[\lhsL] + \StrFindGroup{#5}{3}[\lhsP] + \renewcommand{\polW}{\ensuremath{\IfStrEq{#1}{written}{^{\lhsP}}{}}} + \renewcommand{\polP}{\ensuremath{\IfStrEq{#1}{plingua}{\lhsP}{}}} + \renewcommand{\labelSub}{\ensuremath{\IfStrEq{#1}{written}{_{\lhsL}}{'\lhsL}}} + \formatRule{#1}{#2}{\ensuremath{\polP \left[ \, \lhsC}}{\ensuremath{\rhsC \, \right]\polW\labelSub}} + % \ensuremath{\left[ \, \lhsC \rightarrow \rhsC \, \right]^{\ifthenelse{\equal{\lhsP}{}} {\rhsP} {\lhsP} }_{\ifthenelse{\equal{\lhsL}{}} {\rhsL} {\lhsL} }} + }% END IF SINGLE + {multiple} + {% BEGIN IF MULTIPLE + % BEGIN LHS ANALYSIS + \renewcommand{\lhsIC}{} + \renewcommand{\lhsIL}{} + \renewcommand{\lhsIP}{} + \renewcommand{\lhsOC}{} + \setcounter{membranecomputing@membrane}{1} + \whiledo {\value{membranecomputing@membrane} < \numexpr#3+1\relax} + {% BEGIN FOR MEMBRANE + \StrFindGroup{#5}{\arabic{membranecomputing@membrane}}[\currentM] + \IfStrEq{\currentM}{{}} + {% BEGIN IF EMPTY GROUP + % EMPTY GROUP + }% END IF EMPTY GROUP + {% BEGIN ELSE EMPTY GROUP + \ifthenelse{\equal{\arabic{membranecomputing@membrane}}{1}} + {% BEGIN IF IN-MEMBRANE + \StrFindGroup{#5}{\arabic{membranecomputing@membrane},1}[\lhsIC] + \StrFindGroup{#5}{\arabic{membranecomputing@membrane},2}[\lhsIL] + \StrFindGroup{#5}{\arabic{membranecomputing@membrane},3}[\lhsIP] + \StrExpand[2]{\lhsIC}{\plhsIC} + \renewcommand{\lhsIC}{\expandafter\plhsIC\expandafter \,} + }% END IF IN-MEMBRANE + {% BEGIN ELSE IN-MEMBRANE + \ifthenelse{\equal{\arabic{membranecomputing@membrane}}{2}} + {% BEGIN IF OUT-MEMBRANE + \StrFindGroup{#5}{\arabic{membranecomputing@membrane},1}[\lhsOC] + }% END IF OUT-MEMBRANE + {% BEGIN ELSE OUT-MEMBRANE + \StrFindGroup{#5}{\arabic{membranecomputing@membrane}}[\currentMembrane] + \IfStrEqCase{\currentMembrane} + {% BEGIN CASES CURRENTMEMBRANE + {{.}}% + {% BEGIN IF ... + \StrExpand[2]{\lhsIC}{\plhsIC}% + \renewcommand{\lhsIC}{\ensuremath{\plhsIC \dots \,}}% + }% END IF ... + {{-}}% + {% BEGIN IF -- + \StrExpand[2]{\lhsIC}{\plhsIC}% + \renewcommand{\lhsIC}{\ensuremath{\plhsIC - \,}}% + }% END IF -- + {{;}} + {% BEGIN IF ; + \StrExpand[2]{\lhsIC}{\plhsIC}% + \renewcommand{\lhsIC}{\ensuremath{\plhsIC ; \,}}% + }% END IF ; + {\currentMembrane} + {% BEGIN IF OTHER + \StrFindGroup{#5}{\arabic{membranecomputing@membrane},1}[\lhsCC]% + \StrFindGroup{#5}{\arabic{membranecomputing@membrane},2}[\lhsCL]% + \StrFindGroup{#5}{\arabic{membranecomputing@membrane},3}[\lhsCP]% + \StrExpand[2]{\lhsIC}{\plhsIC}% + \StrExpand[2]{\lhsCC}{\plhsCC}% + \StrExpand[2]{\lhsCL}{\plhsCL}% + \StrExpand[2]{\lhsCP}{\plhsCP}% + \setcounter{membranecomputing@imembrane}{1} + \whiledo {\value{membranecomputing@imembrane} < 5} + {% BEGIN FOR IMEMBRANE + \stepcounter{membranecomputing@imembrane} + }% END FOR IMEMBRANE + \IfStrEq{\lhsCL}{{!}}% + {% BEGIN IF ! + \renewcommand{\lhsIC}{\ensuremath{\plhsIC \{ \IfStrEq{\plhsCC}{}{\quad}{\, \plhsCC \, } \}}} + }% END IF ! + {% BEGIN ELSE ! + \renewcommand{\polW}{\ensuremath{\IfStrEq{#1}{written}{^{\plhsCP}}{}}} + \renewcommand{\polP}{\ensuremath{\IfStrEq{#1}{plingua}{\plhsCP}{}}} + \renewcommand{\labelSub}{\ensuremath{\IfStrEq{#1}{written}{_{\plhsCL}}{'\plhsCL}}} + \StrExpand[2]{\polW}{\ppolW} + \StrExpand[2]{\polP}{\ppolP} + \StrExpand[2]{\labelSub}{\plabelSub} + \renewcommand{\lhsIC}{\ensuremath{\plhsIC \ppolP[ \IfStrEq{\plhsCC}{}{\quad}{\, \plhsCC \, } ]\ppolW\plabelSub \,}}% + \StrExpand[2]{\lhsIC}{\plhsIC}% + \renewcommand{\lhsIC}{\plhsIC}% + }% END ELSE ! + }% END IF OTHER + }% END CASES CURRENTMEMBRANE + }% END ELSE OUT-MEMBRANE + }% END ELSE IN-MEMBRANE + }% END ELSE EMPTY GROUP + \stepcounter{membranecomputing@membrane} + }% END FOR MEMBRANE + % END LHS ANALYSIS + % BEGIN RHS ANALYSIS + \renewcommand{\rhsIC}{} + \renewcommand{\rhsIL}{} + \renewcommand{\rhsIP}{} + \renewcommand{\rhsOC}{} + \setcounter{membranecomputing@membrane}{1} + \whiledo {\value{membranecomputing@membrane} < \numexpr#4+1\relax} + {% BEGIN FOR MEMBRANE + \StrFindGroup{#6}{\arabic{membranecomputing@membrane}}[\currentM] + \IfStrEq{\currentM}{{}} + {% BEGIN IF EMPTY GROUP + % EMPTY GROUP + }% END IF EMPTY GROUP + {% BEGIN ELSE EMPTY GROUP + \ifthenelse{\equal{\arabic{membranecomputing@membrane}}{1}} + {% BEGIN IF IN-MEMBRANE + \StrFindGroup{#6}{\arabic{membranecomputing@membrane},1}[\rhsIC] + \StrFindGroup{#6}{\arabic{membranecomputing@membrane},2}[\rhsIL] + \StrFindGroup{#6}{\arabic{membranecomputing@membrane},3}[\rhsIP] + \StrExpand[2]{\rhsIC}{\prhsIC} + \renewcommand{\rhsIC}{\expandafter\prhsIC\expandafter \,} + }% END IF IN-MEMBRANE + {% BEGIN ELSE IN-MEMBRANE + \ifthenelse{\equal{\arabic{membranecomputing@membrane}}{2}} + {% BEGIN IF OUT-MEMBRANE + \StrFindGroup{#6}{\arabic{membranecomputing@membrane},1}[\rhsOC] + % \ensuremath{} + }% END IF OUT-MEMBRANE + {% BEGIN ELSE OUT-MEMBRANE + \StrFindGroup{#6}{\arabic{membranecomputing@membrane}}[\currentMembrane] + \IfStrEqCase{\currentMembrane} + {% BEGIN CASES CURRENTMEMBRANE + {{.}}% + {% BEGIN IF ... + \StrExpand[2]{\rhsIC}{\prhsIC}% + \renewcommand{\rhsIC}{\ensuremath{\prhsIC \dots \,}}% + }% END IF ... + {{-}}% + {% BEGIN IF -- + \StrExpand[2]{\rhsIC}{\prhsIC}% + \renewcommand{\rhsIC}{\ensuremath{\prhsIC - \,}}% + }% END IF -- + {{;}} + {% BEGIN IF ; + \StrExpand[2]{\rhsIC}{\prhsIC}% + \renewcommand{\rhsIC}{\ensuremath{\prhsIC ; \,}}% + }% END IF ; + {\currentMembrane} + {% BEGIN IF OTHER + \StrFindGroup{#6}{\arabic{membranecomputing@membrane},1}[\rhsCC]% + \StrFindGroup{#6}{\arabic{membranecomputing@membrane},2}[\rhsCL]% + \StrFindGroup{#6}{\arabic{membranecomputing@membrane},3}[\rhsCP]% + \StrExpand[2]{\rhsIC}{\prhsIC}% + \StrExpand[2]{\rhsCC}{\prhsCC}% + \StrExpand[2]{\rhsCL}{\prhsCL}% + \StrExpand[2]{\rhsCP}{\prhsCP}% + \setcounter{membranecomputing@imembrane}{1} + \whiledo {\value{membranecomputing@imembrane} < 5} + {% BEGIN FOR IMEMBRANE + \stepcounter{membranecomputing@imembrane} + }% END FOR IMEMBRANE + \IfStrEq{\rhsCL}{{!}}% + {% BEGIN IF ! + \renewcommand{\rhsIC}{\ensuremath{\prhsIC \{ \IfStrEq{\prhsCC}{}{\quad}{\, \prhsCC \, } \}}}% + }% END IF ! + {% BEGIN ELSE ! + \renewcommand{\polW}{\ensuremath{\IfStrEq{#1}{written}{^{\prhsCP}}{}}} + \renewcommand{\polP}{\ensuremath{\IfStrEq{#1}{plingua}{\prhsCP}{}}} + \renewcommand{\labelSub}{\ensuremath{\IfStrEq{#1}{written}{_{\prhsCL}}{'\prhsCL}}} + \StrExpand[2]{\polW}{\ppolW} + \StrExpand[2]{\polP}{\ppolP} + \StrExpand[2]{\labelSub}{\plabelSub} + \renewcommand{\rhsIC}{\ensuremath{\prhsIC \ppolP[ \IfStrEq{\prhsCC}{}{\quad}{\, \prhsCC \, } ]\ppolW\plabelSub \,}}% + \StrExpand[2]{\rhsIC}{\prhsIC}% + \renewcommand{\rhsIC}{\prhsIC}% + }% END ELSE ! + }% END IF OTHER + }% END CASES CURRENTMEMBRANE + }% END ELSE OUT-MEMBRANE + }% END ELSE IN-MEMBRANE + }% END ELSE EMPTY GROUP + \stepcounter{membranecomputing@membrane} + }% END FOR MEMBRANE + % END RHS ANALYSIS + \StrFindGroup{#5}{1}[\lhsM] + \StrFindGroup{#6}{1}[\rhsM] + \renewcommand{\polWL}{\ensuremath{\IfStrEq{#1}{written}{^{\lhsIP}}{}}} + \renewcommand{\polPL}{\ensuremath{\IfStrEq{#1}{plingua}{\lhsIP}{}}} + \renewcommand{\labelSubL}{\ensuremath{\IfStrEq{#1}{written}{_{\lhsIL}}{'\lhsIL}}} + \renewcommand{\polWR}{\ensuremath{\IfStrEq{#1}{written}{^{\rhsIP}}{}}} + \renewcommand{\polPR}{\ensuremath{\IfStrEq{#1}{plingua}{\rhsIP}{}}} + \renewcommand{\labelSubR}{\ensuremath{\IfStrEq{#1}{written}{_{\rhsIL}}{'\rhsIL}}} + \formatRule{#1}{#2}{\ifthenelse{\equal{\lhsOC}{}}{}{\lhsOC \,} \IfStrEq{\lhsM}{{}}{}{\polPL\left[} \ifthenelse{\equal{\protect\lhsIC}{}}{\quad}{ \, \lhsIC } \IfStrEq{\lhsM}{{}}{}{\right]\polWL\labelSubL}}{\ifthenelse{\equal{\rhsOC}{}}{}{\rhsOC \,} + \IfStrEq{\rhsM}{{}}{}{\polPR\left[} \ifthenelse{\equal{\protect\rhsIC}{}}{\quad}{ \, \rhsIC } \IfStrEq{\rhsM}{{}}{}{\right]\polWR\labelSubR}} + % \ensuremath{\ifthenelse{\equal{\lhsOC}{}}{}{\lhsOC \,} \IfStrEq{\lhsM}{{}}{}{\left[} \ifthenelse{\equal{\protect\lhsIC}{}}{\quad}{ \, \lhsIC } \IfStrEq{\lhsM}{{}}{}{\right]^{\lhsIP}_{\lhsIL}} \rightarrow \ifthenelse{\equal{\rhsOC}{}}{}{\rhsOC \,} + % \IfStrEq{\rhsM}{{}}{}{\left[} \ifthenelse{\equal{\protect\rhsIC}{}}{\quad}{ \, \rhsIC } \IfStrEq{\rhsM}{{}}{}{\right]^{\rhsIP}_{\rhsIL}}} + }% END IF MULTIPLE + {paren} + {% BEGIN IF PAREN + \ifthenelse{\equal{#6}{}} + {% BEGIN IF ONE SIDE + \StrFindGroup{#5}{1}[\lhsC] + \StrFindGroup{#5}{2}[\lhsL] + \ensuremath{\left( \lhsC, \lhsL \right)} + }% END IF ONE SIDE + {% BEGIN ELSE ONE SIDE + \StrFindGroup{#5}{1}[\lhsC] + \StrFindGroup{#6}{1}[\rhsC] + \StrFindGroup{#5}{2}[\lhsL] + \StrFindGroup{#6}{2}[\rhsL] + \formatRule{#1}{#2}{\left( \lhsL, \lhsC}{\rhsC, \rhsL \right)} + % \ensuremath{\left( \lhsL, \lhsC / \rhsC, \rhsL \right)} + }% END ELSE ONE SIDE + }% END IF PAREN + {spike} + {% BEGIN IF SPIKE + \renewcommand{\lhsE}{} + \renewcommand{\lhsS}{} + \renewcommand{\rhsS}{} + \renewcommand{\rhsD}{} + \StrFindGroup{#5}{1}[\lhsE] + \StrFindGroup{#5}{2}[\lhsS] + \StrFindGroup{#6}{1}[\rhsS] + \StrFindGroup{#6}{2}[\rhsD] + \ensuremath{\ifthenelse{\equal{\lhsE}{{}}}{}{\lhsE /} \lhsS \rightarrow \rhsS \ifthenelse{\equal{\rhsD}{}}{}{; \rhsD}} + }% END IF SPIKE + }% END CASES TYPE + [\PackageError{rule}{Undefined option to rule: #2}] +}% END COMMAND RULE + +% Templates for P systems + +\newcommand{\psystemAM}[1][nonrecognizer]{\psystem[#1]{cell}{activemembranes}{}{}} +\newcommand{\rpsystemAM}{\psystemAM[recognizer]} +\newcommand{\psystemSA}[1][nonrecognizer]{\psystem[#1]{tissue}{symportantiport}{}{}} +\newcommand{\rpsystemSA}{\psystemSA[recognizer]} +\newcommand{\SNpsystem}[1][nonrecognizer]{\psystem[#1]{tissue}{spiking}{}{}} +\newcommand{\rSNpsystem}{\SNpsystem[recognizer]} +\newcommand{\kpsystem}[1][nonrecognizer]{\psystem[#1]{cell}{kernel}{}{}} +\newcommand{\rkpsystem}{\kpsystem[recognizer]} +\newcommand{\pcolony}[1][nonrecognizer]{\psystem[#1]{tissue}{colony}{}{}} +\newcommand{\rpcolony}{\pcolony[recognizer]} + +% Rule examples and templates + +\newcommand{\rewriting}[2]{\wrule[rewriting]{}{}{#1}{#2}} +\newcommand{\rewritingT}{\rewriting{u}{v}} + +\newcommand{\evolution}[4]{\wrule[single]{}{}{{#1}{#3}{#4}}{{#2}}} +\newcommand{\evolutionT}{\evolution{a}{b}{h}{\alpha}} + +\newcommand{\evolutionP}[4]{\prule[single]{}{}{{#1}{#3}{#4}}{{#2}}} +\newcommand{\evolutionPT}{\evolutionP{a}{b}{h}{\alpha}} + +\newcommand{\pevolution}[3]{\wrule[single]{}{}{{#1}{#3}}{{#2}}} +\newcommand{\pevolutionT}{\pevolution{a}{b}{h}} + +\newcommand{\pevolutionP}[3]{\evolutionP{#1}{#2}{#3}{}} +\newcommand{\pevolutionPT}{\pevolutionP{a}{b}{h}} + +\newcommand{\antiport}[4]{\wrule[paren]{}{}{{#1}{#2}}{{#3}{#4}}} +\newcommand{\antiportT}{\antiport{u}{i}{v}{j}} +\newcommand{\symportT}{\antiport{u}{i}{\lambda}{j}} + +\newcommand{\antiportP}[4]{\prule[paren]{}{}{{#1}{#2}}{{#3}{#4}}} +\newcommand{\antiportPT}{\antiportP{u}{i}{v}{j}} +\newcommand{\symportPT}{\antiportP{u}{i}{\lambda}{j}} + +\newcommand{\sendin}[5]{\wrule{2}{1}{{{}{#3}{#4}}{{#1}}}{{{#2}{#3}{#5}}}} +\newcommand{\sendinT}{\sendin{a}{b}{h}{\alpha_{1}}{\alpha_{2}}} + +\newcommand{\sendinP}[5]{\prule{2}{1}{{{}{#3}{#4}}{{#1}}}{{{#2}{#3}{#5}}}} +\newcommand{\sendinPT}{\sendinP{a}{b}{h}{\alpha_{1}}{\alpha_{2}}} + +\newcommand{\psendin}[3]{\sendin{#1}{#2}{#3}{}{}} +\newcommand{\psendinT}{\psendin{a}{b}{h}} + +\newcommand{\psendinP}[3]{\sendinP{#1}{#2}{#3}{}{}} +\newcommand{\psendinPT}{\psendinP{a}{b}{h}} + +\newcommand{\sendout}[5]{\wrule{1}{2}{{{#1}{#3}{#4}}}{{{}{#3}{#5}}{{#2}}}} +\newcommand{\sendoutT}{\sendout{a}{b}{h}{\alpha_{1}}{\alpha_{2}}} + +\newcommand{\sendoutP}[5]{\prule{1}{2}{{{#1}{#3}{#4}}}{{{}{#3}{#5}}{{#2}}}} +\newcommand{\sendoutPT}{\sendout{a}{b}{h}{\alpha_{1}}{\alpha_{2}}} + +\newcommand{\psendout}[3]{\sendout{#1}{#2}{#3}{}{}} +\newcommand{\psendoutT}{\psendout{a}{b}{h}} + +\newcommand{\psendoutP}[3]{\sendoutP{#1}{#2}{#3}{}{}} +\newcommand{\psendoutPT}{\psendoutP{a}{b}{h}} + +\newcommand{\dissolution}[4]{\wrule{3}{2}{{}{}{{#1}{#3}{#4}}}{{}{{#2}}}} +\newcommand{\dissolutionT}{\dissolution{a}{b}{h}{\alpha}} + +\newcommand{\dissolutionP}[4]{\prule{3}{2}{{}{}{{#1}{#3}{#4}}}{{}{{#2}}}} +\newcommand{\dissolutionPT}{\dissolutionP{a}{b}{h}{\alpha}} + +\newcommand{\pdissolution}[3]{\dissolution{#1}{#2}{#3}{}} +\newcommand{\pdissolutionT}{\pdissolution{a}{b}{h}} + +\newcommand{\pdissolutionP}[3]{\dissolutionP{#1}{#2}{#3}{}} +\newcommand{\pdissolutionPT}{\pdissolutionP{a}{b}{h}} + +\newcommand{\division}[7]{\wrule{1}{4}{{{#1}{#4}{#5}}{}}{{}{}{{#2}{#4}{#6}}{{#3}{#4}{#7}}}} +\newcommand{\divisionT}{\division{a}{b}{c}{h}{\alpha}{\alpha_{1}}{\alpha_{2}}} + +\newcommand{\divisionP}[7]{\prule{1}{4}{{{#1}{#4}{#5}}{}}{{}{}{{#2}{#4}{#6}}{{#3}{#4}{#7}}}} +\newcommand{\divisionPT}{\divisionP{a}{b}{c}{h}{\alpha}{\alpha_{1}}{\alpha_{2}}} + +\newcommand{\pdivision}[4]{\division{#1}{#2}{#3}{#4}{}{}{}} +\newcommand{\pdivisionT}{\pdivision{a}{b}{c}{h}} + +\newcommand{\pdivisionP}[4]{\divisionP{#1}{#2}{}{#3}{}{#4}{}} +\newcommand{\pdivisionPT}{\pdivisionP{a}{h}{b}{c}} + +\newcommand{\separation}[5]{\wrule{1}{4}{{{#1}{#2}{#3}}{}}{{}{}{{\wa_{0}}{#2}{#4}}{{\wa_{1}}{#2}{#5}}}} +\newcommand{\separationT}{\separation{a}{h}{\alpha}{\alpha_{1}}{\alpha_{2}}} + +\newcommand{\separationP}[5]{\prule{1}{4}{{{#1}{#2}{#3}}{}}{{}{}{{\wa_{0}}{#2}{#4}}{{\wa_{1}}{#2}{#5}}}} +\newcommand{\separationPT}{\separationP{a}{h}{\alpha}{\alpha_{1}}{\alpha_{2}}} + +\newcommand{\pseparation}[2]{\separation{#1}{#2}{}{}{}} +\newcommand{\pseparationT}{\pseparation{a}{h}} + +\newcommand{\pseparationP}[2]{\separationP{#1}{#2}{}{}{}} +\newcommand{\pseparationPT}{\pseparationP{a}{h}} + +\newcommand{\creation}[8]{\wrule{1}{3}{{{#1}{#4}{#6}}}{{{#2}{#4}{#7}}{}{{#3}{#5}{#8}}}} +\newcommand{\creationT}{\creation{a}{b}{c}{h}{h_{1}}{\alpha}{\alpha_{1}}{\alpha_{2}}} + +\newcommand{\creationP}[8]{\prule{1}{3}{{{#1}{#4}{#6}}}{{{#2}{#4}{#7}}{}{{#3}{#5}{#8}}}} +\newcommand{\creationPT}{\creationP{a}{b}{c}{h}{h_{1}}{\alpha}{\alpha_{1}}{\alpha_{2}}} + +\newcommand{\pcreation}[5]{\creation{#1}{#2}{#3}{#4}{#5}{}{}{}} +\newcommand{\pcreationT}{\pcreation{a}{b}{c}{h}{h_{1}}} + +\newcommand{\pcreationP}[5]{\creationP{#1}{#2}{#3}{#4}{#5}{}{}{}} +\newcommand{\pcreationPT}{\pcreationP{a}{b}{c}{h}{h_{1}}} + +\newcommand{\spiking}[4]{\wrule[spike]{}{}{{#1}{#2}}{{#3}{#4}}} +\newcommand{\spikingT}{\spiking{E}{a^{n}}{a}{d}} +\newcommand{\forgettingT}{\spiking{}{a^{n}}{\lambda}{}} + +\newcommand{\spikingP}[4]{\prule[spike]{}{}{{#1}{#2}}{{#3}{#4}}} +\newcommand{\spikingPT}{\spikingP{E}{a^{n}}{a}{d}} +\newcommand{\forgettingPT}{\spikingP{}{a^{n}}{\lambda}{}} + +\newcommand{\krewriting}[3]{\wrule{2}{3}{{}{{#1}}}{{}{{#2}}{{#3}{!}}}} +\newcommand{\krewritingT}{\krewriting{x}{y}{g}} + +\newcommand{\krewritingP}[3]{\prule{2}{3}{{}{{#1}}}{{}{{#2}}{{#3}{!}}}} +\newcommand{\krewritingPT}{\krewritingP{x}{y}{g}} + +\newcommand{\linkcreation}[5]{\wrule{5}{6}{{}{}{{#1}{#3}}{;}{{}{#4}}}{{}{}{{#2}{#3}}{-}{{}{#4}}{{#5}{!}}}} +\newcommand{\linkcreationT}{\linkcreation{x}{y}{t_{l_{i}}}{t_{l_{j}}}{g}} + +\newcommand{\linkcreationP}[5]{\prule{5}{6}{{}{}{{#1}{#3}}{;}{{}{#4}}}{{}{}{{#2}{#3}}{-}{{}{#4}}{{#5}{!}}}} +\newcommand{\linkcreationPT}{\linkcreationP{x}{y}{t_{l_{i}}}{t_{l_{j}}}{g}} + +\newcommand{\linkdestruction}[5]{\wrule{5}{6}{{}{}{{#1}{#3}}{-}{{}{#4}}}{{}{}{{#2}{#3}}{;}{{}{#4}}{{#5}{!}}}} +\newcommand{\linkdestructionT}{\linkdestruction{x}{y}{t_{l_{i}}}{t_{l_{j}}}{g}} + +\newcommand{\linkdestructionP}[5]{\prule{5}{6}{{}{}{{#1}{#3}}{-}{{}{#4}}}{{}{}{{#2}{#3}}{;}{{}{#4}}{{#5}{!}}}} +\newcommand{\linkdestructionPT}{\linkdestructionP{x}{y}{t_{l_{i}}}{t_{l_{j}}}{g}} + +% Families of P systems + +\newcommand{\Pfamily}[4]{\ensuremath{\mathcal{#1}^{#2}_{#3} \IfStrEq{#4}{}{}{( #4 )}}} +\newcommand{\AM}[2][]{\Pfamily{AM}{#1}{}{#2}} +\newcommand{\AMO}[1]{\Pfamily{AM}{0}{}{#1}} +\newcommand{\TC}[2][]{\Pfamily{T#1C}{}{}{#2}} +\newcommand{\TDC}[1]{\TC[D]{#1}} +\newcommand{\TSC}[1]{\TC[S]{#1}} +\newcommand{\CC}[2][]{\Pfamily{C#1C}{}{}{#2}} +\newcommand{\CDC}[1]{\CC[D]{#1}} +\newcommand{\CSC}[1]{\CC[S]{#1}} +\newcommand{\TEC}[2][]{\TC[#1E]{#2}} +\newcommand{\TDEC}[1]{\TEC[D]{#1}} +\newcommand{\TSEC}[1]{\TEC[S]{#1}} +\newcommand{\CEC}[2][]{\CC[#1E]{#2}} +\newcommand{\CDEC}[1]{\CEC[D]{#1}} +\newcommand{\CSEC}[1]{\CEC[S]{#1}} + +% Terms of computability theory + +\newcommand{\compSet}[1]{\ensuremath{#1}} +\newcommand{\REG}{\compSet{REG}} +\newcommand{\LIN}{\compSet{LIN}} +\newcommand{\CF}{\compSet{CF}} +\newcommand{\CS}{\compSet{CS}} +\newcommand{\RE}{\compSet{RE}} + +% Terms of computational complexity theory + +\newcommand{\complClass}[3]{\ensuremath{\mathbf{#1MC}^{#2}_{#3}}} +\newcommand{\PMC}[2][]{\complClass{P}{#1}{#2}} +\newcommand{\PSPACEMC}[2][]{\complClass{PSPACE}{#1}{#2}} +\newcommand{\EXPMC}[2][]{\complClass{EXP}{#1}{#2}} +\newcommand{\EXPSPACEMC}[2][]{\complClass{EXPPSPACE}{#1}{#2}} + +\fullexpandarg +\noexploregroups + +\endinput + +v0.1 23/07/2020 + - Created package + - Created some examples and templates
\ No newline at end of file diff --git a/macros/latex/contrib/membranecomputing/membranecomputing.tex b/macros/latex/contrib/membranecomputing/membranecomputing.tex new file mode 100644 index 0000000000..a8c9207207 --- /dev/null +++ b/macros/latex/contrib/membranecomputing/membranecomputing.tex @@ -0,0 +1,486 @@ +\documentclass{article} + +\usepackage[utf8]{inputenc} + +\usepackage{membranecomputing} +\usepackage{hyperref} +\usepackage{enumitem} +\usepackage{amssymb} +\usepackage{longtable} + +\title{Package \texttt{membranecomputing} (v0.1)} +\author{David Orellana-Martín \\ \texttt{\href{mailto:dorellana@us.es}{dorellana@us.es}}} +\begin{document} + +\maketitle + +\tableofcontents + +\section{Introduction} +\label{sec:introduction} + +Membrane computing is a framework where different models of +computations, called membrane systems or P systems arise from. The +notation of these models is very variate since the number of +researchers in the area is very high, and also their background is +different, and therefore the notation can slightly change. The idea of +this package is to cover all the possible variants in the area and +their respective rules. Concerning the rules, the objective is +twofold: On the one hand, to use commands to transcript a rule in a +paper format; On the other hand, since P-Lingua is the \textit{de + facto} standard language for simulating P systems, there is a +possibility to print the rules in the P-Lingua language, ready to be +copied and pasted into a \texttt{.pli} file. + +\section{Package options} +\label{sec:package-options} + +The \texttt{membranecomputing} package offers the option +\texttt{blackboard}. The differences of this option can be found in +Subsection~\ref{sec:font-option}. + +\subsection{Font option} +\label{sec:font-option} + +Notation of P systems can change depending on the model. But even with +the same model, some differences can be found between different +papers. For instance, while some researchers use the symbol $\Gamma$ +to denote the working alphabet, other use the letter $O$. Other +example is the use of the letters $\mathcal{M}_{i}$ or $w_{i}$ for +describing the initial multisets of the regions. For this purpose, +this option has been implemented. + +\begin{itemize} +\item \texttt{traditional} (\textit{Default}) This typesets the + symbols like + $\Gamma, \Sigma, \mathcal{M}_{i}, \mathcal{R}_{i}, + \rho_{i}$~\footnote{For SNP systems, the singleton $\{a\}$, is still + called $O$ in this mode.}. +\item \texttt{blackboard} This typesets the symbols like + $O, E, w_{i}, R_{i}, p_{i}$. +\end{itemize} + +The rest of the symbols are defined without taking into account this option. + +\section{Using the package} +\label{sec:using-package} + +In this section I will try to explain all the different uses of this +package, from basic use to creation of new templates. + +\subsection{Basic notations} +\label{sec:basic-notations} + +This is a list of some notations that can be used for defining initial +multisets, sets of rules, and so on. + +\vspace{1mm} + +$ +\begin{array}{lll} + \mbox{Working alphabet} & \verb=\wa= & \wa \\ + \mbox{Input alphabet} & \verb=\ia= & \ia \\ + \mbox{Labels set} & \verb=\ls= & \ls \\ + \mbox{Membrane structure} & \verb=\ms= & \ms \\ + \mbox{Initial multiset} & \verb=\im{i}= & \im{i} \\ + \mbox{Rule set} & \verb=\rs{i}= & \rs{i} \\ + \mbox{Probabilities set} & \verb=\ps{i}= & \ps{i} \\ + \mbox{vE} & \verb=\vE= & \vE \\ + \mbox{Neuron} & \verb=\neuron{i}= & \neuron{i} \\ + \mbox{Compartment} & \verb=\compartment{i}= & \compartment{i} \\ + \mbox{Agent} & \verb=\agent{i}= & \agent{i} \\ + \mbox{Degree} & \verb=\degree= & \degree \\ + \mbox{Synapses} & \verb=\syn= & \syn \\ + \mbox{Input region} & \verb=\iin= & \iin \\ + \mbox{Output region} & \verb=\iout= & \iout \\ + \mbox{Object yes} & \verb=\yes= & \yes \\ + \mbox{Object no} & \verb=\no= & \no \\ +\end{array} +$ + +\subsection{Languages and computability theory} +\label{sec:lang-comp-theory} + +$ +\begin{array}{lll} + \mbox{Regular language} & \verb=\REG= & \REG \\ + \mbox{Linear language} & \verb=\LIN= & \LIN \\ + \mbox{Context-free language} & \verb=\CF= & \CF \\ + \mbox{Context-sensitive language} & \verb=\CS= & \CS \\ + \mbox{Recursively enumerable language} & \verb=\RE= & \RE \\ +\end{array} +$ + +To define a new set of languages, it is enough to make a new command +as follows: + +\begin{verbatim} +\newcommand{\L}{\compSet{L}} +\end{verbatim} + +This results in: $\compSet{L}$. + +\subsection{Families of membrane systems} +\label{sec:famil-membr-syst} + +Since the number of ``ingredients'' of the different variants of P +systems is sometimes high, then some notations can be used to short +them whenever they must be used. For instance, polarizationless P +systems with active membranes when dissolution rules and division +rules only for elementary membranes are allowed is usually denoted as +$\AMO{-d, +ne}$. To denote this, it is enough to write +\verb=\AM0{d, +ne}=. In this package, some examples of different +families of P systems are defined. + +$ +\begin{array}{lll} + \mbox{Ps with am} & \verb=\AM[\alpha]{\beta}= & \AM[\alpha]{\beta} \\ + \mbox{Polarizationless Ps with am} & \verb=\AMO{\alpha}= & \AMO{\alpha} \\ + \mbox{Tissue Ps with s/a rules} & \verb=\TC[\alpha]{\beta}= & \TC[\alpha]{\beta} \\ + \mbox{Tissue Ps with s/a and division rules} & \verb=\TDC{\alpha}= & \TDC{\alpha} \\ + \mbox{Tissue Ps with s/a and separation rules} & \verb=\TSC{\alpha}= & \TSC{\alpha} \\ + \mbox{Ps with s/a rules} & \verb=\CC[\alpha]{\beta}= & \CC[\alpha]{\beta} \\ + \mbox{Ps with s/a and division rules} & \verb=\CDC{\alpha}= & \CDC{\alpha} \\ + \mbox{Ps with s/a and separation rules} & \verb=\CSC{\alpha}= & \CSC{\alpha} \\ + \mbox{Tissue Ps with evol. comm. rules} & \verb=\TEC[\alpha]{\beta}= & \TEC[\alpha]{\beta} \\ + \mbox{Tissue Ps with evol. comm. and division rules} & \verb=\TDEC{\alpha}= & \TDEC{\alpha} \\ + \mbox{Tissue Ps with evol. comm. and separation rules} & \verb=\TSEC{\alpha}= & \TSEC{\alpha} \\ + \mbox{Ps with evol. comm. rules} & \verb=\CEC[\alpha]{\beta}= & \CEC[\alpha]{\beta} \\ + \mbox{Ps with evol. comm. and division rules} & \verb=\CDEC{\alpha}= & \CDEC{\alpha} \\ + \mbox{Ps with evol. comm. and separation rules} & \verb=\CSEC{\alpha}= & \CSEC{\alpha} +\end{array} +$ + +To define a new notation for a family of membrane systems, it is +enough to make a new command as follows: + +\begin{verbatim} +\newcommand{\MS}[3]{\Pfamily{MS}{#1}{#2}{#3}} +\end{verbatim} + +This results in: $\Pfamily{MS}{\#2}{\#3}{\#4}$. + +\subsection{Computational complexity theory} +\label{sec:comp-compl-theory} + +It is usual to define different complexity classes in the framework +of membrane computing. In this sense, it would be interesting to +automate the definition of these classes to avoid using all \LaTeX +commands each time we want to use them. + +$ +\begin{array}{lll} + \mbox{} & \verb=\PMC[\alpha]{\beta}= & \PMC[\alpha]{\beta} \\ + \mbox{} & \verb=\PSPACEMC[\alpha]{\beta}= & \PSPACEMC[\alpha]{\beta} \\ + \mbox{} & \verb=\EXPMC[\alpha]{\beta}= & \EXPMC[\alpha]{\beta} \\ + \mbox{} & \verb=\EXPSPACEMC[\alpha]{\beta}= & \EXPSPACEMC[\alpha]{\beta} \\ +\end{array} +$ + +To define a new notation for a complexity class in membrane systems, it is +enough to make a new command as follows: + +\begin{verbatim} +\newcommand{\C}[3]{\complClass{C}{#1}{#2}} +\end{verbatim} + +This results in: $\complClass{C}{\#1}{\#2}$~\footnote{CMC does not + stand for Conference on Membrane Computing here.}. + +\subsection{P systems} +\label{sec:p-systems} + +One of the two main contributions of this package is to make easier to +name a P system. Usually, when we have to define a new membrane +system, we have to write something like + +\begin{verbatim} +\Pi = (\Gamma, \mu, H, \mathcal{M}_1, \mathcal{M}_{2}, \mathcal{R}, i_{out}) +\end{verbatim} + +For making this task easier, the command \verb=psystem= has been +defined. Basically, it takes 5 arguments (first is optional) and can +be used as follows: \verb=\psystem[#1]{#2}{#3}{#4}{#5}=, where + +\begin{enumerate}[label=\texttt{\#\arabic*}] +\item $\in \{\mathtt{recognizer}, \mathtt{nonrecognizer}\}$: adds an + input alphabet and an input region. +\item $\in \{\mathtt{cell}, \mathtt{tissue}\}$: adds a membrane + structure in the first case. +\item + $\in \{\mathtt{transition}, \mathtt{activemembranes}, + \mathtt{symportantiport}, \mathtt{spiking}, \mathtt{kernel}, + \mathtt{colony}\}$: changes some of the parameters of the P system. +\item is a subscript for the symbol $\Pi$. +\item $> 1$ is the degree of the system. +\end{enumerate} + +For instance, the command +\begin{verbatim} +\psystem[recognizer]{cell}{activemembranes}{1}{10} +\end{verbatim} +would lead to the following: + +\begin{center} + \psystem[recognizer]{cell}{activemembranes}{1}{10} +\end{center} + +Some templates have been prepared for most of the usual variants of P +systems: + +$ +\begin{array}{ll} + \verb=\psystemAM= & \psystemAM \\ + \verb=\rpsystemAM= & \rpsystemAM \\ + \verb=\psystemSA= & \psystemSA \\ + \verb=\rpsystemSA= & \rpsystemSA \\ + \verb=\SNpsystem= & \SNpsystem \\ + \verb=\rSNpsystem= & \rSNpsystem \\ + \verb=\kpsystem= & \kpsystem \\ + \verb=\rkpsystem= & \rkpsystem \\ + \verb=\pcolony= & \pcolony \\ + \verb=\rpcolony= & \rpcolony \\ +\end{array} +$ + +All commands preceded by a \verb=r= are the recognizer version of +their r-less counterpart. + +\subsection{Rules} +\label{sec:rules} + +The (current) big work of this paper is to normalise the notation of +the rules of P systems. Several differences can be found in the +literature, most of them about spacing, position of elements, and so +on. The idea is to unify these notations in one big element: the +\verb=\mcrule= command. This command tries to cover all types of rules +in the membrane computing framework, including esoteric rules that +could arise. The idea is to catch some basic elements and parse them +in order to obtain the whole rule. As some types of P systems use +different notations, as arrows, separators and so on, different cases +have being contemplated. The definition of this command is +\verb=\mcrule[#1]{#2}{#3}{#4}{#5}{#6}=, where: + +\begin{enumerate}[label=\texttt{\#\arabic*}] +\item $\in \{\mathtt{written} (\mathit{Default}), \mathtt{plingua}\}$: the first one + makes it look as the usual scientific notation while the second one + transforms the rule into P-Lingua notation. +\item It can be one of the following parameters: + + $ + \begin{array}{lll} + \mathtt{rewriting} & \mbox{Classical rewriting rules} & \rewritingT \\ + \mathtt{single} & \mbox{Rules with a single pair of brackets} & \pevolutionT \\ + \mathtt{multiple} & \mbox{Rules with different brackets in the LHS and the RHS} & \psendoutT \\ + \mathtt{paren} & \mbox{Rules delimited by parentheses} & \antiportT \\ + \mathtt{spike} & \mbox{Spiking rules} & \spikingT + \end{array} +$ +\item $> 1$: Number of regions in the LHS (the main region and the outside regions are counted as one) +\item $> 1$: Number of regions in the RHS (the main region and the outside regions are counted as one) +\item explained below +\item explained below +\end{enumerate} + +The \verb=\mcrule= command is a tool capable of representing a wide +variety of types of rule. The idea is to represent all the rules in a +standardised way and well-spaced. An example with each type of rule is +given: + +\begin{itemize} +\item $\mathtt{rewriting}$: \verb=\mcrule{rewriting}{}{}{u}{v}= will + produce $\mcrule{rewriting}{}{}{u}{v}$. +\item $\mathtt{single}$: + \verb=\mcrule{single}{}{}{{a}{h}{+}}{{c_{2}\alpha}}= will produce + $\mcrule{single}{}{}{{a}{h}{+}}{c_{2}\alpha}$. +\item $\mathtt{multiple}$:\newline + \verb=\mcrule{multiple}{4}{4}{{{a}{3}{+}}{{b}}{{e_{1}}{4}}{;}}=\newline + \verb={{}{{a}}{-}{{o}{!}}}= will produce\newline + $\mcrule{multiple}{4}{4}{{{a}{3}{+}}{{b}}{{e_{1}}{4}}{;}}{{}{{a}}{-}{{o}{!}}}$. I + will explain in detail what means each thing: + \begin{itemize} + \item \verb={4}{4}=: In the left-hand side of the rule, 4 + ``regions'' will be analysed (in this case, membrane $3$, its + parent membrane, membrane $4$ and a special symbol); In the + right-hand side of the rule, 4 ``regions'' will be analysed (in + this case, the empty ``main'' membrane, its parent membrane, a + special symbol and a special region)~\footnote{It is a very + strange rule, but it will be useful to explain some special + cases to use in your own rules.}. + \item \verb={{{a}{3}{+}}{{b}}{{e_{1}}{4}}{;}}=: It is divided into + four parts: + \begin{itemize} + \item \verb={{a}{3}{+}}=: The ``main'' membrane of the rule has + label $3$ and polarisation $+$, and its contents is an object + $a$. + \item \verb={{b}}=: The outer content of the ``main'' membrane is + an object $b$. + \item \verb={{e_{1}}{4}}=: It has a inner membrane with label $4$ + and its contents is an object $e_{1}$. + \item \verb={;}=: It writes down a $;$ symbol~\footnote{Useful for + creation/deletion rules in kP systems.}. + \end{itemize} + \item \verb={{}{{a}}{-}{{o}{!}}}=: It is divided into four + parts: + \begin{itemize} + \item \verb={}=: The ``main'' membrane of the rule is not + specified, so it is omitted~\footnote{Useful for dissolution + rules.}. + \item \verb={{a}}=: The outer content of the ``main'' membrane is + an object $a$. + \item \verb=-= It writes down a $-$ symbol~\footnote{Also useful + for creation/deletion rules in kP systems.}. + \item \verb={{o}{!}}=: The symbol $!$ in the label is a reserved + character to write down a guard $\{ o \}$~\footnote{Also used in + kP systems.}. + \end{itemize} + \end{itemize} +\item $\mathtt{paren}$: \verb=\mcrule{paren}{}{}{{ab}{3}}{{c}{2}}= + will produce $\mcrule{paren}{}{}{{ab}{3}}{{c}{2}}$. +\item $\mathtt{spike}$: + \verb=\mcrule{spike}{}{}{{a^{3}}{a^{2}}}{{a}{1}}= will produce + $\mcrule{spike}{}{}{{a^{3}}{a^{2}}}{{a}{1}}$. +\end{itemize} + +Using $\mathtt{plingua}$ instead of +$\mathtt{written}$ as the optional parameter, it will write the rule +in the P-Lingua syntax. Therefore, the $\mathtt{multiple}$ rule +previously used in this section would render as\newline +$\mcrule[plingua]{multiple}{4}{4}{{{a}{3}{+}}{{b}}{{e_{1}}{4}}{;}}{{}{{a}}{-}{{o}{!}}}$. + +With this, anyone can create almost any kind of rule that one could +think~\footnote{Do you have any idea about other kind of rule? Please + write me so I can think in a way to implement it.}. However, for the +sake of simplicity, I have defined some commands for the basic types +of rules from the bibliography. + +{\footnotesize +\begin{longtable}{ll} + \verb=\rewriting{u}{v}= & $\rewriting{u}{v}$ \\ + \verb=\rewritingT= & $\rewritingT$ \\ + \verb=\evolution{a}{b}{h}{\alpha}= & $\evolution{a}{b}{h}{\alpha}$ \\ + \verb=\evolutionT= & $\evolutionT$ \\ + \verb=\evolutionP{a}{b}{h}{\alpha}= & $\evolutionP{a}{b}{h}{\alpha}$ \\ + \verb=\evolutionPT= & $\evolutionPT$ \\ + \verb=\pevolution{a}{b}{h}= & $\pevolution{a}{b}{h}$ \\ + \verb=\pevolutionT= & $\pevolutionT$ \\ + \verb=\pevolutionP{a}{b}{h}= & $\pevolutionP{a}{b}{h}$ \\ + \verb=\pevolutionPT= & $\pevolutionPT$ \\ + \verb=\antiport{u}{i}{v}{j}= & $\antiport{u}{i}{v}{j}$ \\ + \verb=\antiportT= & $\antiportT$ \\ + \verb=\symportT= & $\symportT$ \\ + \verb=\antiportP{u}{i}{v}{j}= & $\antiportP{u}{i}{v}{j}$ \\ + \verb=\antiportPT= & $\antiportPT$ \\ + \verb=\symportPT= & $\symportPT$ \\ + \verb=\sendin{a}{b}{h}{\alpha_{1}}{\alpha_{2}}= & $\sendin{a}{b}{h}{\alpha_{1}}{\alpha_{2}}$ \\ + \verb=\sendinT= & $\sendinT$ \\ + \verb=\sendinP{a}{b}{h}{\alpha_{1}}{\alpha_{2}}= & $\sendinP{a}{b}{h}{\alpha_{1}}{\alpha_{2}}$ \\ + \verb=\sendinPT= & $\sendinPT$ \\ + \verb=\psendin{a}{b}{h}= & $\psendin{a}{b}{h}$ \\ + \verb=\psendinT= & $\psendinT$ \\ + \verb=\psendinP{a}{b}{h}= & $\psendinP{a}{b}{h}$ \\ + \verb=\psendinPT= & $\psendinPT$ \\ + \verb=\sendout{a}{b}{h}{\alpha_{1}}{\alpha_{2}}= & $\sendout{a}{b}{h}{\alpha_{1}}{\alpha_{2}}$ \\ + \verb=\sendoutT= & $\sendoutT$ \\ + \verb=\sendoutP{a}{b}{h}{\alpha_{1}}{\alpha_{2}}= & $\sendoutP{a}{b}{h}{\alpha_{1}}{\alpha_{2}}$ \\ + \verb=\sendoutPT= & $\sendoutPT$ \\ + \verb=\psendout{a}{b}{h}= & $\psendout{a}{b}{h}$ \\ + \verb=\psendoutT= & $\psendoutT$ \\ + \verb=\psendoutP{a}{b}{h}= & $\psendoutP{a}{b}{h}$ \\ + \verb=\psendoutPT= & $\psendoutPT$ \\ + \verb=\dissolution{a}{b}{h}{\alpha}= & $\dissolution{a}{b}{h}{\alpha}$ \\ + \verb=\dissolutionT= & $\dissolutionT$ \\ + \verb=\dissolutionP{a}{b}{h}{\alpha}= & $\dissolutionP{a}{b}{h}{\alpha}$ \\ + \verb=\dissolutionPT= & $\dissolutionPT$ \\ + \verb=\pdissolution{a}{b}{h}= & $\pdissolution{a}{b}{h}$ \\ + \verb=\pdissolutionT= & $\pdissolutionT$ \\ + \verb=\pdissolutionP{a}{b}{h}= & $\pdissolutionP{a}{b}{h}$ \\ + \verb=\pdissolutionPT= & $\pdissolutionPT$ \\ + \verb=\division{a}{b}{c}{h}{\alpha}{\alpha_{1}}{\alpha_{2}}= & $\division{a}{b}{c}{h}{\alpha}{\alpha_{1}}{\alpha_{2}}$ \\ + \verb=\divisionT= & $\divisionT$ \\ + \verb=\divisionP{a}{b}{c}{h}{\alpha}{\alpha_{1}}{\alpha_{2}}= & $\divisionP{a}{b}{c}{h}{\alpha}{\alpha_{1}}{\alpha_{2}}$ \\ + \verb=\divisionPT= & $\divisionPT$ \\ + \verb=\pdivision{a}{b}{c}{h}= & $\pdivision{a}{b}{c}{h}$ \\ + \verb=\pdivisionT= & $\pdivisionT$ \\ + \verb=\pdivisionP{a}{b}{c}{h}= & $\pdivisionP{a}{b}{c}{h}$ \\ + \verb=\pdivisionPT= & $\pdivisionPT$ \\ + \verb=\separation{a}{h}{\alpha}{\alpha_{1}}{\alpha_{2}}= & $\separation{a}{h}{\alpha}{\alpha_{1}}{\alpha_{2}}$ \\ + \verb=\separationT= & $\separationT$ \\ + \verb=\separationP{a}{h}{\alpha}{\alpha_{1}}{\alpha_{2}}= & $\separationP{a}{h}{\alpha}{\alpha_{1}}{\alpha_{2}}$ \\ + \verb=\separationPT= & $\separationPT$ \\ + \verb=\pseparation{a}{h}= & $\pseparation{a}{h}$ \\ + \verb=\pseparationT= & $\pseparationT$ \\ + \verb=\pseparationP{a}{h}= & $\pseparationP{a}{h}$ \\ + \verb=\pseparationPT= & $\pseparationPT$ \\ + \verb=\creation{a}{b}{c}{h}{h_{1}}{\alpha}{\alpha_{1}}{\alpha_{2}}= & $\creation{a}{b}{c}{h}{h_{1}}{\alpha}{\alpha_{1}}{\alpha_{2}}$ \\ + \verb=\creationT= & $\creationT$ \\ + \verb=\creationP{a}{b}{c}{h}{h_{1}}{\alpha}{\alpha_{1}}{\alpha_{2}}= & $\creationP{a}{b}{c}{h}{h_{1}}{\alpha}{\alpha_{1}}{\alpha_{2}}$ \\ + \verb=\creationPT= & $\creationPT$ \\ + \verb=\pcreation{a}{b}{c}{h}{h_{1}}= & $\pcreation{a}{b}{c}{h}{h_{1}}$ \\ + \verb=\pcreationT= & $\pcreationT$ \\ + \verb=\pcreationP{a}{b}{c}{h}{h_{1}}= & $\pcreationP{a}{b}{c}{h}{h_{1}}$ \\ + \verb=\pcreationPT= & $\pcreationPT$ \\ + \verb=\spiking{E}{a^{n}}{a}{d}= & $\spiking{E}{a^{n}}{a}{d}$ \\ + \verb=\spikingT= & $\spikingT$ \\ + \verb=\forgettingT= & $\forgettingT$ \\ + \verb=\spikingP{E}{a^{n}}{a}{d}= & $\spikingP{E}{a^{n}}{a}{d}$ \\ + \verb=\spikingPT= & $\spikingPT$ \\ + \verb=\forgettingPT= & $\forgettingPT$ \\ + \verb=\krewriting{x}{y}{g}= & $\krewriting{x}{y}{g}$ \\ + \verb=\krewritingT= & $\krewritingT$ \\ + \verb=\krewritingP{x}{y}{g}= & $\krewritingP{x}{y}{g}$ \\ + \verb=\krewritingPT= & $\krewritingPT$ \\ + \verb=\linkcreation{x}{y}{t_{l_{i}}}{t_{l_{j}}}{g}= & $\linkcreation{x}{y}{t_{l_{i}}}{t_{l_{j}}}{g}$ \\ + \verb=\linkcreationT= & $\linkcreationT$ \\ + \verb=\linkcreationP{x}{y}{t_{l_{i}}}{t_{l_{j}}}{g}= & $\linkcreationP{x}{y}{t_{l_{i}}}{t_{l_{j}}}{g}$ \\ + \verb=\linkcreationPT= & $\linkcreationPT$ \\ + \verb=\linkdestruction{x}{y}{t_{l_{i}}}{t_{l_{j}}}{g}= & $\linkdestruction{x}{y}{t_{l_{i}}}{t_{l_{j}}}{g}$ \\ + \verb=\linkdestructionT= & $\linkdestructionT$ \\ + \verb=\linkdestructionP{x}{y}{t_{l_{i}}}{t_{l_{j}}}{g}= & $\linkdestructionP{x}{y}{t_{l_{i}}}{t_{l_{j}}}{g}$ \\ + \verb=\linkdestructionPT= & $\linkdestructionPT$ +\end{longtable} +} + +As you can see, the names follow a pattern: + +\begin{itemize} +\item Their name is descriptive in terms of the rule it represents. +\item If the rule starts with a \texttt{p}, it means that it is a + polarizationless rule. +\item If the rule ends with (or its second to last letter is) a + \texttt{P}, it means it will write the rule in P-Lingua format. +\item If the rule ends with a \texttt{T}, it means it is a rule + template; that is, the typical rule used to describe its behaviour. +\end{itemize} + +If you have an idea to make the notation simpler, please let me know. + +\section{Future work} +\label{sec:future-work} + +A TODO list for the future development of the package. Please do not +hesitate to contact me if you think that something should be included +in this list, or if there is any bug or concept that should be +included as soon as possible. Please, contact me at +\href{mailto:dorellana@us.es}{dorellana@us.es} + +\begin{itemize} +\item Add new variants of P systems, as well as some new templates for + other rules. +\item Clean the code and create new command for analysing the + \texttt{multiple} case automatically. +\item Add the possibility of define rules with more than one level of + deepness. +\item Add a automatic parsing of a membrane structure, so a + well-spaced structure can appear in a paper. It would be interesting + to also let it export a string in the P-Lingua format. +\item A long-term objective is to export a .pdf with the picture of a + P system with its contents. Creating an image for your paper could + be as simple as defining it as you usually do, it would be cool, right? +\end{itemize} + +I hope you find the package interesting and useful for your +purposes. And, as I said above, please do not hesitate to contact me +if you have any questions of or suggestions for it. + +\end{document} |