diff options
author | Karl Berry <karl@freefriends.org> | 2013-01-06 23:44:11 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-01-06 23:44:11 +0000 |
commit | a9ec77a042693fd60429f18a8c4a095105f624e6 (patch) | |
tree | e6f0cdca1f7ad0051416bb767c2e409995a1aaf1 | |
parent | ee04c8f00d7e705f71d02aa40a312252423dd4f3 (diff) |
algorithm2e (6jan13)
git-svn-id: svn://tug.org/texlive/trunk@28749 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/algorithm2e/algorithm2e.pdf | bin | 400133 -> 487487 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/algorithm2e/algorithm2e.tex | 970 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/algorithm2e/algorithm2e_ex04.tex | 3 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/algorithm2e/algorithm2e_ex05.tex | 2 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/algorithm2e/algorithm2e_exProg.tex | 6 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/algorithm2e/algorithm2e_exgeneric.tex | 36 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/algorithm2e/algorithm2e_exswitch.tex | 2 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/algorithm2e/algorithm2e.sty | 921 | ||||
-rwxr-xr-x | Master/tlpkg/libexec/ctan2tds | 1 |
9 files changed, 1219 insertions, 722 deletions
diff --git a/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e.pdf b/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e.pdf Binary files differindex b0a7c08dd82..2b19fceb269 100644 --- a/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e.pdf +++ b/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e.pdf diff --git a/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e.tex b/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e.tex index 3bc2c09baed..496cc8f6e36 100644 --- a/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e.tex +++ b/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e.tex @@ -1,12 +1,12 @@ % algorithm2e.tex --- doc of the package file for algorithms % % (c) 1995-1997 Christophe Fiorio, Tu-Berlin, Germany -% (c) 1998-2009 Christophe Fiorio, Montpellier 2 University, France +% (c) 1998-2013 Christophe Fiorio, Montpellier 2 University, France % % Report bugs and comments to: % christophe.fiorio@univ-montp2.fr % -% $Id: algorithm2e.tex,v 1.38 2009/12/15 08:54:36 cfiorio Exp $ +% $Id: algorithm2e.tex,v 5.0 2013/01/06 14:44:54 cfiorio Exp $ % \documentclass[a4paper]{article} @@ -40,6 +40,7 @@ \newcommand\almacpppp[5]{$\backslash$\texttt{#1\{#2\}\{#3\}\{#4\}\{#5\}}\index{#1@\texttt{$\protect\backslash$#1}|textit}} \newcommand\almacpsix[7]{$\backslash$\texttt{#1\{#2\}\{#3\}\{#4\}\{#5\}\{#6\}\{#7\}}\index{#1@\texttt{$\protect\backslash$#1}|textit}} \newcommand\almacphuit[9]{$\backslash$\texttt{#1\{#2\}\{#3\}\{#4\}\{#5\}\{#6\}\{#7\}\{#8\}\{#9\}}\index{#1@\texttt{$\protect\backslash$#1}|textit}} +\newcommand\Alenv[1]{\texttt{#1}\index{#1@\texttt{#1}|textbf}} \newcommand\Almac[1]{$\backslash$\texttt{#1}\index{#1@\texttt{$\protect\backslash$#1}|textbf}} \newcommand\Almacp[2]{$\backslash$\texttt{#1\{#2\}}\index{#1@\texttt{$\protect\backslash$#1}|textbf}} \newcommand\Almacpp[3]{$\backslash$\texttt{#1\{#2\}\{#3\}}\index{#1@\texttt{$\protect\backslash$#1}|textbf}} @@ -57,9 +58,12 @@ % \newcommand{\optslide}{\textsf{slide}\index{french@\textsf{slide}|textit}\xspace} \newcommand{\optalgoe}{\textsf{algo2e}\index{french@\textsf{algo2e}|textit}\xspace} -\newcommand{\optfrench}{\textsf{french}\index{french@\textsf{french}|textit}\xspace} \newcommand{\optenglish}{\textsf{english}\index{english@\textsf{english}|textit}\xspace} +\newcommand{\optfrench}{\textsf{french}\index{french@\textsf{french}|textit}\xspace} \newcommand{\optgerman}{\textsf{german}\index{german@\textsf{german}|textit}\xspace} +\newcommand{\optngerman}{\textsf{ngerman}\index{ngerman@\textsf{ngerman}|textit}\xspace} +\newcommand{\optspanish}{\textsf{spanish}\index{spanish@\textsf{spanish}|textit}\xspace} +\newcommand{\optcroatian}{\textsf{croatian}\index{croatian@\textsf{croatian}|textit}\xspace} \newcommand{\optportuguese}{\textsf{portuguese}\index{portuguese@\textsf{portuguese}|textit}\xspace} \newcommand{\optczech}{\textsf{czech}\index{czech@\textsf{czech}|textit}\xspace} \newcommand{\optitaliano}{\textsf{italiano}\index{italiano@\textsf{italiano}|textit}\xspace} @@ -98,11 +102,15 @@ \newcommand{\optprocnumbered}{\textsf{procnumbered}\index{procnumbered@\textsf{procnumbered}|textit}\xspace} \newcommand{\optoldcommands}{\textsf{oldcommands}\index{oldcommands@\textsf{oldcommands}|textit}\xspace} \newcommand{\optnokwfunc}{\textsf{nokwfunc}\index{nokwfunc@\textsf{nokwfunc}|textit}\xspace} +\newcommand{\optblockmarkers}{\textsf{displayblockmarkers}\index{displayblockmarkers@\textsf{displayblockmarkers}|textit}\xspace} % \newcommand{\Optfrench}{\textsf{french}\index{french@\textsf{french}|textbf}\xspace} \newcommand{\Optenglish}{\textsf{english}\index{english@\textsf{english}|textbf}\xspace} -\newcommand{\Optgerman}{\textsf{german}\index{german@\textsf{german}|textit}\xspace} -\newcommand{\Optportugues}{\textsf{portugues}\index{portugues@\textsf{portugues}|textit}\xspace} +\newcommand{\Optgerman}{\textsf{german}\index{german@\textsf{german}|textbf}\xspace} +\newcommand{\Optngerman}{\textsf{ngerman}\index{ngerman@\textsf{ngerman}|textbf}\xspace} +\newcommand{\Optspanish}{\textsf{spanish}\index{spanish@\textsf{spanish}|textbf}\xspace} +\newcommand{\Optcroatian}{\textsf{croatian}\index{croatian@\textsf{croatian}|textbf}\xspace} +\newcommand{\Optportugues}{\textsf{portugues}\index{portugues@\textsf{portugues}|textbf}\xspace} \newcommand{\Optczech}{\textsf{czech}\index{czech@\textsf{czech}|textbf}\xspace} \newcommand{\Optitaliano}{\textsf{italiano}\index{italiano@\textsf{italiano}|textbf}\xspace} \newcommand{\Optslovak}{\textsf{slovak}\index{slovak@\textsf{slovak}|textbf}\xspace} @@ -140,6 +148,7 @@ \newcommand{\Optprocnumbered}{\textsf{procnumbered}\index{procnumbered@\textsf{procnumbered}|textbf}\xspace} \newcommand{\Optoldcommands}{\textsf{oldcommands}\index{oldcommands@\textsf{oldcommands}|textbf}\xspace} \newcommand{\Optnokwfunc}{\textsf{nokwfunc}\index{nokwfunc@\textsf{nokwfunc}|textbf}\xspace} +\newcommand{\Optblockmarkers}{\textsf{displayblockmarkers}\index{displayblockmarkers@\textsf{displayblockmarkers}|textbf}\xspace} %%% \newcommand{\ExampleOfAlgo}[1]{% \begin{minipage}{.4\textwidth}% @@ -152,21 +161,21 @@ \end{minipage}% } %%%%%%%%%%%%%%%%%%%%%% -\newcommand{\algocfversion}{release 4.01} \title{algorithm2e.sty --- package for algorithms\\ - {\large\algocfversion}} +\newcommand{\algocfversion}{release 5.0} +\title{algorithm2e.sty --- package for algorithms\\ {\large\algocfversion}} \author{(c) 1995-1997 Christophe Fiorio, Tu-Berlin, Germany\\ - (c) 1998-2009 Christophe Fiorio, LIRMM, Montpellier 2 University, France\\ - Report bugs and comments to christophe.fiorio@univ-montp2.fr\\ +(c) 1998-2013 Christophe Fiorio, LIRMM, Montpellier 2 University, France\\ + Report bugs and comments to cfiorio@um2.fr\\ algorithm2esty-annonce@lirmm.fr mailing list for announcements\\ - algorithm2esty-discussion@lirmm.fr mailing list for discussion\thanks{The author is very grateful to David - Carlisle, one of the authors of the LaTeX Companion book, for his advices} \thanks{Martin Blais for his - suggestions} \thanks{David A. Bader for his new option \texttt{noend}} \thanks{Gilles Geeraerts for his new - command \texttt{SetKwIfElseIf}} \thanks{Ricardo Fukasawa for the portuguese keywords} \thanks{Christian Icking - for the german translation of keywords} \thanks{Arnaud Giersch for his suggestions and corrections on - SetKwComments} \thanks{Nathan Tallent for his $\backslash$SetKwHangingKw macro} \thanks{and the many users as - Jean-Baptiste Rouquier for their remarks} } - -\date{december 14 2009} + algorithm2esty-discussion@lirmm.fr mailing list for discussion\thanks{The author is very grateful + to David Carlisle, one of the authors of the LaTeX Companion book, for his advices} \thanks{Martin Blais for his + suggestions} \thanks{David A. Bader for his new option + \texttt{noend}} \thanks{Gilles Geeraerts for his new + command \texttt{SetKwIfElseIf}} \thanks{Ricardo Fukasawa for the portuguese keywords} \thanks{Christian Icking + for the german translation of keywords} + \thanks{Arnaud Giersch for his suggestions and corrections on SetKwComments} +\thanks{and the many users as Jean-Baptiste Rouquier + for their remarks} } \date{january 06 2013} \makeindex @@ -195,8 +204,8 @@ In order to subscribe to the mailing lists you have to send an email to Name} or\\\texttt{subscribe algorithm2e-discussion Firstname Name} in the body of the message.\makeatother -Changes from one release to the next are indicated in release notes at the beginning of the packages. For release -4.0, changes are indicated at the end of this document. +Changes from one release to the next are indicated in release notes at the beginning of the packages. For this +release (5.0), changes are indicated at the end of this document. \section{How to use it: abstract} @@ -306,15 +315,160 @@ The \LaTeX2e code on next page gives \autoref{IR}. Here lines are not autonumber individually with \almac{nl} command as for \autoref{InRes1} or \autoref{InRes2}. You even can set your own reference with \almac{nlset} command and get back this reference by simply using classical \almac{ref}. For example \texttt{$\backslash$ref\{InResR\}} gives \ref{InResR}.\par +{% \RestyleAlgo{algoruled}\SetAlgoVlined\LinesNotNumbered\input{algorithm2e_exIR.tex} \noindent\fbox{% \begin{minipage}[c]{\textwidth}% \verbatiminput{algorithm2e_exIR.tex}% \end{minipage}\label{code:algoIR}% -}% +}}% \par \clearpage +%%%%%%%%%%%%% +\section{Genericity and example of languages} + +In this section, we will try to show you main macros and how you can use this package to +suit your need. Based on one example using most popular algorithms expressions, we will +show you how it can be configured to be display in pseudo-code, in python or in C. + +The following code shows how is typeset the generic example we'll use in this section:\par +{% +\noindent\fbox{% + \begin{minipage}[c]{\textwidth}% + \verbatiminput{algorithm2e_exgeneric}% + \end{minipage}\label{code:exgeneric}% +}}% +\par\medskip +To handle \texttt{if} condition, use a macro to be abble to change it according to +language syntax, in particular we will change it for python-style and c-style. We also +define a function to write algorithm as a recursive function. These macros are defined as:\vspace{-1.5ex} +\begin{verbatim} +\newcommand{\forcond}{$i=0$ \KwTo $n$} +\SetKwFunction{FRecurs}{FnRecursive}% +\end{verbatim} + +The \autoref{algo:pseudocode} shows how algorithm is displayed in pseudo-code with default +behaviour and options \texttt{boxed}, \texttt{commentsnumbered} and \texttt{longend} +set. Note that by default, lines are used to show block of code. Note also that +\texttt{longend} option makes package use special \emph{end} keyword for each +command\footnote{Default behaviour uses \emph{short end} keywords, it means typeseting only + \emph{end}.}. +\SetKwProg{Fn}{Function}{}{end}\SetKwFunction{FRecurs}{FnRecursive}% +\newcommand{\forcond}{$i=0$ \KwTo $n$} +\begin{algorithm}\SetAlgoLongEnd + \caption{Generic example with most classical expressions derived in pseudo-code}% + \label{algo:pseudocode} + \input{algorithm2e_exgeneric} +\end{algorithm} + +The \autoref{algo:pseudocodeblock} shows how algorithm is displayed using automatic block +display (new feature since relase 5.0). To achieve this display, we only add following +macros at start of the algorithm:\vspace{-1.5ex} +\begin{verbatim} +\AlgoDisplayBlockMarkers\SetAlgoBlockMarkers{begin}{end}% +\SetAlgoNoEnd +\end{verbatim} +\vspace{-1.5ex}First one tells package to display blocks with keyword markers. Note that +the definition of block markers are the one by default. Last macro remove end keywords of +commands to avoid a double end (the one of block marker and the one of command). +\begin{algorithm}\AlgoDisplayBlockMarkers\SetAlgoNoEnd\SetAlgoBlockMarkers{begin}{end} + \caption{Generic example in pseudo-code with begin-end block set}\label{algo:pseudocodeblock} + \input{algorithm2e_exgeneric} +\end{algorithm}\medskip + +The \autoref{algo:pythoncodeblock} shows how algorithm looks like with a python-style +syntax. To achieve this display, we need to make following changes before the algorithm:\vspace{-1.5ex} +\begin{verbatim} +\SetStartEndCondition{ }{}{}% +\SetKwProg{Fn}{def}{\string:}{} +\SetKwFunction{Range}{range}%% +\SetKw{KwTo}{in}\SetKwFor{For}{for}{\string:}{}% +\SetKwIF{If}{ElseIf}{Else}{if}{:}{elif}{else:}{}% +\SetKwFor{While}{while}{:}{fintq}% +\renewcommand{\forcond}{$i$ \KwTo\Range{$n$}} +\AlgoDontDisplayBlockMarkers\SetAlgoNoEnd\SetAlgoNoLine% +\end{verbatim} +\vspace{-1.5ex}\texttt{SetStartEndCondition} is used to display alternatives and loops +conditions according to python syntax: it means a space before condition, and no space +after since ':' marks end of condition. Functions are defined with \emph{def} in python, +so we redefine \texttt{$\backslash$Fn} macro. \texttt{Range} is a new macro for +\emph{range} python function. Next are redefined \emph{For}, \emph{If} and \emph{While} +commands accordingly to python syntax. Note that we do nothing for \emph{repeat-until} +command since it doesn't exist in python. For condition is redefined to match python +behaviour. At last we tell package to not display block, to +not display end keyword and to not print line according to python syntax.% +\renewcommand{\forcond}{$i$ \KwTo\Range{$n$}} +\begin{algorithm} \AlgoDontDisplayBlockMarkers\SetAlgoNoEnd\SetAlgoNoLine% +\SetStartEndCondition{ }{}{}% +\SetKwProg{Fn}{def}{\string:}{}% +\SetKw{KwTo}{in}\SetKwFunction{Range}{range}% +\SetKwFor{For}{for}{\string:}{}% +\SetKwIF{If}{ElseIf}{Else}{if}{:}{elif}{else:}{}% +\SetKwFor{While}{while}{:}{fintq}% + \caption{Generic example in python-style like syntax}\label{algo:pythoncodeblock} + \input{algorithm2e_exgeneric} +\end{algorithm} + + The \autoref{algo:ccodeblock} shows how algorithm looks like with a c-style +syntax. To achieve this display, we need to make following changes before the algorithm:\vspace{-1.5ex} +\begin{verbatim} +\SetStartEndCondition{ (}{)}{)}\SetAlgoBlockMarkers{\{}{\}}% +\SetKwProg{Fn}{}{}{}\SetKwFunction{FRecurs}{void FnRecursive}% +\SetKwFor{For}{for}{}{}% +\SetKwIF{If}{ElseIf}{Else}{if}{}{elif}{else}{}% +\SetKwFor{While}{while}{}{}% +\SetKwRepeat{Repeat}{repeat}{until}% +\AlgoDisplayBlockMarkers\SetAlgoNoLine% +\end{verbatim} +\vspace{-1.5ex} \texttt{SetStartEndCondition} set braces around conditions like in C. We +want that each block is marked with \{ at start and \} at end, so we set it thanks to +\texttt{$\backslash$SetAlgoBlockMarkers} macro. \texttt{$\backslash$Fn} is redefined with +no keyword since in C, name of function defines it. Then we redefin \texttt{FnRecursive} +with its type. Next, \emph{For}, \emph{If}, \emph{While} and \emph{Repeat} are redefined +accordingly to C syntax. At last, we tell the package to display block markers. +\SetKwFunction{FRecurs}{void FnRecursive}% +\begin{algorithm}\AlgoDisplayBlockMarkers\SetAlgoNoLine% +\SetStartEndCondition{ (}{)}{)}\SetAlgoBlockMarkers{\{}{\}}% +\SetKwProg{Fn}{}{}{}% +\SetKwFor{For}{for}{}{}% +\SetKwIF{If}{ElseIf}{Else}{if}{}{elif}{else}{}% +\SetKwFor{While}{while}{}{}% +\SetKwRepeat{Repeat}{repeat}{until}% + \caption{Generic example in c-style like syntax}\label{algo:ccodeblock} + \input{algorithm2e_exgeneric} +\end{algorithm} + +The \autoref{algo:ccodeblockcf} shows how algorithm looks like with a c-style +syntax and a more compact way to mark blocks. To achieve this display, we need to make following changes before the algorithm:\vspace{-1.5ex} +\begin{verbatim} +\SetStartEndCondition{ (}{)}{)}\SetAlgoBlockMarkers{}{\}}% +\SetKwProg{Fn}{}{\{}{}\SetKwFunction{FRecurs}{void FnRecursive}% +\SetKwFor{For}{for}{\{}{}% +\SetKwIF{If}{ElseIf}{Else}{if}{\{}{elif}{else\{}{}% +\SetKwFor{While}{while}{\{}{}% +\SetKwRepeat{Repeat}{repeat\{}{until}% +\AlgoDisplayBlockMarkers\SetAlgoNoLine% +\end{verbatim} +\vspace{-1.5ex} If you look at \autoref{algo:pseudocode}, you can see that some command +doesn't put a end. For example, it is a case for a \emph{if} followed by an \emph{else}, +same thing for a \emph{else if}. In C, there is always an end marker. So, to achieve our +goal we need to use end marker of blocks. But we don't want displaying begin marker as in +\autoref{algo:pseudocodeblock} or \autoref{algo:ccodeblock}. If begin block marker is set to +empty, then nothing is written (especially not a blank line). So we tell package to use +block markers with an empty marker for begin and a \} for end. Now we have to tell package +to write a \{ on the same line as commands. This is achieve by redefining \emph{If}, +\emph{For}, \emph{While} and \emph{Repeat} command. +\begin{algorithm}\AlgoDisplayBlockMarkers\SetAlgoLongEnd\SetAlgoNoLine% +\SetStartEndCondition{ (}{)}{)}\SetAlgoBlockMarkers{}{\}}% +\SetKwProg{Fn}{}{\{}{}% +\SetKwFor{For}{for}{\{}{}% +\SetKwIF{If}{ElseIf}{Else}{if}{\{}{elif}{else\{}{}% +\SetKwFor{While}{while}{\{}{}% +\SetKwRepeat{Repeat}{repeat\{}{until}% + \caption{Generic example in c-style like syntax with compact block}\label{algo:ccodeblockcf} + \input{algorithm2e_exgeneric} +\end{algorithm} %%%%%%%%%%%%% @@ -411,7 +565,7 @@ If you don't like algorithm or look for something else, you can change the name below: \begin{description} \item[\almacppp{SetAlgorithmName}{algorithmname}{algorithmautorefname}{list of algorithms name}] which redefines - name of the algorithms and the sentence list of algorithms. Example: \almacpp{SetAlgorithmName}{Protocol}{List of + name of the algorithms and the sentence list of algorithms. Example:\\\noindent\almacpp{SetAlgorithmName}{Protocol}{List of protocols} if you prefer protocol than algorithm. Second argument is the name that \almac{autoref}, from \texttt{hyperref}\index{hyperref} package, will use. \end{description} @@ -430,23 +584,19 @@ keep its original name: \section{The options of the package\label{sec_options}} + +%-------------------------------------------------------------------------- +\subsection{language option} +\label{sec:option:language} \begin{description} -\item[\optalgoe:] changes the name of environment algorithm into algorithm2e - and so allows to use the package with some journal style which already define - an algorithm environment. Changes also the command name for the list of - algorithms, it becomes \Almac{listofalgorithmes} -\item[\optslide:] require package color. To be used with slide class in order to have correct margins. -\item[\Optnorelsize:] starting from this release v4.00, algorithm2e package uses relsize package in order to get - relative size for lines numbers; but it seems that some rare classes (such as inform1.cls) are not compatible - with relsize; to have algorithm2e working, this option makes algorithm2e not to load relsize package and go back - to previous definition by using \scriptsize font for lines numbers. -\medskip +\item[\Optcroatian:] to have for example \textsl{Algoritam:} instead of \textsl{algorithm:}. \medskip +\item[\Optczech:] to have for example \textsl{Algoritmus:} instead of \textsl{algorithm:}. \item[\Optenglish:] the default. \item[\Optfrench:] to have for example \textsl{algorithme\ :} instead of \textsl{algorithm:}. \item[\Optgerman:] to have for example \textsl{Prozedur\ :} instead of \textsl{procedure:}. \medskip +\item[\Optngerman:] to have german option as babel \item[\Optportugues:] to have for example \textsl{Algoritmo:} instead of \textsl{algorithm:}. \medskip -\item[\Optczech:] to have for example \textsl{Algoritmus:} instead of - \textsl{algorithm:}. +\item[\Optspanish:] to have for example \textsl{Algoritmo:} instead of \textsl{algorithm:}. \medskip \item[\Optonelanguage:] allows, if using standard keywords listed below, to switch from one language to another without changing keywords by using appropriate language option: \begin{itemize} @@ -459,27 +609,85 @@ keep its original name: \item \texttt{Switch, Case, Other} \item \texttt{For, ForPar, ForEach, ForAll, While} \end{itemize} -\medskip -\item[\Optfigure :] algorithms are put in classical figures and so are numbered as - figures and putted in the $\backslash$\texttt{listoffigures}.\par +\end{description} + +%-------------------------------------------------------------------------- +\subsection{compatibility issue} +\label{sec:option:compatibility} + +\begin{description} +\item[\optalgoe:] changes the name of environment algorithm into algorithm2e + and so allows to use the package with some journal style which already define + an algorithm environment. Changes also the command name for the list of + algorithms, it becomes \Almac{listofalgorithmes} \item[\Optendfloat:] endfloat packages doesn't allow float environment inside other environment. So using it with figure option of algorithm2e makes error. This option enables a new environment algoendfloat to be used instead of algorithm environment that put algorithm at the end. algoendfloat environment make algorithm acting as endfloat figures. This option load endfloat package, so it is required to have it. -\medskip -\item[\optalgopart :] algorithms are numbered within part numbers. -\item[\optalgochapter :] algorithms are numbered within chapter numbers. -\item[\optalgosection :] (default) algorithms are numbered within section numbers. -\item[\Optprocnumbered:] makes the procedure and function to be numbered as algorithm. -\medskip +\item[\Optnorelsize:] starting from this release (v4.00), algorithm2e package uses relsize package in order to get + relative size for lines numbers; but it seems that some rare classes (such as inform1.cls) are not compatible + with relsize; to have algorithm2e working, this option makes algorithm2e not to load relsize package and go back + to previous definition by using $\backslash$\texttt{scriptsize} font for lines numbers. +\item[\optslide:] require package color. To be used with slide class in order to have correct margins. +\item[\Optnokwfunc] disable the setting in \almac{KwFunction} of procedure's or function's name (see \autoref{sec_envi}) + of function and procedure environment. Useful if you use name of procedure or function that cannot be a command + name as a math display for example. +\end{description} + +%-------------------------------------------------------------------------- +\subsection{environment display and use} +\label{sec:option:envdisplay} + +%--------------------------------- +\subsubsection{boxed, ruled, plain environment} +\label{sec:option:envdisplay:box} + +\begin{description} \item[\Optboxed :] to have algorithms enclosed in a box. \item[\Optboxruled :] surround algorithm by a box, puts caption above and add a line after caption. \item[\Optruled :] to have algorithms with a line at the top and the bottom. Note that the caption is not centered under the algorithm anymore but is set at the beginning of the algorithm. \item[\Optalgoruled :] as above but with extra spaces after the rules. \item[\Opttworuled:] tworuled acts like ruled but doesn't put a line after the title. -\item[\Optplain :] the default, with no feature. -\medskip +\item[\Optplain :] the default, with no feature.\par +\end{description} + +%--------------------------------- +\subsubsection{algorithm numbering} +\label{sec:option:envdisplay:numbers} + +\begin{description} +\item[\optalgochapter :] algorithms are numbered within chapter numbers. +\item[\optalgosection :] (default) algorithms are numbered within section numbers. +\item[\optalgopart :] algorithms are numbered within part numbers.\par\medskip +\item[\Optprocnumbered:] makes the procedure and function to be numbered as algorithm. +\end{description} + +%--------------------------------- +\subsubsection{figure and toc} +\label{sec:option:envdisplay:figuretoc} + +\begin{description} +\item[\Optfigure :] algorithms are put in classical figures and so are numbered as + figures and putted in the $\backslash$\texttt{listoffigures}.\par +\item[\Optdotocloa] adds an entry in the toc for the list of algorithms. This option loads package + \texttt{tocbibind} if not already done and so list of figures and list of tables are also added in + the toc. If you want to control which ones of the lists will be added in the toc, please load + package \texttt{tocbibind} before package algorithm and give it the options you want. +\end{description} + +%-------------------------------------------------------------------------- +\subsection{code typesetting} +\label{sec:option:algodisplay} + +%--------------------------------- +\subsubsection{blocks display} +\label{sec:option:algodisplay:blocks} + +\paragraph{lines} +\label{sec:option:algodisplay:blocks:lines} + +\begin{description} \item[\Optlined:] \almac{SetAlgoLined} becomes the default, see \autoref{sec_styleoptions} for explanations about the \almac{SetAlgoLined} macros. @@ -489,7 +697,45 @@ keep its original name: \item[\Optnoline:] \almac{SetNoline} becomes the default, see \autoref{sec_styleoptions} for explanations about the \almac{SetNoline} macros. -\medskip +\end{description} + +\paragraph{block markers} +\label{sec:option:algodisplay:blocks:markers} + +\begin{description} +\item[\Optblockmarkers] \almac{AlgoDisplayBlockMarkers} becomes the default, see \autoref{sec_styleoptions} + for explanations about the \almac{AlgoDisplayBlockMarkers} macro. +\end{description} + +%--------------------------------- +\subsubsection{end keywords} +\label{sec:option:algodisplay:endkeywords} + +\begin{description} +\item[\Optlongend] the end keyword are longer and different for + each macro. For example \emph{endif} for a if-then-else macro. +\item[\Optshortend] the ``end keyword'' of the macros is just + \emph{end} (default). +\item[\Optnoend] the ``end keyword'' of the macros is not printed. +\end{description} + +%--------------------------------- +\subsubsection{comments} +\label{sec:option:algodisplay:comments} + +\begin{description} +\item[\Optscright (default)] right justified side comments (side comments are flushed to the right) +\item[\Optscleft] left justified side comments (side comments are put right after the code line) +\item[\Optfillcomment (default)] end mark of comment is flushed to the right so comments fill all + the width of text +\item[\Optnofillcomment] end mark of comment is put right after the comment +\end{description} + +%--------------------------------- +\subsubsection{lines numbers} +\label{sec:optin:algodisplay:linenumber} + +\begin{description} \item[\Optlinesnumbered:] lines of the algorithms are numbered except for comments and input/output (KwInput and KwInOut). You must use \almacp{nllabel}{label} to label thoses lines. @@ -498,18 +744,8 @@ keep its original name: put. \item[\Optcommentsnumbered:] makes comments be numbered if numbering is active. \item[\Optinoutnumbered:] makes data input/output be numbered if numbering is active. -\item[\Optrightnl:] put lines numbers to the right of the algorithm instead of left. -\medskip -\item[\Opttitlenumbered :] \almacp{TitleOfAlgo}{title} - prints \textsl{Algorithm n: thetitle} where \emph{n} is the counter - of the algo.\\ - \textbf{Beware}: \almac{TitleOfAlgo} don't insert an entry in the - list of algorithms. So do not use \almac{TitleOfAlgo} with a caption. - Both increment the counter of the algorithms. -\item[\Opttitlenotnumbered (default)] the macro - \texttt{$\backslash$TitleOfAlgo\{title\}} doesn't number the algorithm. -\medskip - +\item[\Optrightnl:] put lines numbers to the right of the algorithm instead of + left.\par\medskip \item[\Optresetcount] the line numbers are reset to 0 at the beginning of each algorithm (by default). \item[\Optnoresetcount] the contreverse of the precedent. To reset @@ -519,23 +755,21 @@ keep its original name: current algorithm. \textbf{Take care} to set the caption of the algorithm at the beginning of the environnement, else you will have the precedent algorithm number as the current one. -\item[\Optlongend] the end keyword are longer and different for - each macro. For example \emph{endif} for a if-then-else macro. -\item[\Optshortend] the ``end keyword'' of the macros is just - \emph{end} (default). -\item[\Optnoend] the ``end keyword'' of the macros is not printed. -\item[\Optdotocloa] adds an entry in the toc for the list of algorithms. This option loads package - \texttt{tocbibind} if not already done and so list of figures and list of tables are also added in - the toc. If you want to control which ones of the lists will be added in the toc, please load - package \texttt{tocbibind} before package algorithm and give it the options you want. -\item[\Optscright (default)] right justified side comments (side comments are flushed to the right) -\item[\Optscleft] left justified side comments (side comments are put right after the code line) -\item[\Optfillcomment (default)] end mark of comment is flushed to the right so comments fill all - the width of text -\item[\Optnofillcomment] end mark of comment is put right after the comment -\item[\Optnokwfunc] unable the setting in \almac{KwFunction} of procedure's or function's name (see \autoref{sec_envi}) - of function and procedure environment. Useful if you use name of procedure or function that cannot be a command - name as a math display for example. +\end{description} + +%--------------------------------- +\subsubsection{title of algorithms} +\label{sec:option:algodisplay:title} + +\begin{description} +\item[\Opttitlenumbered :] \almacp{TitleOfAlgo}{title} + prints \textsl{Algorithm n: thetitle} where \emph{n} is the counter + of the algo.\\ + \textbf{Beware}: \almac{TitleOfAlgo} don't insert an entry in the + list of algorithms. So do not use \almac{TitleOfAlgo} with a caption. + Both increment the counter of the algorithms. +\item[\Opttitlenotnumbered (default)] the macro + \texttt{$\backslash$TitleOfAlgo\{title\}} doesn't number the algorithm. \end{description} @@ -543,37 +777,34 @@ keep its original name: \section{Typesetting} -There are six text types in an algorithm environment: +There are eight text types in an algorithm environment: \begin{enumerate} -\item The keywords (\textbf{Kw}): Macros which usually indicate words - of the language. Some are predefined and given with \emph{the - algorithm package}. - - The user can define his own language keywords by using the - different macros presented in \autoref{sec_deflanguage} (see - below for a short, non exhaustive list). He can also define simple - keywords with the \almacpp{SetKw}{Kw}{thetext} macro. -\item The Functions: (\textbf{Func}) Macros defined by the user which - denote local functions or other algorithms defined in the text. - - They are defined using \almacpp{SetKwFunction}{KwFn}{Fn} where - $\backslash$KwFn will be the macro and \FuncSty{Fn} the text - printed. +\item The keywords (\textbf{Kw}): Macros which usually indicate words of the language. Some are predefined and + given with \emph{the algorithm package}. + + The user can define his own language keywords by using the different macros presented in + \autoref{sec_deflanguage} (see below for a short, non exhaustive list). He can also define simple keywords with + the \almacpp{SetKw}{Kw}{thetext} macro. +\item The Functions: (\textbf{Func}) Macros defined by the user which denote local functions or other algorithms + defined in the text. (See also function environment at~\autoref{sec_envi}, which defines not only function + keyword but algorithm of the function. + + They are defined using \almacpp{SetKwFunction}{KwFn}{Fn} where $\backslash$KwFn will be the macro and + \FuncSty{Fn} the text printed. \item The Arguments (\textbf{Arg}): The arguments of the \emph{Kw} or \emph{Func} macros. -\item The procedure and function name environment style (\almac{ProcNameSty}): - The type style of the caption of \emph{procedure} and \emph{function} - environment. -\item The arguments of procedure and function environments style - (\almac{ProcArgSty}): the type style of the argument of \emph{procedure} and - \emph{function} environments. -\item Data (\textbf{Data}): A type of text different from the default. - You can use it as you want, and can be useful for example to emphasize a Data - structure or denotes some important variables. - - They are defined with the help of the - \almacpp{SetKwData}{KwDat}{data} macro, where $\backslash$KwDat will - be the macro and \DataSty{data} the text printed. +\item The procedure and function name environment style (\almac{ProcNameSty} and \almac{ProcNameFnt}): The type + style of the caption of \emph{procedure} and \emph{function} environment. +\item The arguments of procedure and function environments style (\almac{ProcArgSty} and \almac{ProcArgFnt}): the + type style of the argument of \emph{procedure} and \emph{function} environments. +\item Data (\textbf{Data}): A type of text different from the default. You can use it as you want, and can be + useful for example to emphasize a Data structure or denotes some important variables. + + They are defined with the help of the \almacpp{SetKwData}{KwDat}{data} macro, where $\backslash$KwDat will be the + macro and \DataSty{data} the text printed. +\item Block markers: style of keywords that are print at begin and end of block when + \optblockmarkers option is set or \almac{AlgoDisplayBlockMarkers} macro used. By default, + \almac{BlockMarkersSty} is set to \almac{KwSty}. \item The text (the default): All the remaining text of the algorithm. \end{enumerate} @@ -587,7 +818,7 @@ particular, you can use them inside all algorithms without redefining them. Be c beginning a block outside an algorithm environment. %---------- -\subsection{basic typesetting commands}\label{sec:basiccommands} +\subsection{global code typesetting commands}\label{sec:basiccommands} \begin{description} \item[\Almac{;}] marks the end of a line. \textbf{Don't forget it !}. By @@ -600,6 +831,19 @@ beginning a block outside an algorithm environment. vertical space of one \texttt{ex}. \item[\Almac{Indp}] indents plus $\rightarrow$ the text is shifted to the right. \item[\Almac{Indm}] indents minus $\rightarrow$ the text is shifted to the left. +\item[\Almacppp{SetStartEndCondition}{typo1}{typo2}{typo3}] which sets typo around + condition in \texttt{For}, \texttt{If}, \texttt{Switch}, \texttt{Case} and + \texttt{Repeat} macros. First two are used around \texttt{For}, \texttt{If}, + \texttt{Switch} conditions, First and third are used for \texttt{Case} and + \texttt{Repeat} condition. Default definition is:\\ \verb+\SetStartEndCondition{ }{ }{}+.\\ + A common alternative is \verb+\SetStartEndCondition{ (}{) }{)}+.\\ + It can also be used to remove space around condition, for example if you want python style + commands: \verb+\SetStartEndCondition{ }{}{}+ and \verb+\SetKwFor{For}{for}{:}{}+ +\item[\Almac{AlgoDisplayBlockMarkers}] that prints begin and end markers at the start and end + of all block. These begin and end keywords could be specified by using + \almacpp{SetAlgoBlockMarkers{begin keywords}{end keywords}} command. By default, these + keywords are not printed but \emph{begin} and \emph{end} are default keywords used if + \verb+\AlgoDisplayBlockMarkers+ is called. \end{description} %---------- @@ -667,7 +911,7 @@ The following commands help you to define the style and the layout of the captio \end{description} Note that two length control the layout of ruled, algoruled, boxruled algorithms -caption. \Almac{interspacetitleruled} and \Almac{interspaceboxruled} are described \autoref{sec_styleoptions}. +caption. \Almac{interspacetitleruled} and \Almac{interspacetitleboxruled} are described \autoref{sec_styleoptions}. %---------- \subsection{line numbering}\label{sec:linenumbering} @@ -704,7 +948,7 @@ following commands: \almac{label}. \end{description} -\subsubsection{setting style of lines} +\subsubsection{setting style of lines numbers} \label{sec:linestyle} The following command allows you to change the way line numbers are printed: @@ -719,6 +963,20 @@ The following command allows you to change the way line numbers are printed: \almacp{SetAlgoNlRelativeSize}{$0$} sets it to the same size, \almacp{SetAlgoNlRelativeSize}{$-1$} to one size smaller and \almacp{SetAlgoNlRelativeSize}{$1$} to one size bigger. \end{description} +Example below shows use of these macros:\par\smallskip\noindent% +{\RestyleAlgo{tworuled}\ExampleOfAlgo{algorithm2e_exnlsty.tex}} + +%---------- + +\subsection{math display} +\label{sec:mathdisplay} + +If you need to use math display to handle complex mathematics as matrix, using standard +$\backslash$[ $\backslash$] or \$\$ will not allow correct numbering and end line +management. If you don't need line numbers, there is no problem. If you want line numbers, +please use \Alenv{algomathdisplay} environment instead of $\backslash$[ $\backslash$] or +\$\$. It will work as standard math display but line spacing, line numbers, end line will +be managed correcly %---------- @@ -746,48 +1004,108 @@ commands'' (see \autoref{sec:setfntsty}) \item[\Almacp{NlSty}{$<$text$>$}] sets $<$text$>$ in number line typography. \medskip -\item[\Almacp{ProcNameSty}{$<$text$>$}] sets $<$text$>$ in caption typography of procedure and function environment (by - default the same as \almacp{AlCapSty}). -\item[\Almacp{ProcArgSty}{$<$text$>$}] sets $<$text$>$ in argument typography of procedure and function environment - (by default the same as \almacp{AlCapNameSty}). +\item[\Almacp{ProcNameSty}{$<$text$>$}] sets $<$text$>$ in procedure style of procedure and function environment (by + default the same as \almacp{AlCapSty}). (see \autoref{sec:captionsty} for more explanations and details) +\item[\Almacp{ProcFnt}{$<$text$>$}] sets $<$text$>$ in procedure typography of procedure and function environment (by + default the same as \almacp{AlCapFnt}). (see \autoref{sec:captionsty} for more explanations and details) +\item[\Almacp{ProcArgSty}{$<$text$>$}] sets $<$text$>$ in argument style of procedure and function environment + (by default the same as \almacp{AlCapNameSty}). (see \autoref{sec:captionsty} for more explanations and details) +\item[\Almacp{ProcArgFnt}{$<$text$>$}] sets $<$text$>$ in argument typography of procedure and function environment + (by default the same as \almacp{AlCapNameFnt}). (see \autoref{sec:captionsty} for more explanations and details) +\item[\Almacp{BlockMarkersSty}{$<$text$>$}] sets $<$text$>$ in block markers typography + (by default the same as \almacp{KwSty}) (see \autoref{sec_styleoptions} for more + explanations and details on block markers). \end{description} \subsubsection{caption and title font style} \label{sec:captionsty} -\almac{AlCapSty}, \almac{AlCapNameSty}, \almac{AlCapFnt}, \almac{AlCapNameFnt} and corresponding +\almac{AlCapSty}, \almac{AlCapNameSty}, \almac{AlCapFnt}, \almac{AlCapNameFnt}, \almac{ProcSty}, \almac{ProcFnt}, +\almac{ProcNameSty}, \almac{ProcNameFnt}, \almac{ProgArgSty}, \almac{ProgArgFnt} and corresponding ``\texttt{$\backslash$Set} commands'' (see \autoref{sec:setcaptionfntsty}) \almac{SetAlCapSty}, -\almac{SetAlCapNameSty}, \almac{SetAlCapFnt}, \almac{SetAlCapNameFnt} control the way caption is -printed. \almac{AlCapSty} and \almac{AlCapFnt} are used to define style and font shape of ``\texttt{Algorithm - \#:}'' in caption. \almac{AlCapNameSty} and \almac{AlCapNameFnt} are used to define style and font shape of the -caption text. In fact a caption \almacp{my algorithm} is printed as follow :\\ -\almacp{AlCapSty}{\almacp{AlCapFnt}{Algorithm \#:}}\almacp{AlCapNameSty}{\almacp{AlCapNameFnt}{my algorithm}}.\\ +\almac{SetAlCapNameSty}, \almac{SetAlCapFnt}, \almac{SetAlCapNameFnt}, \almac{SetProcSty}, \almac{SetProcFnt}, +\almac{SetProcNameSty}, \almac{SetProcNameFnt}, \almac{SetProgArgSty}, \almac{SetProgArgFnt} control the way +caption of algorithm and procedure/function environment are printed. + +\almac{AlCapSty} and \almac{AlCapFnt} are used to define style and font shape of ``\texttt{Algorithm \#:}'' in +caption. \almac{AlCapNameSty} and \almac{AlCapNameFnt} are used to define style and +font shape of the caption text. In fact a caption \almacp{caption}{my algorithm} is printed as follow :\medskip + +\noindent\almacp{AlCapSty}{\almac{AlCapFnt} Algorithm \#:}\almacp{AlCapNameSty}{\almac{AlCapNameFnt} my algorithm}. +\medskip + By default, \almac{AlCapSty} is \texttt{textbf} and \almac{AlCapFnt} is nothing. \almac{AlCapNameSty} keeps text as it is, and \almac{AlCapNameFnt} do nothing. + +\almac{ProcSty} and \almac{ProcFnt} are used to define style and font shape of ``\texttt{Procedure}'' in caption of +procedure and function environment. \almac{ProcNameSty} and \almac{ProcNameFnt} are used to define style and font +shape of the procedure or function name. \almac{ProcArgSty} and \almac{ProgArgFnt} are used to define style and +font shape of arguments in procedure/function environment. In fact a caption \almacp{caption}{Proc(int i)} of +procedure/function environment is printed as follow :\medskip + +\noindent\almacp{ProcSty}{\almac{ProcFnt} Procedure}\almacp{ProcNameSty}{\almac{ProcNameFnt} Proc(}\%\\% +\almacp{ProgArgSty}{\almac{ProgArgFnt} int i}\almacp{ProcNameSty}{\almac{ProcNameFnt} )}.\medskip + +By default, \almac{ProcSty} is \almac{AlCapSty} and \almac{ProcFnt} is \almac{AlCapFnt}. \almac{ProcNameSty} keeps text as +it is, and \almac{ProcNameFnt} do nothing. + \begin{description} \item[\Almacp{AlCapSty}{$<$text$>$}] sets $<$text$>$ in caption title typography, that is the same used, together with \almac{AlCapFnt}, to print \texttt{Algorithm \#:}, more precisely it is printed as follow:\\ - \almacp{AlCapSty}{\almacp{AlCapFnt}{Algorithm \#:}}\\ + \almacp{AlCapSty}{\almac{AlCapFnt} Algorithm \#:}\\ which gives actually ``\AlCapSty{\AlCapFnt Algorithm \#:}''. By default \almac{AlCapSty} is \texttt{textbf}. \item[\Almacp{AlCapNameSty}{$<$text$>$}] sets $<$text$>$ in caption name typography, that is the same used, together with \almac{AlCapNameFnt} to print the name of caption you set by calling \almacp{caption}{name}. More precisely it is printed as follow:\\ - \almacp{AlCapNameSty}{\almacp{AlCapNameFnt}{name}}\\ + \almacp{AlCapNameSty}{\almac{AlCapNameFnt} name}\\ which gives ``\AlCapNameSty{\AlCapNameFnt name}''. By default \almac{AlCapNameSty} is \texttt{textnormal} which means print in standard text. \item[\Almacp{AlCapFnt}{$<$text$>$}] sets $<$text$>$ in font shape of caption title, that is the same used, together with \almac{AlCapSty}, to print \texttt{Algorithm \#:}, more precisely it is printed as follow:\\ - \almacp{AlCapSty}{\almacp{AlCapFnt}{Algorithm \#:}}\\ + \almacp{AlCapSty}{\almac{AlCapFnt} Algorithm \#:}\\ which gives actually ``\AlCapSty{\AlCapFnt Algorithm \#:}''. By default \almac{AlCapFnt} is \almac{relax} which means keep text as it is. \item[\Almacp{AlCapNameFnt}{$<$text$>$}] sets $<$text$>$ in caption name typography, that is the same used, together with \almac{AlCapNameSty} to print the name of caption you set by calling \almacp{caption}{name}. More precisely it is printed as follow:\\ - \almacp{AlCapNameSty}{\almacp{AlCapNameFnt}{name}}\\ + \almacp{AlCapNameSty}{\almac{AlCapNameFnt} name}\\ which gives ``\AlCapNameSty{\AlCapNameFnt name}''. By default \almac{AlCapNameFnt} is \almac{relax} which means keep text as it is. \medskip +\item[\Almacp{ProcSty}{$<$text$>$}] sets $<$text$>$ in procedure/function caption title typography, that is the + same used, together with \almac{ProcFnt}, to print \texttt{Procedure}, more precisely it is printed as follow:\\ + \almacp{ProcSty}{\almac{ProcFnt} Procedure}\\ + which gives actually ``\ProcSty{\ProcFnt Procedure}''. By default \almac{ProcSty} is \almac{AlCapSty}. +\item[\Almacp{ProcNameSty}{$<$text$>$}] sets $<$text$>$ in procedure name typography, that is the same used, + together with \almac{ProcNameFnt} to print the name of caption you set by calling \almacp{caption}{Proc(int + i)}. More precisely it is printed as follow:\\ + \almacp{ProcNameSty}{\almac{ProcNameFnt} Proc(}\\ + which gives ``\ProcNameSty{\ProcNameFnt Proc(}''. By default \almac{ProcNameSty} is \almac{AlCapNameSty} which + means print in standard text. +\item[\Almacp{ProcArgSty}{$<$text$>$}] sets $<$text$>$ in argument of procedure/function typography, that is the + same used, together with \almac{ProcArgFnt}, to print \texttt{int i} if \almacp{caption}{Proc(int i)} was + called. More precisely it is printed as follow:\\ + \almacp{ProcArgSty}{\almac{ProcArgFnt} int i}\\ + which gives actually ``\ProcArgSty{\ProcArgFnt int i}''. By default \almac{ProcArgSty} is \almac{AlCapNameSty}; +\item[\Almacp{ProcFnt}{$<$text$>$}] sets $<$text$>$ in font shape of caption title, that is the same used, + together with \almac{ProcSty}, to print \texttt{Procedure}, more precisely it is printed as follow:\\ + \almacp{ProcSty}{\almac{ProcFnt} Procedure}\\ + which gives actually ``\ProcSty{\ProcFnt Procedure}''. By default \almac{ProcFnt} is \almac{relax} which + means keep text as it is. +\item[\Almacp{ProcNameFnt}{$<$text$>$}] sets $<$text$>$ in procedure/function name typography, that is the same + used, together with \almac{ProcNameSty} to print the name of caption you set by calling \almacp{caption}{Proc(int + i)}. More precisely it is printed as follow:\\ + \almacp{ProcNameSty}{\almac{ProcNameFnt} Proc(}\\ + which gives ``\ProcNameSty{\ProcNameFnt Proc(}''. By default \almac{ProcNameFnt} is \almac{relax} which means + keep text as it is. +\item[\Almacp{ProcArgFnt}{$<$text$>$}] sets $<$text$>$ in font shape of argument of procedure/environment caption, + that is the same used, together with \almac{ProcArgSty}, to print \texttt{int i} if \almacp{caption}{int i} was + called. More precisely it is printed as follow:\\ + \almacp{ProcArgSty}{\almac{ProcFnt} int i}\\ + which gives actually ``\ProcArgSty{\ProcArgFnt int i}''. By default \almac{ProcArgFnt} do nothing. + +\medskip \item[\Almacp{AlTitleSty}{$<$text$>$}] is used to typeset ``\texttt{Algorithm \#:}'' in title, together with \almac{AlTitleFnt}. You can use it to have text as your titles. Precisely, titles are typeset as follow:\\ \almacp{AlTitleSty}{\almacp{AlTitleFnt}{Algorithm \#:}}. @@ -835,6 +1153,8 @@ Here is the complete list of these macros: default the same as \almacp{AlCapSty}). \item[\Almacp{SetProcArgSty}{$<$font$>$}] sets argument typography of procedure and function environment (by default the same as \almacp{AlCapNameSty}). +\item[\Almacp{SetBlockMarkersSty}{$<$font$>$}] sets block markers typography (by default + the same as \almacp{KwSty}). \end{description} \subsubsection{setting caption and title font style} @@ -855,10 +1175,15 @@ caption printed in large red font. The next commands allow to redefine \texttt{Sty} macros for caption or title. As ``\texttt{$\backslash$Set} commands'' of basic font style (see \autoref{sec:setfntsty}), they require a name of a command in argument, -this command have to take one argument, the text to be typeset. Examples of use: +this command have to take one argument, the text to be typeset. They should be combined +with previous commands to redefine display of caption or title. Examples of use: \begin{itemize} -\item $\backslash$\texttt{newcommand\{}$\backslash$\texttt{mycapfn\}[1]\{}$\backslash$\texttt{tiny \#1\}}\almacp{SetAlCapNameFnt}{mycapfnt} -\item $\backslash$\texttt{newcommand\{}$\backslash$\texttt{mycapfn\}[1]\{}$\backslash$\texttt{textsl\{}$\backslash$\texttt{small \#1\}\}}\almacp{SetAlCapNameFnt}{mycapfnt} +\item + $\backslash$\texttt{newcommand\{}$\backslash$\texttt{mycapsty\}[1]\{}$\backslash$\texttt{textbf\{}$\backslash$\texttt{emph\{\#1\}\}\}}\almacp{SetAlCapNameSty}{mycapsty}\\ + caption will be print emphased and in bold face. +\item \almacp{SetAlCapNameFnt}{$\backslash$tiny} set font to tiny size. +\item if you combine $\backslash$SetAlCapNameSty\{mycapsty\} and + $\backslash$SetAlCapNameFnt\{$\backslash$tiny\} will give tiny bold empased caption. \end{itemize} Now the commands: @@ -950,7 +1275,15 @@ the last example above can be define in a simplier way that previously presented \item[\almacp{SetAlgoNlRelativeSize}{number}] sets the relative size of line number (see \autoref{sec:linenumbering}) for more details on this command. \item[\almacp{SetAlgoCaptionLayout}{style}] sets the global style of caption (see \autoref{sec:titlemacros} for - more details). + more details). +\item[\Almac{DisplayBlockMarkers}] acts like \optblockmarkers option: each block will be + started by a \emph{begin} keyword and be ended by an \emph{end} keywords. This is tricky + to use but allows to customize syntax to match almost every language (see + \autoref{code:exgeneric} for examples showing how to use + it). \Almacpp{SetAlgoBlockMarkers}{begin keyword}{end keyword} defines \emph{begin} and + \emph{end} keywords that will be used by \verb+\DisplayBlockMarkers+. Default keywords + are \textbf{begin} and \textbf{end}. but for example you can set + \verb+\DisplayBlockMarkers{\{}{\}}+ to match c-style syntax. \end{description} Some length are used to set the layout of ruled, algoruled and boxruled algorithms caption. These length have no @@ -958,7 +1291,7 @@ particular macro to set them but can be changed by classical \almac{setlength} c \begin{description} \item[interspacetitleruled] (2pt by defaut) which controls the vertical space between rules and title in ruled and algoruled algorithms. -\item[interspaceboxruled] (2\almac{lineskip} by default) which controls the vertical space between rules and title in +\item[interspacetitleboxruled] (2\almac{lineskip} by default) which controls the vertical space between rules and title in boxruled algorithms. \end{description} @@ -1005,6 +1338,7 @@ are defined using macros provided by the package and described in \autoref{sec_deflanguage}. %\subsection{english keywords} +\RestyleAlgo{boxed} %---------- \subsection{Input, output macros...}\label{sec:inputmacros} @@ -1060,7 +1394,7 @@ are defined using macros provided by the package and described in example\}\macind{tcp*[f]}: comment ``à la'' C++ \end{itemize} -You can see some examples of this macros with \texttt{if then else} at the end of \autoref{sec:ifthenelsemacros}. +You can see some examples of this macros with \texttt{if then else} at the end of \autoref{sec:defifthenelsemacros} %---------- \subsection{if-then-else macros} @@ -1089,6 +1423,8 @@ You can see some examples of this macros with \texttt{if then else} at the end o \item $\backslash$eIf(\textit{then comment})\{condition\}\{then block\}(\textit{else comment})\{else block\}\macind{eIf} \item $\backslash$eIf(\textit{then comment})\{condition\}\{then block\}\{else block\}\macind{eIf} \item $\backslash$eIf\{condition\}\{then block\}(\textit{else comment})\{else block\}\macind{eIf} +\item $\backslash$leIf\{condition\}\{then block\}\{else block\}\macind{eIf} +\item $\backslash$leIf(\textit{comment})\{condition\}\{then block\}\{else block\}\macind{eIf} \end{itemize} %---------- @@ -1167,7 +1503,7 @@ You can see some examples of this macros with \texttt{if then else} at the end o \item \almacppp{SetKwComment}{tcc}{/*}{*/}\par \almacppp{SetKwComment}{tcp}{//}{} \item \almacphuit{SetKwIF}{If}{ElseIf}{Else}{if}{then}{else if}{else}{endif} -\item {\small \almacphuit{SetKwSwitch}{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{endsw}} +\item {\small\almacphuit{SetKwSwitch}{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{endcase}\texttt{endsw}} \item \almacpppp{SetKwFor}{For}{for}{do}{endfor}\par \almacpppp{SetKwFor}{While}{while}{do}{endw}\par \almacpppp{SetKwFor}{ForEach}{foreach}{do}{endfch}\par @@ -1204,33 +1540,27 @@ package with your own. %---------- \subsection{to define basic keywords or blocks}\label{sec:defbasickeywords} -\begin{description} +\begin{description}\RestyleAlgo{plain} \item[\Almacpp{SetKw}{Kw}{thetext}] defines the macro \almac{Kw} which defines a keyword \emph{thetext} and prints it in keyword - typography. It can take one argument: $backslash$Kw\{arg\}. If so, - \emph{arg} is printed in argument typography. + typography. It can take one argument: $\backslash$Kw\{arg\}. If so, + \emph{arg} is printed in argument typography. For example \verb+\Kw{thetext}+ + could give: \KwSty{Kw} \ArgSty{thetext} +\item[\Almacpp{SetKwHangingKw}{Kw}{thetext}] defines a hanging keyword that should act + like a combination of \almac{SetKwInput} and \almac{SetKw}. In comparison with + $\backslash$SetKwInput, it doesn't print ':' at end of keyword and line is numbering if + \optlinesnumbered is set.\\ + For example \verb+\SetKwHangingKw{HData}{Data$\rightarrow$}+ could gives:\par\vspace{-.5ex} + \begin{algorithm}[H] + \KwHData{a list of data and a long description of this data to be sure that text requires several lines to be printed} + \end{algorithm}\vspace{-1ex} \item[\Almacpp{SetKwData}{Kw}{thetext}] defines the macro \almacp{Kw} which defines a data text. Prints \emph{thetext} in data typography. Note that this macros can takes one argument as function macros. -\item[\Almacpp{SetKwHangingKw}{name}{text}] (hanging indent with keyword): This creates a hanging indent much like - \Almac{SetKwInput}, except that it removes the trailing `:' and does not reset numbering. It can be used for - example to create \textbf{let} declarations. -\begin{verbatim} - text -------------- <= [text] is placed at left - -------------- <= hanging determined by [text] -\end{verbatim} -% \item[\Almacppp{SetKwInParam}{Kw}{text1}{text2}] defines the macro -% \almacpp{Kw}{name}{arg} which prints \emph{name} followed by -% \emph{text1} in key word typography, behind the argument \emph{arg}, -% followed by \emph{text2} in key word typography. Typically used when -% the algorithm described a function in order to define a macro which -% allows to give the name of the function and to show its arguments. -% Note that \emph{arg} will be shifted so that all the text is -% vertically aligned and to the right of -% \emph{text1}.\\ -% Example $\backslash$SetKwInParam\{Func\}\{(\}\{)\} defines macro -% $\backslash$Func and $\backslash$Func\{function\}\{arg1, arg2, arg3\} -% gives \KwSty{function(}arg1, arg2, arg3\KwSty{)}. +\item[\Almacpp{SetKwArray}{Kw}{array}] which defines an array keywords \texttt{Kw} called \emph{array} and printed + in DataSty style when call with $\backslash$\texttt{Kw}. It can be used with one argument which denotes the + element index: $\backslash$\texttt{Kw}\{n\} prints \DataSty{array[}\ArgSty{n}\DataSty{]} with \emph{array} in + \Almac{DataSty} and \emph{n} in \Almac{ArgSty}. \item[\Almacppp{SetKwBlock}{Begin}{begin}{end}] defines a macro \almacp{Begin}{txt} which denotes a block. The text is surrounded by the words \emph{begin} and \emph{end} in keyword typography and @@ -1238,7 +1568,17 @@ package with your own. \almac{Line}\emph{ mode} a straight vertical line is added.\\ \verb+\Begin(side text){text}+ gives also text in a block surrounded by \emph{begin} and \emph{end}, but \emph{side text} if put after the \emph{begin} keyword. Combined with - \Almac{tcc*[f]} macro, it allows you to put comments on the same line as \emph{begin}. + \Almac{tcc*[f]} macro, it allows you to put comments on the same line as + \emph{begin}.\par + You can also use alternativ \almacp{uBegin}{txt} which acts as \almacp{Begin}{txt} but + without \emph{end}. Useful for example as a part separator that doesn't necessary need + an \emph{end} keyword. +\item[\Almacpppp{SetKwProg}{Prog}{Title}{is}{end}] Env is a block with 'Title' (in + \texttt{CapSty} style) at the beginning followed by args followed by '\texttt{is}' then + '\texttt{text}' inside a block ended by '\texttt{end}'. If no '\texttt{end}' is + specified, nothing is written (no blank line is inserted). Useful to typeset function or + prog. For example:\par + \noindent\ExampleOfAlgo{algorithm2e_exProg.tex}\par \end{description} \subsection{to define keywords as function} @@ -1275,7 +1615,7 @@ If you want describe the function by an algorithm, use instead \emph{function} o \label{sec:defcommentsmacros} \begin{description} -\item[\Almacppp{SetKwComment}{Comment}{start}{end}] defines a macr +\item[\Almacppp{SetKwComment}{Comment}{start}{end}] defines a macro \almacp{Comment}{text comment} which writes \emph{text comment} between \emph{start} and \emph{end}. Note that \emph{start} or \emph{end} can be empty.\\ @@ -1295,26 +1635,39 @@ If you want describe the function by an algorithm, use instead \emph{function} o \label{sec:defifthenelsemacros} \begin{description} -\item[\almacphuit{SetKwIF}{If}{ElseIf}{Else}{if}{then}{else if}{else}{endif}] +\item[\Almacphuit{SetKwIF}{If}{ElseIf}{Else}{if}{then}{else if}{else}{endif}] defines several macros to give the opportunity to write all if-then-else-elseif-endif possibilities: \begin{itemize} \item \almacpp{If}{cond}{Then's text}\\ Then's text is writen in a block (below \texttt{then} and on several lines) and terminating by the \texttt{endif} given in the last argument. + \item \almacpp{If(comment)}{cond}{Then's text}\\ + as previous but put \emph{comment} after \texttt{then} keyword. Usually use with + comment macro like \almac{tcc}*[f]\{comment\} or \almac{tcp}*[f]\{comment\} \item \almacp{ElseIf}{ElseIf's text}\\ ElseIf's text is writen in a block and terminating by the \texttt{endif}. + \item \almacp{ElseIf(comment)}{ElseIf's text}\\ + the same with comment. \item \almacp{Else}{Else's text}\\ Else's text is writen in a block and terminating by the \texttt{endif}. + \item \almacp{Else}{Else's text}\\ + the same with comment. \item \almacpp{lIf}{cond}{Then's text}\\ Then's text is written on the same line as \texttt{then}. No \texttt{endif} - is printed. + is printed. Do not put $\backslash$; after \emph{Then's text} neither after \almac{lIf}. + \item \almacpp{lIf(comment)}{cond}{Then's text}\\ + the same with comment. \item \almacp{lElseIf}{ElseIf's text}\\ ElseIf's text is written on the same line as \texttt{else if}. No \texttt{endif} is printed. + \item \almacp{lElseIf(comment)}{ElseIf's text}\\ + the same with comment. \item \almacp{lElse}{Else's text}\\ Else's text is written on the same line as \texttt{else}. No \texttt{endif} is printed. + \item \almacp{lElse(comment)}{Else's text}\\ + the same with comment. \item \almacpp{uIf}{cond}{Then's text} (for uncomplete if)\\ defines a If block unterminated like in a \almac{eIf} block, i.e. don't print the \texttt{endif} or don't put the little @@ -1335,10 +1688,16 @@ If you want describe the function by an algorithm, use instead \emph{function} o % \lElse{else in one line}\; % \end{algorithm} % \end{minipage} + \item \almacpp{uIf(comment)}{cond}{Then's text}\\ + the same with comment. \item \almacp{uElseIf}{ElseIf's text} (for uncomplete elseif)\\ Same explanation as for \almac{uIf} but with \texttt{else if}. + \item \almacp{uElseIf(comment)}{ElseIf's text}\\ + the same with comment. \item \almacp{uElse}{Else's text} (for uncomplete else)\\ Same explanation as for \almac{uElseIf} but with \texttt{else}. + \item \almacp{uElse}{Else's text}\\ + the same with comment. \item \almacppp{eIf}{cond}{Then's text}{Else's text}\\ equivalent to the use of \almac{uIf} followed by \almac{Else}. \end{itemize} @@ -1373,16 +1732,22 @@ in the package:\par\smallskip \ExampleOfAlgo{algorithm2e_ex01.tex}\par---\par \label{sec:defswitchmacros} \begin{description} -\item[\Almacphuit{SetKwSwitch}{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{endsw}] +\item[\Almacphuit{SetKwSwitch}{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{endcase}\texttt{endsw}] defines several macros to give a complete Switch-do-case-otherwise environment: \begin{itemize} \item \almacpp{Switch}{iden}{switch's block} - \item \almacpp{Case}{cond}{Case's text} - \item \almacpp{uCase}{cond}{Case's text} + \item \almacpp{Switch(comment)}{iden}{switch's block} + \item \almacpp{Case}{cond}{Case's block} + \item \almacpp{Case(comment)}{cond}{Case's block} + \item \almacpp{uCase}{cond}{Case's block} + \item \almacpp{uCase(comment)}{cond}{Case's block} \item \almacpp{lCase}{cond}{Case's text} - \item \almacp{Other}{Otherwise's text} + \item \almacpp{lCase(comment)}{cond}{Case's text} + \item \almacp{Other}{Otherwise's block} + \item \almacp{Other(comment)}{Otherwise's block} \item \almacp{lOther}{Otherwise's text} + \item \almacp{lOther(comment)}{Otherwise's text} \end{itemize} \end{description} @@ -1402,7 +1767,9 @@ As for If-then-elseif-else-endif macro, you can use () to put comments after mai the loop. \begin{itemize} \item \almacpp{For}{loop's condition}{For's text} + \item \almacpp{For(comment)}{loop's condition}{For's text} \item \almacpp{lFor}{loop's condition}{For's text} + \item \almacpp{lFor(comment)}{loop's condition}{For's text} \end{itemize} \end{description} @@ -1420,7 +1787,11 @@ As for If-then-elseif-else-endif macro, you can use () to put comments after mai of the loop): \begin{itemize} \item \almacpp{Repeat}{end loop condition}{the loop} + \item \almacpp{Repeat(comment after repeat)}{end loop condition}{the loop} + \item \almacpp{Repeat}{end loop condition}{the loop}(comment after until) + \item \almacpp{Repeat(comment after repeat)}{end loop condition}{the loop}(comment after until) \item \almacpp{lRepeat}{end loop condition}{only one line} + \item \almacpp{lRepeat(comment)}{end loop condition}{only one line} \end{itemize} \end{description} @@ -1484,7 +1855,7 @@ Here we describe how they are obtained: \almacpp{SetKw}{Retour}{retourner} \item \almacppp{SetKwBlock}{Deb}{d\'ebut}{fin} \item \almacphuit{SetKwIF}{Si}{SinonSi}{Sinon}{si}{alors}{sinon si}{alors}{finsi} -\item {\footnotesize\almacphuit{SetKwSwitch}{Suivant}{Cas}{Autre}{suivant}{faire}{cas o\`u}{autres cas}{fin d'alternative}} +\item {\footnotesize\almacphuit{SetKwSwitch}{Suivant}{Cas}{Autre}{suivant}{faire}{cas o\`u}{autres cas}{fin cas}\texttt{fin d'alternative}} \item \almacpppp{SetKwFor}{Pour}{pour}{faire}{finpour}\par \item \almacpppp{SetKwFor}{Tq}{tant que}{faire}{fintq}\par \item \almacpppp{SetKwFor}{PourCh}{pour chaque}{faire}{finprch} @@ -1546,7 +1917,8 @@ Here we describe how they are obtained: \item \almacppp{SetKwBlock}{Beginn}{Beginn}{Ende}%Begin \item \almacppp{SetKwRepeat}{Wiederh}{wiederhole}{bis}%Repeat \item \almacphuit{SetKwIF}{Wenn}{SonstWenn}{Sonst}{wenn}{dann}{sonst wenn}{sonst}{Ende}%IF -\item \almacphuit{SetKwSwitch}{Unterscheide}{Fall}{Anderes}{unterscheide}{tue}{Fall}{sonst}{Ende.}%Switch +\item + \almacphuit{SetKwSwitch}{Unterscheide}{Fall}{Anderes}{unterscheide}{tue}{Fall}{sonst}{Ende Fall}\texttt{Ende.}%Switch \item \almacpppp{SetKwFor}{Fuer}{f\"ur}{tue}{Ende}%For \item \almacpppp{SetKwFor}{FuerPar}{f\"ur}{tue gleichzeitig}{Ende}%ForPar \item \almacpppp{SetKwFor}{FuerJedes}{f\"ur jedes}{tue}{Ende}%ForEach @@ -1607,7 +1979,7 @@ Here we describe how they are obtained: \almacpp{SetKw}{Retorna}{retorna}\par \item \almacppp{SetKwBlock}{Inicio}{in\'{i}cio}{fim}% \item \almacphuit{SetKwIF}{Se}{SenaoSe}{Senao}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim se}% -\item \almacphuit{SetKwSwitch}{Selec}{Caso}{Outro}{selecione}{fa\c{c}a}{caso}{sen\~{a}o}{fim selec}% +\item \almacphuit{SetKwSwitch}{Selec}{Caso}{Outro}{selecione}{fa\c{c}a}{caso}{sen\~{a}o}{fim caso}\texttt{fim selec}% \item \almacpppp{SetKwFor}{Para}{para}{fa\c{c}a}{fim para}% \item \almacpppp{SetKwFor}{ParaPar}{para}{fa\c{c}a em paralelo}{fim para} \item \almacpppp{SetKwFor}{ParaCada}{para cada}{fa\c{c}a}{fim para cada}% @@ -1670,7 +2042,7 @@ Here we describe how they are obtained: \item \almacppp{SetKwBlock}{Inizio}{inizio}{fine} \item \almacppp{SetKwRepeat}{Ripeti}{ripeti}{finché} \item \almacphuit{SetKwIF}{Sea}{AltSe}{Altrimenti}{se}{allora}{altrimenti se}{allora}{fine se} -\item \almacphuit{SetKwSwitch}{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{endsw} +\item \almacphuit{SetKwSwitch}{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{endcase}\texttt{endsw} \item \almacpppp{SetKwFor}{Per}{per}{fai}{fine per} \item \almacpppp{SetKwFor}{PerPar}{per}{fai in parallelo}{fine per} \item \almacpppp{SetKwFor}{PerCiascun}{per ciascun}{fai}{fine per ciascun} @@ -1704,7 +2076,7 @@ How they are obtained: \section{Known bugs}\label{sec_bugs} \begin{itemize} -\item no more known bugs actually; if you find one, please sent it to me. +\item no more known bugs actually; if you find one, please send it to me. \end{itemize} \clearpage @@ -1712,193 +2084,93 @@ How they are obtained: \section*{Release notes}\label{sec:relnotes} \begin{verbatim} -% - december 14 2009 - revision 4.01 -% * ADD : new command \SetKwHangingKw{Name}{text} (hanging indent with keyword): This creates a -% hanging indent much like \texttt{SetKwInput}, except that it removes the trailing `:' -% and does not reset numbering. -% - november 17 2009 - revision 4.00 - -% * CHANGE : IMPORTANT : some commands have been renamed to have consistent naming (CamlCase -% syntax) and old commands are no more available. If you doesn't want to change -% your mind or use old latex files, you can use oldcommands option to enable old -% commands back. -% text. Here are these commands: -% - \SetNoLine becomes \SetAlgoNoLine -% - \SetVline becomes \SetAlgoVlined -% - \Setvlineskip becomes \SetVlineSkip -% - \SetLine becomes \SetAlgoLined -% - \dontprintsemicolon becomes \DontPrintSemicolon -% - \printsemicolon becomes \PrintSemicolon -% - \incmargin becomes \IncMargin -% - \decmargin becomes \DecMargin -% - \setnlskip becomes \SetNlSkip -% - \Setnlskip becomes \SetNlSkip -% - \setalcapskip becomes \SetAlCapSkip -% - \setalcaphskip becomes \SetAlCapHSkip -% - \nlSty becomes \NlSty -% - \Setnlsty becomes \SetNlSty -% - \linesnumbered becomes \LinesNumbered -% - \linesnotnumbered becomes \LinesNotNumbered -% - \linesnumberedhidden becomes \LinesNumberedHidden -% - \showln becomes \ShowLn -% - \showlnlabel becomes \ShowLnLabel -% - \nocaptionofalgo becomes \NoCaptionOfAlgo -% - \restorecaptionofalgo becomes \RestoreCaptionOfAlgo -% - \restylealgo becomes \RestyleAlgo -% - gIf macros and so on do no more exist -% * NEW: - Compatibily with other packages improven by changing name of internal -% macros. Algorithm2e can now be used with arabtex for example, if this last is -% loaded after algorithm2e package. -% * ADD: - OPTION endfloat: endfloat packages doesn't allow float environment inside other -% environment. So using it with figure option of algorithm2e makes error. This -% option enables a new environment algoendfloat to be used instead of algorithm -% environment that put algorithm at the end. algoendfloat environment make -% algorithm acting as endfloat figures. This option requires endfloat packages. -% * ADD: - OPTION norelsize: starting from this release (v4.00), algorithm2e package uses -% relsize package in order to get relative size for lines numbers; but it seems -% that some rare classes (such as inform1.cls) are not compatible with relsize; to -% have algorithm2e working, this option makes algorithm2e not to load relsize -% package and go back to previous definition by using \scriptsize font for lines -% numbers. -% * ADD: - OPTION onelanguage: allow, if using standard keywords listed below, to switch -% from one language to another without changing keywords by using appropriate -% language option : -% . KwIn, KwOut, KwData, KwResult -% . KwTo KwFrom -% . KwRet, Return -% . Begin -% . Repeat -% . If, ElseIf, Else -% . Switch, Case, Other -% . For, ForPar, ForEach, ForAll, While -% . -% * ADD: - OPTION rightnl: put lines numbers to the right of the algorithm instead of left. -% * ADD: new commands \setRightLinesNumbers and \setLeftLinesNumbers which sets the lines -% numbers to the right or to the left of the algorithm. -% * ADD/FIX: rules of ruled, algoruled, tworuled styles used rules of different sizes! This -% is now fixed. Moreover size of the rules is now controlled by a length and so -% can be customized by the user. -% \algoheightrule is the height of the rules and can be changed via \setlength -% \algoheightruledefault is the default height of he rules (0.8pt) -% \algotitleheightrule is the height of the rule that comes just after the -% caption in ruled and algoruled style; it can be changed via \setlength -% \algotitleheightruledefault is the default height of this rules (0.8pt) -% Thanks to Philippe Dumas who reports the bug and make the suggestion. -% * ADD: - \SetAlgoCaptionSeparator which sets the separator between Algorithm 1 and the -% title. By default it's ':' and caption looks like "Algorithm 2: title" but now -% you can change it by using for example \SetAlgoCaptionSeparator{.} which will -% give "Algorithm 3. title" -% * ADD: - \SetAlgoLongEnd and \SetAlgoShortEnd and \SetAlgoNoEnd commands which act as -% corresponding package options -% * ADD: - OPTIONS italiano and slovak as new language (thanks to Roberto Posenato and -% Miroslav Binas) -% * ADD: - \AlCapSty, \AlCapNameSty, \AlCapFnt, \AlCapNameFnt and corresponding "set macro" -% \SetAlCapSty, \SetAlCapNameSty, \SetAlCapFnt, \SetAlCapNameFnt which control the -% way caption is printed. Sty macro use command taking one parameter as argument, -% Fnt macros use directly command. In Fact caption is printed as follow : -% \AlCapSty{\AlCapFnt Algorithm 1:}\AlCapNameSty{\AlCapNameFnt my algorithm} -% By default, \AlCapSty is textbf and \AlCapFnt is nothing. \AlCapNameSty keep text -% as it is, and \AlCapNameFnt do nothing also. -% You can redefine \AlCapFnt and \AlCapNameFnt by giving macro to \Set commands. For -% example, you can do \SetAlCapFnt{\large} to see Algorithm printed in \large font. -% You can redefine \AlCapSty, \AlCapFnt, \AlCapNameSty and \AlCapNameFnt with the -% corresponding \Set command. For the Sty commands, you have to give in parameter -% name of a macro (whithout \) which takes one argument. For example, -% \SetAlCapFnt{textbf} defines the default behaviour. If you want to do more -% complicated thing, you should define your own macro and give it to \SetAlCapFnt or -% \SetAlCapNameFnt. Here are two examples: -% - \newcommand{\mycapsty}[1]{\tiny #1}\SetAlCapNameSty{mycapsty} -% - \newcommand{\mycapsty}[1]{\textsl{\small #1}}\SetAlCapNameSty{mycapsty} -% Or you can combine the two, for the last example you can also do: -% \SetAlCapNameSty{textsl}\SetAlCapNameFnt{\small} -% Thanks to Jan Stilhammer who gives me the idea of \AlCapNameFnt. -% * CHANGE \AlTitleFnt to match definition of all other Fnt macros and add a \AlTitleSty -% macro (see below) . Now you set \AlTitleFnt by calling \SetAlTitleFnt with -% directly a macro without parameter in argument: -% Example: \SetAlTitleFnt{\small} to set title in small font. -% * ADD: - \AlTitleSty and \SetAlTitleSty commands to set a style for title. These commands -% are defined from a macro taking the text in argument, as \textbf for example. -% To set the TitleSty you have to give name of the macro (without the '\') -% to \SetAlTitleSty. For example \SetAlTitleSty{textbf} to set \textbf style. -% * ADD: - new command \SetAlgorithmName{algorithmname}{list of algorithms name} which -% redefines name of the algorithms and the sentence list of algorithms. Second -% argument is the name that \autoref, from hyperref package, will use. Example: -% \SetAlgorithmName{Protocol}{List of protocols} if you prefer protocol than -% algorithm. -% * ADD: - new \SetAlgoRefName{QXY} which change the default ref (number of the algorithm) by -% the name given in parameter (QXY in the example). -% * ADD: - new command \SetAlgoRefRelativeSize{-2} which sets the output size of refs, defined -% by \SetAlgoRefName, used in list of algorithms. -% * ADD: - two dimensions to control the layout of caption in ruled, algoruled and boxruled -% algorithms: -% - interspacetitleruled (2pt by defaut) which controls the vertical space between -% rules and title in ruled and algoruled algorithms. -% - interspaceboxruled (2\lineskip by default) which controls the vertical space -% between rules and title in boxruled algorithms. -% These two dimensions can be changed by using \setlength command. -% * ADD: - With the fix (see below) of procedure and function environments, a new feature has -% been added: the name of the procedure or function set in caption is automatically -% defined as a KwFunction and so can be used as a macro. For example, if inside a -% procedure environment you set \caption{myproc()}, you can use \myproc macro in you -% main text. Beware that the macro is only defined after the \caption! -% * ADD: - OPTION nokwfunc to unable the new feature described above in function and -% procedure environment. Useful if you use name of procedure or function that cannot -% be a command name as a math display for example. -% * ADD: - \SetAlgoNlRelativeSize{number} command which sets the relative size of line -% numbers. By default, line numbers are two size smaller than algorithm text. Use -% this macro to change this behavior. For example, \SetAlgoNlRelativeSize{0} sets it -% to the same size, \SetAlgoNlRelativeSize{-1} to one size smaller and -% \SetAlgoNlRelativeSize{1} to one size bigger -% * ADD: - \SetAlgoProcName{aname} command which sets the name of Procedure printed by -% procedure environment (the environment prints Procedure by default). Second -% argument is the name that \autoref, from hyperref package, will use. -% * ADD: - \SetAlgoFuncName{aname} command which sets the name of Function printed by -% procedure environment (the environment prints Function by default). Second -% argument is the name that \autoref, from hyperref package, will use. -% * ADD: - \SetAlgoCaptionLayout{style} command which sets style of the caption; style must -% be the name of a macro taking one argument (the text of the caption). Examples -% below show how to use it: -% . \SetAlgoCaptionLayout{centerline} to have centered caption -% . \SetAlgoCaptionLayout{textbf} to have bold caption -% If you want to apply two styles in the same time, such as centered bold, you have -% to define you own macro and then use \SetAlgoCaptionLayout with its name. -% * ADD: - OPTION procnumbered: which makes the procedure and function to be numbered as -% algorithm -% * ADD: - OPTIONS tworuled and boxruled -% these are two new layouts: tworuled acts like ruled but doesn't put a line after -% caption ; boxruled surround algorithm by a box, puts caption above and add a line -% after caption. -% * REMOVE: - SetKwInParam has been deleted since not useful itself because of different -% macros which can do the same in a better and a more consistent way as -% SetKwFunction or SetKw. -% * FIX: - line number is now correctly vertically aligned with math display. -% * FIX: - references with hyperref. No more same identifier or missing name error. BUT now -% you must NOT use naturalnames option of hyperref packages if you do PdfLaTeX -% * FIX: - autoref with hyperref package (thanks to Jörg Sommer who notices the problem). -% * FIX: - titlenumbered was not working! fixed. -% * FIX: - Else(){} acted like uElse. Corrected. -% * FIX: - noend management: when a block was inside another and end of block was following -% each other, a blank line was added: it's now corrected. -% * FIX: - Function and Procedure environment was no more working as defined originally: the -% label was no more name of the procedure, it acts always as if procumbered option -% has been used. -% * FIX: - line numbers had a fixed size which can be bigger than algorithm text accordingly -% to \AlFnt set (see also new command \SetAlgoNlRelativeSize above) -% * FIX: - semicolon in comments when dontprintsemicolon is used. -% * FIX: - listofalgorithms adds a vertical space before first algo of a chapter as for -% listoffigures or listoftables -% * FIX: - listofalgorithms with twocolumns mode and some classes which don't allow onecolumn -% and so don't define \if@restonecol as prescribed in LaTeX (sig-alternate for -% example) -% * FIX: - algorithm2e now works with elsart cls and some more classes. -% * FIX: - blocks defined by SetKwBlock act now as other blocks (if for instance) and don't -% write end in vlined mode, instead they print a small horizontal line as required -% by the option. -% * FIX: - underfull hbox warning at each end of algorithm environment removed. -% -% * INTERNAL CHANGE: - short end keyword are deduce from long end keyword by keeping the -% first one. Allows to avoid double definition. -% * INTERNAL CHANGE: - procedure, function and algorithm are now resolved by the same -% environment to avoid code duplication. +% - January 6 2013 - revision 5.0 +% * CHANGE: SetKwSwith takes now 9 args: 9th arg is the same as +% previous 8th arg ('end of switch' keyword). New 8th arg is +% 'end of case' keyword. This is due to change of release +% 3.2 which introduce end after case block... as I never +% test with longend option, I never see that the 'end +% switch' used for case was not good. +% * CHANGE: when no end keyword is defined in a block macro, then +% algorithm2e does no more try to print it. So even with lined or noline +% option, no empty line is printed (before: a blank end was +% printed, so a blank line appeared) +% * Internal Change: add some internal function to improve readibility +% (thanks to Philip K. F. H\ölzenspies) +% * ADD: Block markers. +% You can now ask package to put begin and end keywords automatically at begin +% and end of blocks, it means each group of commands shifted and enclosed in +% braces. +% This is tricky to use but, combined with \SetStartEndCondition and +% redefinition of keywords, you should be abble to simulate any syntax. See +% examples in documentation where a generic example is derived in pseudo-code, +% python and C by keeping code and changing only style using block markers +% macros, \SetStartEndCondition and some redefinition of keywords. +% These new block markers macros are: +% - \AlgoDisplayBlockMarkers and \AlgoDontDisplayBlockMarkers +% - \SetAlgoBlockMarkers{begin marker}{end marker} +% - \BlockMarkersSty{text} and \SetBlockMarkersSty +% Note that a new option has also been added: displayblockmarkers +% * ADD: \leIf macro automatically defined by \SetKw: allow to define +% an if-then-else on a single line. +% * ADD: new macro \SetStartEndCondition{typo1}{typo2}{typo3} which +% sets typo around condition in For, If, Switch, Case and +% Repeat macros. First two are used around For, If, Swith +% conditions, First and third are used for Case and Repeat +% condition. Default definition is \SetStartEndCondition{ }{ }{}. +% A common alternative is \SetStartEndCondition{ (}{) }{)} +% Can also be used to remove space around condition, for +% example if you want python style commands: +% \SetStartEndCondition{ }{}{} and \SetKwFor{For}{for}{:}{} +% * ADD: new environment algomathdisplay which allow display math (like inside \[ \] or $$ $$) +% handling end line and line number +% * ADD: new command \SetKwProg{Env}{Title}{is}{end} which defines a macro +% \Env{args}{text}. Env is a block with 'Title' (in \CapSty) at the beginning +% followed by args followed by 'is' then 'text' is put below inside a block ended +% by 'end'. If no 'end' is specified, nothing is written (no +% blank line is inserted). Useful to typeset function or prog for example: +% \SetKwProg{Fn}{Function}{is}{end} makes \Fn{afunc(i: int) : int}{return 0\;} +% writes: +% Function afunc(i: int) : int is +% | return 0; +% end +% or \SetKwProg{Def}{def}{:}{} makes \Def{afunc(i: int)}{return 0\;} writes: +% def afunc(i: int): +% | return 0 +% Tip: combine it with \SetKwFunction to write recursive function algorithm. With +% example above, you could define \SetKwFunction{\Afunc}{afunc} and then write: +% Def{\Afunc{i:int}{\eIf{i>0}{\KwRet \Afunc{i-1}}{\KwRet 0\;}} that writes: +% def afunc(i: int): +% | if(i>0): +% | return afunc(i-1) +% | else: +% | return 0 +% with appropriate typo. +% * ADD: option croatian: croation keywords (thanks to Ivan Gavran) +% * ADD: option ngerman: same as german option but so can be used with global option ngerman +% of babel +% * ADD: option spanish: Spanish support (thanks to Mario Abarca) +% * ADD: unterminated block: useful to add part separator that doesn't necessary need an end +% keyword. +% Designed on the pattern of unterminated if (see \uIf macro) allowing to +% add a block that is not terminated by a keyword. Such block are defined in the same +% time as a block is defined by adding a macro beginning with u. So, for example, +% predefined \SetKwBlock{Begin}{begin}{end} defines now two commands: +% - \Begin{} as previously which print a begin - end block +% - \uBegin{} that defines a begin only block +% * FIX: dotocloa option which was broken +% * FIX: uIf and uCase didn't have same behavior when used with +% noline, vlined or lined option. This is fixed. Side effect: no empty +% line after an uIf or uCase when used with options lined or vlined +% * FIX: a bug with Repeat Until command when use with side comment on Until +% * FIX: a bug with side text -- text put into () -- of command macro (SetKwIf and so on) +% which was always setting a ';' even after a \DontPrintSemicolon +% * FIX: a bug with hyperref and chapter definition (thanks to Hubert Meier) +% * FIX: bugs with l macro and side comment +% * FIX: revision number +% * FIX: fix non ascii character (utf8 not yet recognized by all latex engine) +% * FIX: fnum@algocf had an useless parameter which sometimes broke expansion and output an error +% * FIX: works now with multicol package \end{verbatim} \clearpage diff --git a/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e_ex04.tex b/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e_ex04.tex index 0e0b00fbcaf..2d586a01c9d 100644 --- a/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e_ex04.tex +++ b/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e_ex04.tex @@ -1 +1,2 @@ -\lIf{cond4}{ok} \lElse{wrong}\;
\ No newline at end of file +\lIf{cond4}{ok} \lElse{wrong} +\leIf{cond4}{ok}{wrong} diff --git a/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e_ex05.tex b/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e_ex05.tex index 6ee3f6f29ad..7db5f9d2492 100644 --- a/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e_ex05.tex +++ b/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e_ex05.tex @@ -1,5 +1,5 @@ \SetAlgoVlined -\lIf{cond5}{cond5 true}\; +\lIf{cond5}{cond5 true} \uElseIf{cond51}{ cond 5 false\; but cond51 true\; diff --git a/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e_exProg.tex b/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e_exProg.tex new file mode 100644 index 00000000000..10428c08629 --- /dev/null +++ b/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e_exProg.tex @@ -0,0 +1,6 @@ +\SetAlgoLined +\SetKwProg{Fn}{Function}{ is}{end} +\Fn{afunc(i: int) : int}{return 0\;} + +\SetKwProg{Def}{def}{:}{} +\Def{afunc(i: int)}{return 0\;}
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e_exgeneric.tex b/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e_exgeneric.tex new file mode 100644 index 00000000000..dc8c53d49bc --- /dev/null +++ b/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e_exgeneric.tex @@ -0,0 +1,36 @@ +\Fn(\tcc*[h]{algorithm as a recursive function}){\FRecurs{some args}}{ + \KwData{Some input data\\these inputs can be displayed on several lines and one + input can be wider than line's width.} + \KwResult{Same for output data} + \tcc{this is a comment to tell you that we will now really start code} + \If(\tcc*[h]{a simple if but with a comment on the same line}){this is true}{ + we do that, else nothing\; + \tcc{we will include other if so you can see this is possible} + \eIf{we agree that}{ + we do that\; + }{ + else we will do a more complicated if using else if\; + \uIf{this first condition is true}{ + we do that\; + } + \uElseIf{this other condition is true}{ + this is done\tcc*[r]{else if} + } + \Else{ + in other case, we do this\tcc*[r]{else} + } + } + } + \tcc{now loops} + \For{\forcond}{ + a for loop\; + } + \While{$i<n$}{ + a while loop including a repeat--until loop\; + \Repeat{this end condition}{ + do this things\; + } + } + They are many other possibilities and customization possible that you have to + discover by reading the documentation. +} diff --git a/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e_exswitch.tex b/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e_exswitch.tex index c40b26c46fa..bce9a19ab4e 100644 --- a/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e_exswitch.tex +++ b/Master/texmf-dist/doc/latex/algorithm2e/algorithm2e_exswitch.tex @@ -3,7 +3,7 @@ do this\; do that\; } - \lCase{another value}{one line}\; + \lCase{another value}{one line} \Case{last value}{ do this\; break\; diff --git a/Master/texmf-dist/tex/latex/algorithm2e/algorithm2e.sty b/Master/texmf-dist/tex/latex/algorithm2e/algorithm2e.sty index 4377fa87fdf..c2ebe93dc01 100644 --- a/Master/texmf-dist/tex/latex/algorithm2e/algorithm2e.sty +++ b/Master/texmf-dist/tex/latex/algorithm2e/algorithm2e.sty @@ -1,6 +1,6 @@ % algorithm2e.sty --- style file for algorithms % almost everything can be customized by users. See the document for more explanations -%% Copyright 1996-2008 Christophe Fiorio +%% Copyright 1996-2013 Christophe Fiorio % % This program may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.2 @@ -17,7 +17,7 @@ % - algorithm2e-discussion@lirmm.fr mailing list for discussion about package^^J% % subscribe by emailing sympa@lirmm.fr with 'subscribe <list> <firstname name>'^^J% % -% $Id: algorithm2e.sty,v 4.1 2009/12/15 08:54:08 cfiorio Exp $ +% $Id: algorithm2e.sty,v 5.0 2013/01/06 14:40:35 cfiorio Exp $ % % PACKAGES REQUIRED: % @@ -26,14 +26,14 @@ % - xspace (in packages/tools) % - relsize (in contrib/misc/relsize.sty) % -%%%%%%%%%%%%%%% Release 4.01 +%%%%%%%%%%%%%%% Release 5.0 % % Package options: % --------------- % - oldcommands : to use old command names -% - french, english, german, -% portuguese, czech, italiano, -% slovak : for the name of the algorithm and some keyword code +% - french, english, german, ngerman +% portuguese, czech, italiano, +% slovak, croatian, spanish : for the name of the algorithm and some keyword code % - onelanguage : to simply switch keyword from one language to another without changing % keyword commands % - boxed, boxruled, ruled, tworuled, @@ -59,6 +59,7 @@ % - procnumbered : procedure or function are numbered as algorithm % - nokwfunc : procedure or function name doens't become a command % - norelsize : don't use relsize package (useful if it breaks the compatibily) +% - displayblockmarkers : display begin, end keywords at start of each block % % defaults are; english,plain,resetcount,titlenotnumbered % @@ -148,41 +149,132 @@ % % History: % -% - december 14 2009 - revision 4.01 -% * ADD : new command \SetKwHangingKw{Name}{text} (hanging indent with keyword): This creates a -% hanging indent much like \texttt{SetKwInput}, except that it removes the trailing `:' -% and does not reset numbering. +% - January 06 2013 - revision 5.0 +% * CHANGE: SetKwSwith takes now 9 args: 9th arg is the same as +% previous 8th arg ('end of switch' keyword). New 8th arg is +% 'end of case' keyword. This is due to change of release +% 3.2 which introduce end after case block... as I never +% test with longend option, I never see that the 'end +% switch' used for case was not good. +% * CHANGE: when no end keyword is defined in a block macro, then +% algorithm2e does no more try to print it. So even with lined or noline +% option, no empty line is printed (before: a blank end was +% printed, so a blank line appeared) +% * Internal Change: add some internal function to improve readibility +% (thanks to Philip K. F. H\ölzenspies) +% * ADD: Block markers. +% You can now ask package to put begin and end keywords automatically at begin +% and end of blocks, it means each group of commands shifted and enclosed in +% braces. +% This is tricky to use but, combined with \SetStartEndCondition and +% redefinition of keywords, you should be abble to simulate any syntax. See +% examples in documentation where a generic example is derived in pseudo-code, +% python and C by keeping code and changing only style using block markers +% macros, \SetStartEndCondition and some redefinition of keywords. +% These new block markers macros are: +% - \AlgoDisplayBlockMarkers and \AlgoDontDisplayBlockMarkers +% - \SetAlgoBlockMarkers{begin marker}{end marker} +% - \BlockMarkersSty{text} and \SetBlockMarkersSty +% Note that a new option has also been added: displayblockmarkers +% * ADD: \leIf macro automatically defined by \SetKwIF: allow to define +% an if-then-else on a single line. +% * ADD: new macro \SetStartEndCondition{typo1}{typo2}{typo3} which +% sets typo around condition in For, If, Switch, Case and +% Repeat macros. First two are used around For, If, Swith +% conditions, First and third are used for Case and Repeat +% condition where condition ends the line. Default definition +% is \SetStartEndCondition{ }{ }{}. +% A common alternative is \SetStartEndCondition{ (}{) }{)} +% Can also be used to remove space around condition, for +% example if you want python style commands: +% \SetStartEndCondition{ }{}{} and \SetKwFor{For}{for}{:}{} +% * ADD: new environment algomathdisplay which allow display math (like inside \[ \] or $$ $$) +% handling end line and line number +% * ADD: new command \SetKwProg{Env}{Title}{is}{end} which defines a macro +% \Env{args}{text}. Env is a block with 'Title' (in \CapSty) at the beginning +% followed by args followed by 'is' then 'text' is put below inside a block ended +% by 'end'. If no 'end' is specified, nothing is written (no +% blank line is inserted). Useful to typeset function or prog for example: +% \SetKwProg{Fn}{Function}{is}{end} makes \Fn{afunc(i: int) : int}{return 0\;} +% writes: +% Function afunc(i: int) : int is +% | return 0; +% end +% or \SetKwProg{Def}{def}{:}{} makes \Def{afunc(i: int)}{return 0\;} writes: +% def afunc(i: int): +% | return 0 +% Tip: combine it with \SetKwFunction to write recursive function algorithm. With +% example above, you could define \SetKwFunction{\Afunc}{afunc} and then write: +% \Def{\Afunc{i:int}{\eIf{i>0}{\KwRet \Afunc{i-1}}{\KwRet 0\;}} that writes: +% def afunc(i: int): +% | if(i>0): +% | return afunc(i-1) +% | else: +% | return 0 +% with appropriate typo. +% * ADD: option croatian: croation keywords (thanks to Ivan Gavran) +% * ADD: option ngerman: same as german option but so can be used with global option ngerman +% of babel +% * ADD: option spanish: Spanish support (thanks to Mario Abarca) +% * ADD: unterminated block: useful to add part separator that doesn't necessary need an end +% keyword. +% Designed on the pattern of unterminated if (see \uIf macro) allowing to +% add a block that is not terminated by a keyword. Such block are defined in the same +% time as a block is defined by adding a macro beginning with u. So, for example, +% predefined \SetKwBlock{Begin}{begin}{end} defines now two commands: +% - \Begin{} as previously which print a begin - end block +% - \uBegin{} that defines a begin only block +% * FIX: problem when numbering line inside until condition of +% \SetKwRepeat macro: line number was not correctly aligned. +% * FIX: dotocloa option which was broken +% * FIX: uIf and uCase didn't have same behavior when used with +% noline, vlined or lined option. This is fixed. Side effect: no empty +% line after an uIf or uCase when used with options lined or vlined +% * FIX: a bug with Repeat Until command when use with side comment on Until +% * FIX: a bug with side text -- text put into () -- of command macro (SetKwIf and so on) +% which was always setting a ';' even after a \DontPrintSemicolon +% * FIX: a bug with hyperref and chapter definition (thanks to Hubert Meier) +% * FIX: bugs with l macro and side comment +% * FIX: revision number +% * FIX: fix non ascii character (utf8 not yet recognized by all latex engine) +% * FIX: fnum@algocf had an useless parameter which sometimes broke expansion and output an error +% * FIX: works now with multicol package +% +% - december 14 2009 - revision 4.1 +% * ADD: new command \SetKwHangingKw{Name}{text} (hanging indent with keyword): This creates a +% hanging indent much like \texttt{SetKwInput}, except that it removes the trailing `:' +% and does not reset numbering (thanks to Nathan Tallent) % % - november 17 2009 - revision 4.00 - % -% * CHANGE : IMPORTANT : some commands have been renamed to have consistent naming (CamlCase -% syntax) and old commands are no more available. If you doesn't want to change -% your mind or use old latex files, you can use oldcommands option to enable old -% commands back. -% text. Here are these commands: -% - \SetNoLine becomes \SetAlgoNoLine -% - \SetVline becomes \SetAlgoVlined -% - \Setvlineskip becomes \SetVlineSkip -% - \SetLine becomes \SetAlgoLined -% - \dontprintsemicolon becomes \DontPrintSemicolon -% - \printsemicolon becomes \PrintSemicolon -% - \incmargin becomes \IncMargin -% - \decmargin becomes \DecMargin -% - \setnlskip becomes \SetNlSkip -% - \Setnlskip becomes \SetNlSkip -% - \setalcapskip becomes \SetAlCapSkip -% - \setalcaphskip becomes \SetAlCapHSkip -% - \nlSty becomes \NlSty -% - \Setnlsty becomes \SetNlSty -% - \linesnumbered becomes \LinesNumbered -% - \linesnotnumbered becomes \LinesNotNumbered -% - \linesnumberedhidden becomes \LinesNumberedHidden -% - \showln becomes \ShowLn -% - \showlnlabel becomes \ShowLnLabel -% - \nocaptionofalgo becomes \NoCaptionOfAlgo -% - \restorecaptionofalgo becomes \RestoreCaptionOfAlgo -% - \restylealgo becomes \RestyleAlgo -% - gIf macros and so on do no more exist +% * CHANGE: IMPORTANT: some commands have been renamed to have consistent naming (CamlCase +% syntax) and old commands are no more available. If you doesn't want to change +% your mind or use old latex files, you can use oldcommands option to enable old +% commands back. +% text. Here are these commands: +% - \SetNoLine becomes \SetAlgoNoLine +% - \SetVline becomes \SetAlgoVlined +% - \Setvlineskip becomes \SetVlineSkip +% - \SetLine becomes \SetAlgoLined +% - \dontprintsemicolon becomes \DontPrintSemicolon +% - \printsemicolon becomes \PrintSemicolon +% - \incmargin becomes \IncMargin +% - \decmargin becomes \DecMargin +% - \setnlskip becomes \SetNlSkip +% - \Setnlskip becomes \SetNlSkip +% - \setalcapskip becomes \SetAlCapSkip +% - \setalcaphskip becomes \SetAlCapHSkip +% - \nlSty becomes \NlSty +% - \Setnlsty becomes \SetNlSty +% - \linesnumbered becomes \LinesNumbered +% - \linesnotnumbered becomes \LinesNotNumbered +% - \linesnumberedhidden becomes \LinesNumberedHidden +% - \showln becomes \ShowLn +% - \showlnlabel becomes \ShowLnLabel +% - \nocaptionofalgo becomes \NoCaptionOfAlgo +% - \restorecaptionofalgo becomes \RestoreCaptionOfAlgo +% - \restylealgo becomes \RestyleAlgo +% - gIf macros and so on do no more exist % * NEW: - Compatibily with other packages improven by changing name of internal % macros. Algorithm2e can now be used with arabtex for example, if this last is % loaded after algorithm2e package. @@ -199,7 +291,7 @@ % numbers. % * ADD: - OPTION onelanguage: allow, if using standard keywords listed below, to switch % from one language to another without changing keywords by using appropriate -% language option : +% language option: % . KwIn, KwOut, KwData, KwResult % . KwTo KwFrom % . KwRet, Return @@ -212,7 +304,7 @@ % * ADD: - OPTION rightnl: put lines numbers to the right of the algorithm instead of left. % * ADD: new commands \setRightLinesNumbers and \setLeftLinesNumbers which sets the lines % numbers to the right or to the left of the algorithm. -% * ADD: - new kind of keywords : KwArray used to define arrays: +% * ADD: - new kind of keywords: KwArray used to define arrays: % \SetKwArray{Kw}{array} defines an array keywords Kw called array and printed in % DataSty style when call with \Kw. It can be used with one argument which % denotes the element index: \Kw{n} prints array[n] with array in DataSty and n in @@ -240,7 +332,7 @@ % \SetAlCapSty, \SetAlCapNameSty, \SetAlCapFnt, \SetAlCapNameFnt, \SetProcSty, % \SetProcFnt, \SetProcNameSty, \SetProcNameFnt, \SetProcArgSty, \SetProcArgFnt which % control the way caption is printed. Sty macro use command taking one parameter as -% argument, Fnt macros use directly command. In Fact caption is printed as follow : +% argument, Fnt macros use directly command. In Fact caption is printed as follow: % \AlCapSty{\AlCapFnt Algorithm 1:}\AlCapNameSty{\AlCapNameFnt my algorithm} % By default, \AlCapSty is textbf and \AlCapFnt is nothing. \AlCapNameSty keep text % as it is, and \AlCapNameFnt do nothing also. @@ -522,7 +614,7 @@ % pdf correctly generated) % * flush text to left in order to have correct indentation even with class as amsart which % center all figures -% * add german, portugues and czech options for title of algorithms and typo. +% * add german, portuguese and czech options for title of algorithms and typo. % * add portuguese translation of predefined keywords * add czech translation of some % predefined keywords % @@ -577,7 +669,7 @@ % * minor bug on longend option corrected. % % - August 26 1999 - revision 2.31 -% * add an option : figure +% * add an option: figure % this option makes algorithms be figure and so are numbered % as figures, have Figure as caption and are put in % the \listoffigures @@ -595,7 +687,7 @@ % - label now puts the name (the text before the braces in the % caption) of the procedure or function as reference (not % the number like a classic algorithm environment). -% There are also two new styles : ProcNameSty and +% There are also two new styles: ProcNameSty and % ProcArgSty. These style are by default the same as FuncSty % and ArgSty but are used in the caption of a procedure or a % function. @@ -611,11 +703,11 @@ % \KwSty{functioname(}list of arguments\KwSty{)} % % -% - November 27 1996 - revision 2.21 : +% - November 27 1996 - revision 2.21: % minor bug in length of InOut boxes fixed. % add algorithm* environment. % -% - July 12 1996 - revision 2.2 : \SetArg and \SetKwArg macros removed. +% - July 12 1996 - revision 2.2: \SetArg and \SetKwArg macros removed. % % \SetArg has been removed since it never has been % documented. @@ -623,7 +715,7 @@ % take an argument in order to be consistent with % \SetKwData and \SetKwFunction macros. % -% - July 04 1996 - revision 2.1 : still more LaTeX2e! Minor compatibility break +% - July 04 1996 - revision 2.1: still more LaTeX2e! Minor compatibility break % % Macros use now \newcommand instead of \def, use of \setlength, % \newsavebox, ... and other LaTeX2e specific stuff. @@ -641,7 +733,7 @@ % % Known bugs: % ----------- -% - no more known bugs... all are corrected! +% - horizontal spacing (indent) doesn't work with revtex4 class. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -652,13 +744,76 @@ % \NeedsTeXFormat{LaTeX2e}[1994/12/01] % -\ProvidesPackage{algorithm2e}[2008/00/00 v3.10 algorithms environments] +\ProvidesPackage{algorithm2e}[2013/01/06 v5.00 algorithms environments] % % %%%%%%%%%%%%%%%%%%%%%%%%%%% Initial Code %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \@makeother\*% some package redefined it as a letter (as color.sty) \def\@firstword#1 #2\@nil{#1}% an useful fonction +%%%%%%% Utilities: +% \ifArgumentEmpty<c><t><e> ; if c is empty, i.e. {}, then t, else e. +% Function used internally, but may as well expose it to the user; it's useful +\long\def\ifArgumentEmpty#1{\bgroup + \catcode`\Q=3 + \catcode`\T=3 + \long\def\@tempa##1##2Q##3##4##5T{##4}% + \xdef\@tempa{\@tempa#1QQ{\noexpand\@secondoftwo}{\noexpand\@firstoftwo}T}% +\egroup\@tempa} +% +% \algocf@longdef -> shorthand to reduce +% \expandafter\long\expandafter\def +% to +% \expandafter\algocf@longdef +% may look insignificant, but reads that much better ;) +\def\algocf@longdef{\long\def} +% +% \algocf@newcommand (and helper \algocf@new@command) behaves like LaTeX's newcommand, +% with two differences: +% - the argument is not "\<name>", but rather "<name>"; i.e. one level of indirection +% - if the command exists already, then \renewcommand, rather than \newcommand +\def\algocf@newcommand#1{\expandafter\algocf@new@command\csname#1\endcsname} +\def\algocf@new@command#1{% + \begingroup \escapechar\m@ne\xdef\@gtempa{{\string#1}}\endgroup + \expandafter\@ifundefined\@gtempa\newcommand\renewcommand#1}% +% +% \algocf@newcmdside<name><arity><body> +% The largest time-saver; many commands we define have the pattern: +% \<name>(<side_text>)<argX><argY>... +% where "(<side_text>)" is optional. By defining them with this function, +% the arguments are parsed and renumbered, i.e. the body works as if the +% command was: +% \<name><side_text><argX><argY>... +% and can use \ifArgumentEmpty to see whether its #1 exists (default case +% for the side text is (), so there's no difference between calling +% \foo{bar} +% or +% \foo(){bar} +% Technically this is new behaviour, but it shouldn't really occur... +\algocf@longdef\algocf@newcmdside#1#2#3{% + \expandafter\def\csname#1\endcsname{% + \@ifnextchar({\csname algocf@#1strip\endcsname}{\csname algocf@#1strip\endcsname()}% + }% + \expandafter\algocf@longdef\csname algocf@#1strip\endcsname(##1){\csname algocf@#1main\endcsname{##1}}% + \algocf@newcommand{algocf@#1main}[#2]{#3}% +} +% +% \algocf@newcmdsides<name><arity><body><tail><closing> +% Like the command above, but with an optional side text at the end +% of the command as well, i.e.: +% \<name>(<side_text>)<argX><argY>(<end_text>) +% It may be a bit confusing that <arity> doesn't count <end_text>, +% but since it is for internal use, the naming can be a little more +% fuzzy. This function behaves as if: +% <body'> = <body><if end_text: tail{end_text}><closing> +\algocf@longdef\algocf@newcmdsides#1#2#3#4#5{% + \expandafter\def\csname#1\endcsname{% + \@ifnextchar({\csname algocf@#1strip\endcsname}{\csname algocf@#1strip\endcsname()}% + }% + \expandafter\algocf@longdef\csname algocf@#1strip\endcsname(##1){\csname algocf@#1main\endcsname{##1}}% + \algocf@newcommand{algocf@#1main}[#2]{#3\@ifnextchar({\csname algocf@#1end\endcsname}{#4#5}}% + \expandafter\algocf@longdef\csname algocf@#1end\endcsname(##1){#4{##1}\strut\par}% +}% % % definition of commands which can be redefined in options of the package. % @@ -697,8 +852,17 @@ % % %% redefine chapter so that it adds a vspace in the loa as the original does for lof and lot -\let\algocf@original@chapter=\chapter% -\def\chapter{\expandafter\addtocontents{loa}{\protect\addvspace{10\p@}}\algocf@original@chapter}% +% \let\algocf@original@chapter=\chapter% +% \def\chapter{\expandafter\addtocontents{loa}{\protect\addvspace{10\p@}}\algocf@original@chapter}% +% +% bug correction with hyperref submitted by Hubert Meier +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname @chapter\endcsname\relax\else +% \let\algocf@original@chapter=\chapter% +% \def\chapter{\addtocontents{loa}{\protect\addvspace{10\p@}}\algocf@original@chapter}% +\let\algocf@original@chapter=\@chapter% +\def\@chapter[#1]#2{\algocf@original@chapter[#1]{#2}\addtocontents{loa}{\protect\addvspace{10\p@}}}% +\fi % %% if@restonecol is defined in article and book but some other classes don't define it and we need it, so we do \ifx\if@restonecol\relax\else\newif\if@restonecol\fi% @@ -708,6 +872,11 @@ % \RequirePackage{ifthen}% % +\newboolean{algocf@displayblockmarkers}\setboolean{algocf@displayblockmarkers}{false}% +\DeclareOption{displayblockmarkers}{% + \setboolean{algocf@displayblockmarkers}{true}% +} +% \newboolean{algocf@nokwfunc}\setboolean{algocf@nokwfunc}{false}% \DeclareOption{nokwfunc}{% \setboolean{algocf@nokwfunc}{true}% @@ -775,9 +944,9 @@ \renewcommand{\algorithmautorefname}{algorithme}% \renewcommand{\algorithmcflinename}{ligne}% \renewcommand{\algocf@typo}{\ }% -\renewcommand{\@algocf@procname}{Procédure}% +\renewcommand{\@algocf@procname}{Proc\'edure}% \renewcommand{\@algocf@funcname}{Fonction}% -\renewcommand{\procedureautorefname}{procédure}% +\renewcommand{\procedureautorefname}{proc\'edure}% \renewcommand{\functionautorefname}{fonction}% \renewcommand{\algocf@languagechoosen}{french}% }% @@ -808,6 +977,19 @@ \renewcommand{\algocf@languagechoosen}{german}% }% % +\DeclareOption{ngerman}{% +\renewcommand{\listalgorithmcfname}{Liste der Algorithmen}% +\renewcommand{\algorithmcfname}{Algorithmus}% +\renewcommand{\algorithmautorefname}{\algorithmcfname}% +\renewcommand{\algorithmcflinename}{Zeile}% +\renewcommand{\algocf@typo}{\ }% +\renewcommand{\@algocf@procname}{Prozedur}% +\renewcommand{\@algocf@funcname}{Funktion}% +\renewcommand{\procedureautorefname}{\@algocf@procname}% +\renewcommand{\functionautorefname}{\@algocf@funcname}% +\renewcommand{\algocf@languagechoosen}{german}% +}% +% \DeclareOption{portuguese}{% \renewcommand{\listalgorithmcfname}{Lista de Algoritmos}% \renewcommand{\algorithmcfname}{Algoritmo}% @@ -833,6 +1015,18 @@ \renewcommand{\functionautorefname}{funzione}% \renewcommand{\algocf@languagechoosen}{italiano}% }% +\DeclareOption{spanish}{% +\renewcommand{\listalgorithmcfname}{\'Indice de algoritmos}% +\renewcommand{\algorithmcfname}{Algoritmo}% +\renewcommand{\algorithmautorefname}{algoritmo}% +\renewcommand{\algorithmcflinename}{l\'inea}% +\renewcommand{\algocf@typo}{}% +\renewcommand{\@algocf@procname}{Procedimiento}% +\renewcommand{\@algocf@funcname}{Funci\'on}% +\renewcommand{\procedureautorefname}{procedimiento}% +\renewcommand{\functionautorefname}{funci\'on}% +\renewcommand{\algocf@languagechoosen}{spanish}% +}% \DeclareOption{slovak}{% \renewcommand{\listalgorithmcfname}{Zoznam algoritmov}% \renewcommand{\algorithmcfname}{Algoritmus}% @@ -846,6 +1040,19 @@ \renewcommand{\algocf@languagechoosen}{slovak}% }% % +\DeclareOption{croatian}{% +\renewcommand{\listalgorithmcfname}{Popis algoritama}% +\renewcommand{\algorithmcfname}{Algoritam}% +\renewcommand{\algorithmautorefname}{\algorithmcfname}% +\renewcommand{\algorithmcflinename}{linija}% +\renewcommand{\algocf@typo}{}% +\renewcommand{\@algocf@procname}{Procedura}% +\renewcommand{\@algocf@funcname}{Funkcija}% +\renewcommand{\procedureautorefname}{\@algocf@procname}% +\renewcommand{\functionautorefname}{\@algocf@funcname}% +\renewcommand{\algocf@languagechoosen}{croatian}% +}% +% % OPTIONs plain, boxed, ruled, algoruled & boxruled % \newcommand{\algocf@style@plain}{\renewcommand{\algocf@style}{plain}}% @@ -854,8 +1061,10 @@ \newcommand{\algocf@style@algoruled}{\renewcommand{\algocf@style}{algoruled}}% \newcommand{\algocf@style@boxruled}{\renewcommand{\algocf@style}{boxruled}}% \newcommand{\algocf@style@tworuled}{\renewcommand{\algocf@style}{tworuled}}% +\newcommand{\algocf@style@plainruled}{\renewcommand{\algocf@style}{plainruled}}% \newcommand{\RestyleAlgo}[1]{\csname algocf@style@#1\endcsname}% \DeclareOption{plain}{\algocf@style@plain}% +\DeclareOption{plainruled}{\algocf@style@plainruled}% \DeclareOption{boxed}{\algocf@style@boxed}% \DeclareOption{ruled}{\algocf@style@ruled}% \DeclareOption{algoruled}{\algocf@style@algoruled}% @@ -926,6 +1135,8 @@ \DeclareOption{shortend}{\AtBeginDocument{\SetAlgoShortEnd}}%\SetAlgoShortEnd \DeclareOption{noend}{\AtBeginDocument{\SetAlgoNoEnd}}% \SetAlgoNoEnd % +\DeclareOption{nosemicolon}{\AtBeginDocument{\DontPrintSemicolon}}% \SetAlgoNoEnd +% % OPTION dotoc % \newboolean{algocf@dotocloa}\setboolean{algocf@dotocloa}{false}% @@ -986,10 +1197,10 @@ % \ifthenelse{\boolean{algocf@slide}}{\RequirePackage{color}}{}% % - +% \AtEndOfPackage{% \ifthenelse{\boolean{algocf@dotocloa}}{% - \renewcommand{\listofalgorithmes}{\tocfile{\listalgorithmcfname}{loa}}% + \renewcommand{\listofalgorithms}{\tocfile{\listalgorithmcfname}{loa}}% }{\relax}% }% % @@ -998,19 +1209,19 @@ \ifx\@tocextra\undefined% \RequirePackage{tocbibind}% \fi% -}% +}{\relax}% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%% Main Part %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \newcommand{\algocf@name}{algorithm2e}% -\newcommand{\algocf@date}{december 14 2009}% -\newcommand{\algocf@version}{Release 4.01}% +\newcommand{\algocf@date}{january 06 2013}% +\newcommand{\algocf@version}{Release 5.0}% \newcommand{\algocf@id}{\algocf@version\space -- \algocf@date\space --}% \typeout{********************************************************^^JPackage `\algocf@name'\space\algocf@id^^J% - algorithm2e-announce@lirmm.fr mailing list for announcement about releases^^J% - algorithm2e-discussion@lirmm.fr mailing list for discussion about package^^J% subscribe by emailing sympa@lirmm.fr with 'subscribe <list> <firstname name>'^^J% - - Author: Christophe Fiorio (fiorio@lirmm.fr)^^J********************************************************}% + - Author: Christophe Fiorio (cfiorio@um2.fr)^^J********************************************************}% %% %% %% @@ -1049,7 +1260,7 @@ \newskip\skipalgocfslide\skipalgocfslide=1em% \newdimen\algowidth% \newdimen\inoutsize% -\newdimen\inoutline% +\newdimen\inoutindent% \newdimen\interspacetitleruled\setlength{\interspacetitleruled}{2pt}% \newdimen\interspacealgoruled\setlength{\interspacealgoruled}{2pt}% \newdimen\interspacetitleboxruled\setlength{\interspacetitleboxruled}{2\lineskip}% @@ -1087,10 +1298,16 @@ \SetAlCapHSkip{.5\algomargin}% %% %% +\newskip\algoskipindent +\newcommand{\algocf@adjustskipindent}{% + \algoskipindent=\skiprule% + \advance\algoskipindent by \skiptext\advance\algoskipindent by 0.4pt} +\algocf@adjustskipindent% +% \newcommand{\Indentp}[1]{\advance\leftskip by #1}% -\newcommand{\Indp}{\advance\leftskip by 1em}% +\newcommand{\Indp}{\algocf@adjustskipindent\advance\leftskip by \algoskipindent} \newcommand{\Indpp}{\advance\leftskip by 0.5em}% -\newcommand{\Indm}{\advance\leftskip by -1em}% +\newcommand{\Indm}{\algocf@adjustskipindent\advance\leftskip by -\algoskipindent} \newcommand{\Indmm}{\advance\leftskip by -0.5em}% %% %% @@ -1113,6 +1330,8 @@ \sbox\algocf@nlbox{\NlSty{#1}}% \skiplinenumber=\hsize\advance\skiplinenumber by-\leftskip\advance\skiplinenumber by-\skiptext% \advance\skiplinenumber by\algomargin\advance\skiplinenumber by.3em\advance\skiplinenumber by-\wd\algocf@nlbox% + % to handle particular case of until: printnl is after 'until' keyword has been writen, so we need to substract length of this keyword + \advance\skiplinenumber by-\algocf@skipuntil% \strut\raisebox{0pt}{\rlap{\kern\skiplinenumber\NlSty{#1\ignorespaces}}}\ignorespaces% }% }% @@ -1139,14 +1358,14 @@ }% now we can do the line numbering \skiplinenumber=\hsize\advance\skiplinenumber by-\leftskip% \strut\raisebox{0pt}{\rlap{\kern\skiplinenumber\strut\NlSty{\theAlgoLine}}}\ignorespaces% -} +}% %% nlset \newcommand{\nlset}[1]{% \@ifundefined{hyper@refstepcounter}{\protected@edef\@currentlabel{#1}}{\algocf@nl@sethref{#1}}\algocf@printnl{#1}% }% % %% lnl definitions -\newcommand{\lnl}[1]{\nl\label{#1}}% +\newcommand{\lnl}[1]{\nl\label{#1}\ignorespaces}% % %% lnlset \newcommand{\lnlset}[2]{\nlset{#2}\label{#1}}% @@ -1227,6 +1446,8 @@ \newcommand{\TitleSty}[1]{#1\unskip}%\SetTitleSty{}{} \newcommand{\SetTitleSty}[2]{\renewcommand{\TitleSty}[1]{% \csname#1\endcsname{\csname#2\endcsname##1}}\unskip}% +\newcommand{\BlockMarkersSty}[1]{\KwSty{#1}}% +\newcommand{\SetBlockMarkersSty}[1]{\renewcommand{\BlockMarkersSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}% % %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1235,8 +1456,8 @@ % \newcommand{\algocf@push}[1]{\advance\skiptotal by #1\moveright #1}% \newcommand{\algocf@pop}[1]{\advance\skiptotal by -#1}% -\newcommand{\algocf@addskiptotal}{\advance\skiptotal by 0.4pt\advance\hsize by -0.4pt}% 0.4 pt=width of \vrule -\newcommand{\algocf@subskiptotal}{\advance\skiptotal by -0.4pt\advance\hsize by 0.4pt}% 0.4 pt=width of \vrule +\newcommand{\algocf@addskiptotal}{\advance\skiptotal by 0.4pt\advance\hsize by -0.4pt\advance\hsize by -\skiplength}% 0.4 pt=width of \vrule +\newcommand{\algocf@subskiptotal}{\advance\skiptotal by -0.4pt\advance\hsize by 0.4pt\advance\hsize by \skiplength}% 0.4 pt=width of \vrule % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% @@ -1244,43 +1465,72 @@ % \skiphlne=.8ex% \newcommand{\SetVlineSkip}[1]{\skiphlne=#1}% +\newcommand{\algocf@bblock}{\BlockMarkersSty{begin}}% +\newcommand{\algocf@eblock}{\BlockMarkersSty{end}}% +\newcommand{\AlgoDisplayBlockMarkers}{\setboolean{algocf@displayblockmarkers}{true}}% +\newcommand{\AlgoDontDisplayBlockMarkers}{\setboolean{algocf@displayblockmarkers}{false}}% +\newcommand{\algocf@bblockcode}{% + \ifthenelse{\boolean{algocf@displayblockmarkers}}{\algocf@bblock\par}{\relax}% +}% +\newcommand{\algocf@eblockcode}{% + \ifthenelse{\boolean{algocf@displayblockmarkers}}{\algocf@eblock\par}{\relax}% +}% +\newcommand{\SetAlgoBlockMarkers}[2]{% + \ifArgumentEmpty{#1}{% + \renewcommand{\algocf@bblock}{\relax}% + }{% + \renewcommand{\algocf@bblock}{\BlockMarkersSty{#1}}% + }% begin marker set + \ifArgumentEmpty{#2}{% + \renewcommand{\algocf@eblock}{\relax}% + }{% + \renewcommand{\algocf@eblock}{\BlockMarkersSty{#2}}% + }% end marker set +} % -%% block with a vertical line end by a little horizontal line +%%%%%%%%% block with a vertical line end by a little horizontal line \newcommand{\algocf@Vline}[1]{% no vskip in between boxes but a strut to separate them, \strut\par\nointerlineskip% then interblock space stay the same whatever is inside it \algocf@push{\skiprule}% move to the right before the vertical rule \hbox{\vrule% \vtop{\algocf@push{\skiptext}%move the right after the rule - \vtop{\algocf@addskiptotal\advance\hsize by -\skiplength #1}\Hlne}}\vskip\skiphlne% inside the block + \vtop{\algocf@addskiptotal #1}\Hlne}}\vskip\skiphlne% inside the block \algocf@pop{\skiprule}%\algocf@subskiptotal% restore indentation \nointerlineskip}% no vskip after % -%% block with a vertical line +%%%%%%%%% block with a vertical line \newcommand{\algocf@Vsline}[1]{% no vskip in between boxes but a strut to separate them, \strut\par\nointerlineskip% then interblock space stay the same whatever is inside it + \algocf@bblockcode% \algocf@push{\skiprule}% move to the right before the vertical rule \hbox{\vrule% the vertical rule \vtop{\algocf@push{\skiptext}%move the right after the rule - \vtop{\algocf@addskiptotal\advance\hsize by -\skiplength #1}}}% inside the block - \algocf@pop{\skiprule}}% restore indentation + \vtop{\algocf@addskiptotal #1}}}% inside the block + \algocf@pop{\skiprule}% restore indentation + \algocf@eblockcode% +} % \newcommand{\algocf@Hlne}{\hrule height 0.4pt depth 0pt width .5em}% % -%% block without line +%%%%%%%%% block without line \newcommand{\algocf@Noline}[1]{% no vskip in between boxes but a strut to separate them, \strut\par\nointerlineskip% then interblock space stay the same whatever is inside it + \algocf@bblockcode% \algocf@push{\skiprule}% \hbox{% \vtop{\algocf@push{\skiptext}% - \vtop{\advance\hsize by -\skiplength #1}}}% inside the block + \vtop{\algocf@addskiptotal #1}}}% inside the block \algocf@pop{\skiprule}% + \algocf@eblockcode% % \nointerlineskip% no vskip after }% +%%%%%%%%% % %% default=NoLine % -\newcommand{\algocf@group}[1]{\algocf@Noline{##1}}% group: set of instruction depending from another (ex: then part of the If) -\newcommand{\algocf@@block}[2]{\algocf@Noline{##1}\KwSty{##2}\par}% block: group with a end keyword. +\newcommand{\algocf@group}[1]{\algocf@Noline{#1}}% group: set of instruction depending from another (ex: then part of the If) +\newcommand{\algocf@@@block}[2]{#1\ifArgumentEmpty{#2}{\relax}{\KwSty{\@algocf@endoption{#2}}\strut\par}}% block: group with a end keyword. +\newcommand{\algocf@@block}[2]{\algocf@@@block{#1}{#2}}% block: group with a end keyword. \newcommand{\algocf@block}[2]{\algocf@@block{#1}{#2}}% command that will be used and redefined accordingly to noend option \newcommand{\algocf@setBlock}{% \ifthenelse{\boolean{algocf@optnoend}}{% if no end option @@ -1311,18 +1561,18 @@ \algocf@setBlock}% % \newcommand{\SetAlgoNoLine}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Noline -\renewcommand{\algocf@@block}[2]{\algocf@Noline{##1}\KwSty{##2}\strut\par}% +\renewcommand{\algocf@@block}[2]{\algocf@@@block{\algocf@Noline{##1}}{##2}}% \renewcommand{\algocf@group}[1]{\algocf@Noline{##1}}% \renewcommand{\Hlne}{}}% % \newcommand{\SetAlgoVlined}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Vline \renewcommand{\algocf@@block}[2]{\algocf@Vline{##1}}% -\renewcommand{\algocf@group}[1]{\algocf@Vsline{##1}\ifthenelse{\boolean{algocf@optnoend}}{\relax}{\strut\ignorespaces}}% +\renewcommand{\algocf@group}[1]{\algocf@Vsline{##1}}%\ifthenelse{\boolean{algocf@optnoend}}{\relax}{\strut\ignorespaces}}% \renewcommand{\Hlne}{\algocf@Hlne}}% % \newcommand{\SetAlgoLined}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Line -\renewcommand{\algocf@@block}[2]{\strut\algocf@Vsline{##1}\KwSty{##2}\strut\par}% no skip after a block so garantie at least a line -\renewcommand{\algocf@group}[1]{\algocf@Vsline{##1}\ifthenelse{\boolean{algocf@optnoend}}{\relax}{\strut\ignorespaces}}% +\renewcommand{\algocf@@block}[2]{\algocf@@@block{\strut\algocf@Vsline{##1}}{##2}}% no skip after a block so garantie at least one line +\renewcommand{\algocf@group}[1]{\algocf@Vsline{##1}}%\ifthenelse{\boolean{algocf@optnoend}}{\relax}{\strut\ignorespaces}}% \renewcommand{\Hlne}{}}% % \newcommand{\SetNothing}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Noline @@ -1337,24 +1587,28 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% ``Input :'''s like command +% ``Input:'''s like command % %%% % text staying at the right of the longer keyword of KwInOut commands % (text of KwInOut commands are all vertically aligned) % -\newcommand{\algocf@newinout}{\par\parindent=\wd\algocf@inoutbox}% to put right indentation after a \\ in the KwInOut +\newcommand{\algocf@newinout}{\par\parindent=\inoutindent}% to put right indentation after a \\ in the KwInOut \newcommand{\SetKwInOut}[2]{% \sbox\algocf@inoutbox{\KwSty{#2}\algocf@typo:}% \expandafter\ifx\csname InOutSizeDefined\endcsname\relax% if first time used \newcommand\InOutSizeDefined{}\setlength{\inoutsize}{\wd\algocf@inoutbox}% + \sbox\algocf@inoutbox{\parbox[t]{\inoutsize}{\KwSty{#2}\algocf@typo\hfill:}~}\setlength{\inoutindent}{\wd\algocf@inoutbox}% \else% else keep the larger dimension - \ifdim\wd\algocf@inoutbox>\inoutsize\setlength{\inoutsize}{\wd\algocf@inoutbox}\fi% + \ifdim\wd\algocf@inoutbox>\inoutsize% + \setlength{\inoutsize}{\wd\algocf@inoutbox}% + \sbox\algocf@inoutbox{\parbox[t]{\inoutsize}{\KwSty{#2}\algocf@typo\hfill:}~}\setlength{\inoutindent}{\wd\algocf@inoutbox}% + \fi% \fi% the dimension of the box is now defined. - \@ifundefined{#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% - \expandafter\algocf@mkcmd\csname#1\endcsname[1]{% + \algocf@newcommand{#1}[1]{% \ifthenelse{\boolean{algocf@inoutnumbered}}{\relax}{\everypar={\relax}}% - {\let\\\algocf@newinout\hangindent=\wd\algocf@inoutbox\hangafter=1\parbox[t]{\inoutsize}{\KwSty{#2}\algocf@typo\hfill:}~##1\par}% +% {\let\\\algocf@newinout\hangindent=\wd\algocf@inoutbox\hangafter=1\parbox[t]{\inoutsize}{\KwSty{#2}\algocf@typo\hfill:}~##1\par}% + {\let\\\algocf@newinout\hangindent=\inoutindent\hangafter=1\parbox[t]{\inoutsize}{\KwSty{#2}\algocf@typo\hfill:}~##1\par}% \algocf@linesnumbered% reset the numbering of the lines }}% % @@ -1371,17 +1625,15 @@ % \newcommand{\algocf@newinput}{\par\parindent=\wd\algocf@inputbox}% to put right indentation after a \\ in the KwInput \newcommand{\SetKwInput}[2]{% - \@ifundefined{#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% - \expandafter\algocf@mkcmd\csname#1\endcsname[1]{% + \algocf@newcommand{#1}[1]{% \sbox\algocf@inputbox{\hbox{\KwSty{#2}\algocf@typo: }}% \ifthenelse{\boolean{algocf@inoutnumbered}}{\relax}{\everypar={\relax}}% {\let\\\algocf@newinput\hangindent=\wd\algocf@inputbox\hangafter=1\unhbox\algocf@inputbox##1\par}% \algocf@linesnumbered% reset the numbering of the lines }}% \newcommand{\SetKwData}[2]{% - \@ifundefined{#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% - \expandafter\algocf@mkcmd\csname @#1\endcsname[1]{\DataSty{#2(}\ArgSty{##1}\DataSty{)}}% - \expandafter\algocf@mkcmd\csname#1\endcsname{% + \algocf@newcommand{@#1}[1]{\DataSty{#2(}\ArgSty{##1}\DataSty{)}}% + \algocf@newcommand{#1}{% \@ifnextchar\bgroup{\csname @#1\endcsname}{\DataSty{#2}\xspace}}% }% % @@ -1400,8 +1652,7 @@ \newsavebox{\algocf@hangingbox} \newcommand{\algocf@newhanging}{\par\parindent=\wd\algocf@hangingbox}% to put right indentation after a \\ in the KwInput \newcommand{\SetKwHangingKw}[2]{% - \@ifundefined{#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% - \expandafter\algocf@mkcmd\csname#1\endcsname[1]{% + \algocf@newcommand{#1}[1]{% \sbox\algocf@hangingbox{\hbox{\KwSty{#2}\algocf@typo\ }}% {\let\\\algocf@newhanging\hangindent=\wd\algocf@hangingbox\hangafter=1\unhbox\algocf@hangingbox##1\;}% }% @@ -1446,10 +1697,8 @@ \algocf@scrfill\algocf@startsidecomment\ignorespaces}% % \newcommand{\SetKwComment}[3]{% - % newcommand or renewcommand ? - \@ifundefined{#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% - %%% comment definition - \expandafter\algocf@mkcmd\csname algocf@#1\endcsname[1]{% + \algocf@newcommand{#1}{\@ifstar{\csname algocf@#1@star\endcsname}{\csname algocf@#1\endcsname}}% + \algocf@newcommand{algocf@#1}[1]{% \sbox\algocf@inputbox{\CommentSty{\hbox{#2}}}% \ifthenelse{\boolean{algocf@commentsnumbered}}{\relax}{\everypar={\relax}}% {\renewcommand{\algocf@endmarkcomment}{#3}% @@ -1459,49 +1708,51 @@ \algocf@linesnumbered% reset the numbering of the lines }% %%% side comment definitions - % option or not? - \expandafter\algocf@mkcmd\csname algocf@#1@star\endcsname{% - \@ifnextchar [{\csname algocf@#1@staropt\endcsname}{\csname algocf@#1@sidecomment\endcsname}% - }% - % manage option - \expandafter\def\csname algocf@#1@staropt\endcsname[##1]##2{% - \ifthenelse{\boolean{algocf@scleft}}{\setboolean{algocf@sidecomment}{true}}{\setboolean{algocf@sidecomment}{false}}% - \ifx##1h\setboolean{algocf@altsidecomment}{true}\SetSideCommentLeft\fi% - \ifx##1f\setboolean{algocf@altsidecomment}{true}\SetSideCommentRight\fi% - \ifx##1l\setboolean{algocf@altsidecomment}{false}\SetSideCommentLeft\fi% - \ifx##1r\setboolean{algocf@altsidecomment}{false}\SetSideCommentRight\fi% - \csname algocf@#1@sidecomment\endcsname{##2}% call sidecomment - \ifthenelse{\boolean{algocf@sidecomment}}{\setboolean{algocf@scleft}{true}}{\setboolean{algocf@scleft}{false}}% - \setboolean{algocf@altsidecomment}{false}% - }% - % side comment - \expandafter\algocf@mkcmd\csname algocf@#1@sidecomment\endcsname[1]{% + \algocf@newcommand{algocf@#1@star}[2][]{% + \ifArgumentEmpty{##1}\relax{% TODO: Is this even necessary, with all those \ifx's? + \ifthenelse{\boolean{algocf@scleft}}{\setboolean{algocf@sidecomment}{true}}{\setboolean{algocf@sidecomment}{false}}% + \ifx##1h\setboolean{algocf@altsidecomment}{true}\SetSideCommentLeft\fi% + \ifx##1f\setboolean{algocf@altsidecomment}{true}\SetSideCommentRight\fi% + \ifx##1l\setboolean{algocf@altsidecomment}{false}\SetSideCommentLeft\fi% + \ifx##1r\setboolean{algocf@altsidecomment}{false}\SetSideCommentRight\fi% + }% \sbox\algocf@inputbox{\CommentSty{\hbox{#2}}}% \ifthenelse{\boolean{algocf@commentsnumbered}}{\relax}{\everypar={\relax}}% {% \renewcommand{\algocf@endmarkcomment}{#3}% \let\\\algocf@endstartsidecomment% % here is the comment - %\ifthenelse{\boolean{algocf@altsidecomment}}{\relax}{\algocf@endline\ }% \ifthenelse{\boolean{algocf@altsidecomment}}{\relax}{\@endalgocfline\ }% \algocf@scrfill\algocf@startsidecomment\CommentSty{% - \strut\ignorespaces##1\strut\algocf@sclfill#3}\algocf@scpar% + \strut\ignorespaces##2\strut\algocf@sclfill#3}\algocf@scpar% }% \algocf@linesnumbered% reset the numbering of the lines - } - \expandafter\algocf@mkcmd\csname#1\endcsname{\@ifstar{\csname algocf@#1@star\endcsname}{\csname algocf@#1\endcsname}}% + \ifArgumentEmpty{##1}\relax{% + \ifthenelse{\boolean{algocf@sidecomment}}{\setboolean{algocf@scleft}{true}}{\setboolean{algocf@scleft}{false}}% + \setboolean{algocf@altsidecomment}{false}% + }% + }% +}% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% KwProg +% +\newcommand{\SetKwProg}[4]{% + \algocf@newcmdside{#1} 3{\KwSty{#2}\ifArgumentEmpty{#2}\relax{\ }\ArgSty{##2}\KwSty{#3}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##3}{#4}}% + \algocf@newcmdside{l#1}3{\KwSty{#2} \ArgSty{##2}\KwSty{#3} ##3\@endalgocfline\ifArgumentEmpty{##1}\relax{##1}\strut\par}% }% % +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Kw % \newcommand{\SetKw}[2]{% - \@ifundefined{#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% - \expandafter\algocf@mkcmd\csname @#1\endcsname[1]{\KwSty{#2} \ArgSty{##1}}% - \expandafter\algocf@mkcmd\csname#1\endcsname{% - \@ifnextchar\bgroup{\csname @#1\endcsname}{\KwSty{#2}\xspace}}% - }% + \algocf@newcommand{@#1}[1]{\KwSty{#2} \ArgSty{##1}} + \algocf@newcommand{#1}{\@ifnextchar\bgroup{\csname @#1\endcsname}{\KwSty{#2}\xspace}}% +}% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -1531,268 +1782,100 @@ % KwBlock % \newcommand{\SetKwBlock}[3]{% -\@ifundefined{algocf@#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% -% side text or not? -\expandafter\def\csname#1\endcsname{%Begin - \@ifnextchar({\csname algocf@#1opt\endcsname}{\csname algocf@#1\endcsname}}% -% with side text -\expandafter\def\csname algocf@#1opt\endcsname(##1)##2{% \Begin(){} - \KwSty{#2} ##1\algocf@block{##2}{\@algocf@endoption{#3}}% - \@ifnextchar({\csname algocf@#1end\endcsname}{\par}}% -% without side text at the beginning -\expandafter\algocf@mkcmd\csname algocf@#1\endcsname[1]{% \Begin{} - \KwSty{#2}\algocf@block{##1}{\@algocf@endoption{#3}}\@ifnextchar({\csname algocf@#1end\endcsname}{\par}}% -% side text at the end -\expandafter\def\csname algocf@#1end\endcsname(##1){% \Begin{} - \ ##1\par}% + \algocf@newcmdside{#1}{2} + {\KwSty{#2}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##2}{#3}\par} }% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% For Switch +% condition typo % -\newcommand{\SetKwSwitch}[8]{% #1=\Switch #2=\Case #3=\Other #4=swicth #5=case #6=do #7=otherwise #8=endsw -%%%% Switch -\@ifundefined{algocf@#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% -% side text or not? -\expandafter\def\csname#1\endcsname{%Switch - \@ifnextchar({\csname algocf@#1opt\endcsname}{\csname algocf@#1\endcsname}}% -% with side text -\expandafter\def\csname algocf@#1opt\endcsname(##1)##2##3{% \Switch(){}{} - \KwSty{#4} \ArgSty{##2} \KwSty{#5} ##1\algocf@block{##3}{\@algocf@endoption{#8}}}% -% without side text -\expandafter\algocf@mkcmd\csname algocf@#1\endcsname[2]{% \Switch{}{} - \KwSty{#4} \ArgSty{##1} \KwSty{#5}\algocf@block{##2}{\@algocf@endoption{#8}}}% -% side text at the end -\expandafter\def\csname algocf@#1end\endcsname(##1){% \Switch{}{}() -}% +\newcommand{\algocf@scond}{ } +\newcommand{\algocf@econd}{ } +\newcommand{\algocf@ucond}{} +\newcommand{\SetStartEndCondition}[3]{% + \renewcommand{\algocf@scond}{#1}\renewcommand{\algocf@econd}{#2}\renewcommand{\algocf@ucond}{#3}} +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % +% For Switch +% +\newcommand{\SetKwSwitch}[9]{% #1=\Switch #2=\Case #3=\Other #4=switch #5=do #6=case #7=otherwise #8=endcase #9=endsw + \algocf@newcmdside{#1}{3} + {\KwSty{#4}\algocf@scond\ArgSty{##2}\algocf@econd\KwSty{#5}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##3}{#9}} %%%% Case -\@ifundefined{algocf@#2}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% -% side text or not? -\expandafter\def\csname#2\endcsname{%Case - \@ifnextchar({\csname algocf@#2opt\endcsname}{\csname algocf@#2\endcsname}}% -\expandafter\def\csname u#2\endcsname{%uCase - \@ifnextchar({\csname algocf@u#2opt\endcsname}{\csname algocf@u#2\endcsname}}% -\expandafter\def\csname l#2\endcsname{%lCase - \@ifnextchar({\csname algocf@l#2opt\endcsname}{\csname algocf@l#2\endcsname}}% -% with side text -\expandafter\def\csname algocf@#2opt\endcsname(##1)##2##3{% \Case(){}{} - \KwSty{#6} \ArgSty{##2} ##1\algocf@block{##3}{\@algocf@endoption{#8}}}% -\expandafter\def\csname algocf@u#2opt\endcsname(##1)##2##3{% \uCase(){}{} - \KwSty{#6} \ArgSty{##2} ##1\algocf@group{##3}}% -\expandafter\def\csname algocf@l#2opt\endcsname(##1)##2##3{% \lCase(){}{} - \KwSty{#6} \ArgSty{##2} ##3\algocf@endline\ ##1\par}% -% without side text -\expandafter\algocf@mkcmd\csname algocf@#2\endcsname[2]{% \Case{}{} - \KwSty{#6} \ArgSty{##1}\algocf@block{##2}{\@algocf@endoption{#8}}}% -\expandafter\algocf@mkcmd\csname algocf@u#2\endcsname[2]{% \uCase{}{} - \KwSty{#6} \ArgSty{##1}\algocf@group{##2}}% -\expandafter\algocf@mkcmd\csname algocf@l#2\endcsname[2]{% \lCase{}{} - \KwSty{#6} \ArgSty{##1} ##2}% -%%%% Other -\@ifundefined{algocf@#3}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% -% side text or not? -\expandafter\def\csname#3\endcsname{%Other - \@ifnextchar({\csname algocf@#3opt\endcsname}{\csname algocf@#3\endcsname}}% -\expandafter\def\csname l#3\endcsname{%Other - \@ifnextchar({\csname algocf@l#3opt\endcsname}{\csname algocf@l#3\endcsname}}% -% with side text -\expandafter\def\csname algocf@#3opt\endcsname(##1)##2{% \Other(){}{} - \KwSty{#7} ##1\algocf@block{##2}{\@algocf@endoption{#8}}}% -\expandafter\def\csname algocf@l#3opt\endcsname(##1)##2{% \Other(){}{} - \KwSty{#7} ##2\algocf@endline\ ##1\par}% -% without side text -\expandafter\algocf@mkcmd\csname algocf@#3\endcsname[1]{% default - \KwSty{#7}\algocf@block{##1}{\@algocf@endoption{#8}}}% -\expandafter\algocf@mkcmd\csname algocf@l#3\endcsname[1]{% ldefault - \KwSty{#7} ##1}% + \algocf@newcmdside{#2}{3}{\KwSty{#6}\algocf@scond\ArgSty{##2}\algocf@ucond\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##3}{#8}}% + \algocf@newcmdside{u#2}{3}{\KwSty{#6}\algocf@scond\ArgSty{##2}\algocf@ucond\ifArgumentEmpty{##1}\relax{ ##1}\algocf@group{##3}}% + \algocf@newcmdside{l#2}{3}{\KwSty{#6}\algocf@scond\ArgSty{##2}\algocf@ucond\ ##3\@endalgocfline\ifArgumentEmpty{##1}\relax{ ##1}\strut\par}% +%%%% Other + \algocf@newcmdside{#3}{2}{\KwSty{#7}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##2}{#8}}% + \algocf@newcmdside{l#3}{2}{\KwSty{#7}\ ##2\@endalgocfline\ifArgumentEmpty{##1}\relax{ ##1}\strut\par}% }% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % If macros % -\newcommand{\SetKwIF}[8]{% #1=\If #2=\ElseIf #3=\Else #4=if #5=then #6=elseif si #7=else #8=endif +\newcommand{\SetKwIF}[8]{% #1=\If #2=\ElseIf #3=\Else #4=if #5=then #6=elseif #7=else #8=endif % % common text -\@ifundefined{#1@ifthen}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% -\expandafter\algocf@mkcmd\csname #1@ifthen\endcsname[1]{% - \KwSty{#4} \ArgSty{##1} \KwSty{#5}}% -\expandafter\algocf@mkcmd\csname #1@endif\endcsname[1]{\algocf@block{##1}{\@algocf@endoption{#8}}}% -\expandafter\algocf@mkcmd\csname #1@noend\endcsname[1]{\algocf@group{##1}}% -\expandafter\algocf@mkcmd\csname #1@else\endcsname[1]{\algocf@group{##1}\KwSty{#7}}% -\@ifundefined{#2@elseif}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% -\expandafter\algocf@mkcmd\csname #2@elseif\endcsname[1]{% - \KwSty{#6} \ArgSty{##1} \KwSty{#5}}% -\@ifundefined{#3@else}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% -\expandafter\algocf@mkcmd\csname #3@else\endcsname{\KwSty{#7}}% + \algocf@newcommand{#1@ifthen}[1]{\KwSty{#4}\algocf@scond\ArgSty{##1}\algocf@econd\KwSty{#5}}% + \algocf@newcommand{#1@endif} [1]{\algocf@block{##1}{#8}}% + \algocf@newcommand{#1@noend} [1]{\algocf@group{##1}}% + \algocf@newcommand{#1@else} [1]{\algocf@group{##1}\KwSty{#7}}% + \algocf@newcommand{#2@elseif}[1]{\KwSty{#6}\algocf@scond\ArgSty{##1}\algocf@econd\KwSty{#5}}% + \algocf@newcommand{#3@else} {\KwSty{#7}}% %%%% If then { } endif -% -\@ifundefined{algocf@#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% -% side text or not? -\expandafter\def\csname#1\endcsname{% - \@ifnextchar({\csname algocf@#1opt\endcsname}{\csname algocf@#1\endcsname}}% -% with side text -\expandafter\def\csname algocf@#1opt\endcsname(##1)##2##3{% \If(){}{} - \csname #1@ifthen\endcsname{##2} ##1\csname #1@endif\endcsname{##3}}% -% without side text -\expandafter\algocf@mkcmd\csname algocf@#1\endcsname[2]{% \If{}{} - \csname #1@ifthen\endcsname{##1}\csname #1@endif\endcsname{##2}}% -% + \algocf@newcmdside{#1}3{\csname #1@ifthen\endcsname{##2}\ifArgumentEmpty{##1}\relax{ ##1}\csname #1@endif\endcsname{##3}}% %%%% If then {} else {} endif -% -% side text or not? -\expandafter\def\csname e#1\endcsname{% - \@ifnextchar({\csname algocf@e#1thenopt\endcsname}{\csname algocf@e#1then\endcsname}}% -% with side text after if -\expandafter\def\csname algocf@e#1thenopt\endcsname(##1)##2##3{% \eIf() - \csname #1@ifthen\endcsname{##2} ##1\csname #1@else\endcsname{##3}% - \csname algocf@e#1thenelse\endcsname}% -% without side text after if -\expandafter\def\csname algocf@e#1then\endcsname##1##2{% \eIf() - \csname #1@ifthen\endcsname{##1}\csname #1@else\endcsname{##2}% - \csname algocf@e#1thenelse\endcsname}% -% side text after else or not ? -\expandafter\def\csname algocf@e#1thenelse\endcsname{% - \@ifnextchar({\csname algocf@e#1elseopt\endcsname}{\csname algocf@e#1else\endcsname}}% -% else with a side text -\expandafter\def\csname algocf@e#1elseopt\endcsname(##1)##2{% - ##1\csname #1@endif\endcsname{##2}}% -% else without side text -\expandafter\algocf@mkcmd\csname algocf@e#1else\endcsname[1]{% - \csname #1@endif\endcsname{##1}}% -% + % first command to handle optional side comment of else (so just after first braces) + \algocf@newcmdside{algocf@e#1thenelse}2{\ifArgumentEmpty{##1}\relax{ ##1}\csname #1@endif\endcsname{##2}} + % the definition of if-then-else command using command above + \algocf@newcmdside{e#1}3{\csname #1@ifthen\endcsname{##2}\ifArgumentEmpty{##1}\relax{ ##1}\csname #1@else\endcsname{##3}\csname algocf@e#1thenelse\endcsname}% + %%% leif + \algocf@newcmdside{le#1}4{\csname #1@ifthen\endcsname{##2} ##3 \csname #3@else\endcsname\ ##4\@endalgocfline\ifArgumentEmpty{##1}\relax{##1}\strut\par} %%%% If then -% -% side text or not? -\expandafter\def\csname l#1\endcsname{% lif - \@ifnextchar({\csname algocf@l#1opt\endcsname}{\csname algocf@l#1\endcsname}}% -\expandafter\def\csname u#1\endcsname{% uif - \@ifnextchar({\csname algocf@u#1opt\endcsname}{\csname algocf@u#1\endcsname}}% -% with side text -\expandafter\def\csname algocf@l#1opt\endcsname(##1)##2##3{% \lIf(){}{} - \csname #1@ifthen\endcsname{##2} ##3\algocf@endline\ ##1\par}% -\expandafter\def\csname algocf@u#1opt\endcsname(##1)##2##3{% \uIf(){}{} - \csname #1@ifthen\endcsname{##2} ##1\csname#1@noend\endcsname{##3}}% -% without side text -\expandafter\algocf@mkcmd\csname algocf@l#1\endcsname[2]{% \lIf{}{} - \csname #1@ifthen\endcsname{##1} ##2}% -\expandafter\algocf@mkcmd\csname algocf@u#1\endcsname[2]{% \uIf{}{} - \csname #1@ifthen\endcsname{##1}\csname#1@noend\endcsname{##2}}% -% + \algocf@newcmdside{l#1}3{\csname #1@ifthen\endcsname{##2} ##3\@endalgocfline\ifArgumentEmpty{##1}\relax{##1}\strut\par}% + \algocf@newcmdside{u#1}3{\csname #1@ifthen\endcsname{##2}\ifArgumentEmpty{##1}\relax{ ##1}\csname #1@noend\endcsname{##3}}% %%%% ElseIf {} endif -% -\@ifundefined{algocf@#2}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% -% side text or not? -\expandafter\def\csname#2\endcsname{% ElseIf - \@ifnextchar({\csname algocf@#2opt\endcsname}{\csname algocf@#2\endcsname}}% -% with side text -\expandafter\def\csname algocf@#2opt\endcsname(##1)##2##3{% \ElseIf(){}{} - \csname #2@elseif\endcsname{##2} ##1\csname #1@endif\endcsname{##3}}% -% without side text -\expandafter\algocf@mkcmd\csname algocf@#2\endcsname[2]{% \ElseIf{}{} - \csname #2@elseif\endcsname{##1}\csname #1@endif\endcsname{##2}}% -% + \algocf@newcmdside{#2} 3{\csname #2@elseif\endcsname{##2}\relax\ifArgumentEmpty{##1}\relax{ ##1}\csname #1@endif\endcsname{##3}}% %%%% ElseIf -% -% side text or not? -\expandafter\def\csname l#2\endcsname{% lElseIf - \@ifnextchar({\csname algocf@l#2opt\endcsname}{\csname algocf@l#2\endcsname}}% -\expandafter\def\csname u#2\endcsname{% uElseIf - \@ifnextchar({\csname algocf@u#2opt\endcsname}{\csname algocf@u#2\endcsname}}% -% with side text -\expandafter\def\csname algocf@l#2opt\endcsname(##1)##2##3{% \lElseIf(){}{} - \csname #2@elseif\endcsname{##2} ##3\algocf@endline\ ##1\par}% -\expandafter\def\csname algocf@u#2opt\endcsname(##1)##2##3{% \uElseIf(){}{} - \csname #2@elseif\endcsname{##2} ##1\csname #1@noend\endcsname{##3}}% -% without side text -\expandafter\algocf@mkcmd\csname algocf@l#2\endcsname[2]{% \lElseIf{}{} - \csname #2@elseif\endcsname{##1} ##2}% -\expandafter\algocf@mkcmd\csname algocf@u#2\endcsname[2]{% \uElseIf{}{} - \csname #2@elseif\endcsname{##1}\csname #1@noend\endcsname{##2}}% -% + \algocf@newcmdside{l#2}3{\csname #2@elseif\endcsname{##2} ##3\@endalgocfline\ifArgumentEmpty{##1}\relax{##1}\strut\par}% + \algocf@newcmdside{u#2}3{\csname #2@elseif\endcsname{##2}\relax\ifArgumentEmpty{##1}\relax{ ##1}\csname #1@noend\endcsname{##3}}% %%%% Else {} endif -% -\@ifundefined{algocf@#3}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% -% side text or not? -\expandafter\def\csname#3\endcsname{% Else - \@ifnextchar({\csname algocf@#3opt\endcsname}{\csname algocf@#3\endcsname}}% -% with side text -\expandafter\def\csname algocf@#3opt\endcsname(##1)##2{% \Else(){} - \csname #3@else\endcsname\ ##1\csname #1@endif\endcsname{##2}}% -% without side text -\expandafter\algocf@mkcmd\csname algocf@#3\endcsname[1]{% \Else{} - \csname #3@else\endcsname\csname #1@endif\endcsname{##1}}% -% + \algocf@newcmdside{#3} 2{\csname #3@else\endcsname\ifArgumentEmpty{##1}\relax\ ##1\csname #1@endif\endcsname{##2}}% %%%% Else -% -% side text or not? -\expandafter\def\csname l#3\endcsname{% lElse - \@ifnextchar({\csname algocf@l#3opt\endcsname}{\csname algocf@l#3\endcsname}}% -\expandafter\def\csname u#3\endcsname{% uElse - \@ifnextchar({\csname algocf@u#3opt\endcsname}{\csname algocf@u#3\endcsname}}% -% with side text -\expandafter\def\csname algocf@l#3opt\endcsname(##1)##2{% \lElse(){} - \csname #3@else\endcsname\ ##2\algocf@endline\ ##1\par}% -\expandafter\def\csname algocf@u#3opt\endcsname(##1)##2{% \uElse(){} - \csname #3@else\endcsname\ ##1\csname #1@noend\endcsname{##2}}% -% without side text -\expandafter\algocf@mkcmd\csname algocf@l#3\endcsname[1]{% \lElse{} - \csname #3@else\endcsname\ ##1}% -\expandafter\algocf@mkcmd\csname algocf@u#3\endcsname[1]{% \uElse{} - \csname #3@else\endcsname\csname #1@noend\endcsname{##1}}% -}% + \algocf@newcmdside{l#3}2{\csname #3@else\endcsname\ ##2\@endalgocfline\ifArgumentEmpty{##1}\relax{##1}\strut\par}% + \algocf@newcmdside{u#3}2{\csname #3@else\endcsname \ifArgumentEmpty{##1}\relax{\ ##1\relax}\csname #1@noend\endcsname{##2}}% +}% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % For macros % \newcommand{\SetKwFor}[4]{% -\@ifundefined{algocf@#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% -% side text or not? -\expandafter\def\csname#1\endcsname{%For - \@ifnextchar({\csname algocf@#1opt\endcsname}{\csname algocf@#1\endcsname}}% -\expandafter\def\csname l#1\endcsname{%For - \@ifnextchar({\csname algocf@l#1opt\endcsname}{\csname algocf@l#1\endcsname}}% -% with side text -\expandafter\def\csname algocf@#1opt\endcsname(##1)##2##3{% \For(){}{} - \KwSty{#2} \ArgSty{##2} \KwSty{#3} ##1\algocf@block{##3}{\@algocf@endoption{#4}}}% -\expandafter\def\csname algocf@l#1opt\endcsname(##1)##2##3{% \lFor(){}{} - \KwSty{#2} \ArgSty{##2} \KwSty{#3} ##3\algocf@endline\ ##1\par}% -% without side text -\expandafter\algocf@mkcmd\csname algocf@#1\endcsname[2]{% \For{}{} - \KwSty{#2} \ArgSty{##1} \KwSty{#3}\algocf@block{##2}{\@algocf@endoption{#4}}}% -\expandafter\algocf@mkcmd\csname algocf@l#1\endcsname[2]{% \lFor{}{} - \KwSty{#2} \ArgSty{##1} \KwSty{#3} ##2}% + \algocf@newcmdside{#1} 3{\KwSty{#2}\algocf@scond\ArgSty{##2}\algocf@econd\KwSty{#3}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##3}{#4}}% + \algocf@newcmdside{l#1}3{\KwSty{#2}\algocf@scond\ArgSty{##2}\algocf@econd\KwSty{#3} ##3\@endalgocfline\ifArgumentEmpty{##1}\relax{##1}\strut\par}% }% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Repeat macros % +\newsavebox{\algocf@untilbox}% to handle width of until keyword needed to have good skip + % for line numbers +\newskip\algocf@skipuntil \newcommand{\SetKwRepeat}[3]{% -\@ifundefined{algocf@#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% -% side text or not? -\expandafter\def\csname#1\endcsname{% Repeat - \@ifnextchar({\csname algocf@#1opt\endcsname}{\csname algocf@#1\endcsname}}% -\expandafter\def\csname l#1\endcsname{% lRepeat - \@ifnextchar({\csname algocf@l#1opt\endcsname}{\csname algocf@l#1\endcsname}}% -% with side text -\expandafter\def\csname algocf@#1opt\endcsname(##1)##2##3{% \Repeat(){}{} - \KwSty{#2} ##1\algocf@group{##3}\KwSty{#3} \ArgSty{##2}% - \@ifnextchar({\csname algocf@#1optopt\endcsname}{\@endalgoln}% -}% -\expandafter\def\csname algocf@#1optopt\endcsname(##1){% \Repeat(){}{}() - ##1\@endalgoln}% -\expandafter\def\csname algocf@l#1opt\endcsname(##1)##2##3{% \lRepeat(){}{} - \KwSty{#2} ##3 \KwSty{#3} \ArgSty{##2}\algocf@endline\ ##1\par}% -% without side text -\expandafter\algocf@mkcmd\csname algocf@#1\endcsname[2]{% \Repeat{}{} - \KwSty{#2}\algocf@group{##2}\KwSty{#3} \ArgSty{##1}% - \@ifnextchar({\csname algocf@#1optopt\endcsname}{\@endalgoln}% -}% -\expandafter\algocf@mkcmd\csname algocf@l#1\endcsname[2]{% \lRepeat{}{} - \KwSty{#2} ##2 \KwSty{#3} \ArgSty{##1}}% + \algocf@newcmdsides{#1}{3}{% + \sbox\algocf@untilbox{\KwSty{#3}\algocf@scond}\algocf@skipuntil=\wd\algocf@untilbox% + \KwSty{#2}\ifArgumentEmpty{##1}\relax{##1}\algocf@group{##3}% + \KwSty{#3}\algocf@scond% until keyword and start condition typo + \advance\skiptotal by\algocf@skipuntil% + \ArgSty{##2}% + \advance\skiptotal by-\algocf@skipuntil% + \algocf@ucond% + \algocf@skipuntil=0pt% reset counter + }{\@endalgocfline}{\strut\par}% + \algocf@newcmdside{l#1}3{\KwSty{#2} ##3 \KwSty{#3}\algocf@scond\ArgSty{##2}\algocf@ucond\@endalgocfline\ifArgumentEmpty{##1}\relax{ ##1}\strut\par}% }% % % @@ -1841,6 +1924,7 @@ \addtolength{\hsize}{\algomargin}% }% % +\newcommand{\algocf@makecaption@plainruled}[2]{\algocf@makecaption@plain{#1}{#2}}% \newcommand{\algocf@makecaption@tworuled}[2]{\algocf@makecaption@ruled{#1}{#2}}% \newcommand{\algocf@makecaption@algoruled}[2]{\algocf@makecaption@ruled{#1}{#2}}% \newcommand{\algocf@makecaption@boxruled}[2]{\algocf@makecaption@ruled{#1}{#2}}% @@ -1854,9 +1938,10 @@ \newlength{\algotitleheightruledefault}\setlength{\algotitleheightruledefault}{0.8pt}% \newlength{\algotitleheightrule}\setlength{\algotitleheightrule}{\algotitleheightruledefault}% \newcommand{\algocf@caption@plain}{\vskip\AlCapSkip\box\algocf@capbox}% +\newcommand{\algocf@caption@plainruled}{\algocf@caption@plain}% \newcommand{\algocf@caption@boxed}{\vskip\AlCapSkip\box\algocf@capbox}% \newcommand{\algocf@caption@ruled}{\box\algocf@capbox\kern\interspacetitleruled\hrule height\algotitleheightrule depth0pt\kern\interspacealgoruled}% -\newcommand{\algocf@caption@tworuled}{\box\algocf@capbox\kern\interspacetitleruled}% +\newcommand{\algocf@caption@tworuled}{\box\algocf@capbox\hrule height0pt depth0pt\kern\interspacealgoruled}% \newcommand{\algocf@caption@algoruled}{\algocf@caption@ruled}% \newcommand{\algocf@caption@boxruled}{% \addtolength{\hsize}{-0.8pt}% @@ -1891,7 +1976,7 @@ \renewcommand{\theHalgocf}{\algocf@algocfref}}%else if SetAlgoRefName done, take this name as ref. \hyper@refstepcounter{algocf}%set algocf as category of ref }% - \algocf@latexcaption{#1}[#2]{#3}% call original caption + \algocf@latexcaption{#1}[{#2}]{{#3}}% call original caption }% % % beamer define is own caption overrinding latex caption! @@ -2008,8 +2093,8 @@ \def\fps@algocf{htbp}% % default \def\ftype@algocf{10}% % float type \def\ext@algocf{\algocf@list} % loa by default, lof if figure option used -\newcommand{\fnum@algocf}[1]{\AlCapSty{\AlCapFnt\algorithmcfname\nobreakspace\thealgocf}}% -\newcommand{\algocf@resetfnum}{\renewcommand{\fnum@algocf}[1]{\AlCapSty{\AlCapFnt\algorithmcfname\nobreakspace\thealgocf}}}% +\newcommand{\fnum@algocf}{\AlCapSty{\AlCapFnt\algorithmcfname\nobreakspace\thealgocf}}% +\newcommand{\algocf@resetfnum}{\renewcommand{\fnum@algocf}{\AlCapSty{\AlCapFnt\algorithmcfname\nobreakspace\thealgocf}}}% \newenvironment{algocf}% % float environment for algorithms {\@float{algocf}}% {\end@float}% @@ -2063,6 +2148,9 @@ \def\@algocf@pre@boxruled{\noindent\begin{lrbox}{\algocf@algoframe}}% \def\@algocf@post@boxruled{\end{lrbox}\framebox[\hsize]{\box\algocf@algoframe}\par}% \def\@algocf@capt@boxruled{above}% +\def\@algocf@pre@plainruled{\@algocf@pre@ruled}% action to be done before printing the algo. +\def\@algocf@post@plainruled{\@algocf@post@ruled\kern\interspacealgoruled}% action to be done before printing the algo. +\def\@algocf@capt@plainruled{under}% % \newcommand{\noalgocaption}{\def\@algocf@capt@ruled{none}} % @@ -2135,6 +2223,7 @@ %%%%%%%%%%%%%%%%%%% % %% at the beginning of algocf or figure environment +\newenvironment{algomathdisplay}{\[}{\@endalgocfline\]\ifthenelse{\boolean{algocf@linesnumbered}}{\nl}{\relax}}% \newcommand{\@algocf@start}{% \@algoskip% \begin{lrbox}{\algocf@algobox}% @@ -2148,6 +2237,7 @@ \raggedright\AlFnt{}% \ifthenelse{\boolean{algocf@slide}}{\IncMargin{\skipalgocfslide}}{}% \@algoinsideskip% +% \let\@emathdisplay=\]\def\]{\algocf@endline\@emathdisplay\nl}% }% % %% at the end of algocf or figure environment @@ -2165,6 +2255,7 @@ \setlength{\hsize}{\algowidth}% \lineskip\normallineskip\setlength{\skiptotal}{\@defaultskiptotal}% \let\;=\@mathsemicolon% + \let\]=\@emathdisplay% }% % %%%%%%%%%%%%%%%%%%%% @@ -2405,6 +2496,7 @@ % french keywords % %\SetKwInOut{AlgDonnees}{Donn\'ees}\SetKwInOut{AlgRes}{R\'esultat} +\SetKwHangingKw{HDonnees}{Donnees$\rightarrow$} \SetKwInput{Donnees}{Donn\'ees}% \SetKwInput{Res}{R\'esultat}% \SetKwInput{Entree}{Entr\'ees}% @@ -2415,15 +2507,16 @@ \SetKwRepeat{Repeter}{r\'ep\'eter}{jusqu'\`a}% % \SetKwIF{Si}{SinonSi}{Sinon}{si}{alors}{sinon si}{sinon}{fin si}% -\SetKwSwitch{Suivant}{Cas}{Autre}{suivant}{faire}{cas o\`u}{autres cas}{fin d'alternative}% +\SetKwSwitch{Suivant}{Cas}{Autre}{suivant}{faire}{cas o\`u}{autres cas}{fin cas}{fin d'alternative}% \SetKwFor{Pour}{pour}{faire}{fin pour}% -\SetKwFor{PourPar}{pour}{faire en parallèle}{fin pour}% +\SetKwFor{PourPar}{pour}{faire en parall\`ele}{fin pour}% \SetKwFor{PourCh}{pour chaque}{faire}{fin pour chaque}% \SetKwFor{PourTous}{pour tous les}{faire}{fin pour tous}% \SetKwFor{Tq}{tant que}{faire}{fin tq}% % % english keywords % +\SetKwHangingKw{KwHData}{Data$\rightarrow$} \SetKwInput{KwIn}{Input}% \SetKwInput{KwOut}{Output}% \SetKwInput{KwData}{Data}% @@ -2435,7 +2528,7 @@ \SetKwRepeat{Repeat}{repeat}{until}% % \SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{end if}% -\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{end switch}% +\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{end case}{end switch}% \SetKwFor{For}{for}{do}{end for}% \SetKwFor{ForPar}{for}{do in parallel}{end forpar} \SetKwFor{ForEach}{foreach}{do}{end foreach}% @@ -2455,7 +2548,7 @@ \SetKwRepeat{Wiederh}{wiederhole}{bis}%Repeat % \SetKwIF{Wenn}{SonstWenn}{Sonst}{wenn}{dann}{sonst wenn}{sonst}{Ende wenn}%gIf -\SetKwSwitch{Unterscheide}{Fall}{Anderes}{unterscheide}{tue}{Fall}{sonst}{Ende Unt.}%Switch +\SetKwSwitch{Unterscheide}{Fall}{Anderes}{unterscheide}{tue}{Fall}{sonst}{Ende Fall}{Ende Unt.}%Switch \SetKwFor{Fuer}{f\"ur}{tue}{Ende f\"ur}%For \SetKwFor{FuerPar}{f\"ur}{tue gleichzeitig}{Ende gleichzeitig}%ForPar \SetKwFor{FuerJedes}{f\"ur jedes}{tue}{Ende f\"ur}%ForEach @@ -2481,7 +2574,7 @@ \SetKwRepeat{Repita}{repita}{at\'{e}}% % \SetKwIF{Se}{SenaoSe}{Senao}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim se}% -\SetKwSwitch{Selec}{Caso}{Outro}{selecione}{fa\c{c}a}{caso}{sen\~{a}o}{fim selec}% +\SetKwSwitch{Selec}{Caso}{Outro}{selecione}{fa\c{c}a}{caso}{sen\~{a}o}{fim caso}{fim selec}% \SetKwFor{Para}{para}{fa\c{c}a}{fim para}% \SetKwFor{ParaPar}{para}{fa\c{c}a em paralelo}{fim para} \SetKwFor{ParaCada}{para cada}{fa\c{c}a}{fim para cada}% @@ -2498,15 +2591,57 @@ \SetKw{KwRitorna}{ritorna}% \SetKw{Ritorna}{ritorna}% \SetKwBlock{Inizio}{inizio}{fine}% -\SetKwRepeat{Ripeti}{ripeti}{finché}% +\SetKwRepeat{Ripeti}{ripeti}{finch\'e}% % \SetKwIF{Sea}{AltSe}{Altrimenti}{se}{allora}{altrimenti se}{allora}{fine se}% -\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{endsw}% +\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{end case}{endsw}% \SetKwFor{Per}{per}{fai}{fine per}% \SetKwFor{PerPar}{per}{fai in parallelo}{fine per}% \SetKwFor{PerCiascun}{per ciascun}{fai}{fine per ciascun}% \SetKwFor{PerTutti}{per tutti i}{fai}{fine per tutti}% -\SetKwFor{Finche}{finché}{fai}{fine finché}% +\SetKwFor{Finche}{finch\'e}{fai}{fine finch\'e}% +% +% --- Spanish keywords +% +\SetKwInput{Datos}{Datos} +\SetKwInput{Resultado}{Resultado} +\SetKwInput{Entrada}{Entrada} +\SetKwInput{Salida}{Salida} +\SetKw{KwA}{a} +\SetKw{KwDevolver}{devolver} +\SetKw{Devolver}{devolver} +\SetKwBlock{Inicio}{inicio}{fin} +\SetKwIF{SSi}{EnOtroCasoSi}{EnOtroCaso}{si}{entonces}{sin\'o, si}{sin\'o}{fin si} +\SetKwSwitch{Seleccionar}{Caso}{Otro}{seleccionar}{hacer}{caso}{sin\'o}{fin caso}{fin seleccionar} +\SetKwFor{Para}{para}{hacer}{fin para} +\SetKwFor{ParaPara}{par}{hacer en paralelo}{fin para} +\SetKwFor{EnParalelo}{para}{hacer en paralelo}{fin para} +\SetKwFor{Mientras}{mientras}{hacer}{fin mientras} +\SetKwFor{ParaCada}{para cada}{hacer}{fin para cada} +\SetKwFor{ParaTodo}{para todo}{hacer}{fin para todo} +\SetKwRepeat{Repetir}{repetir}{hasta que} +% +% Croatian keywords +% +\SetKwInput{KwUlaz}{Ulaz}%KwIn +\SetKwInput{KwIzlaz}{Izlaz}%KwOut +\SetKwInput{KwPodaci}{Podaci}%KwData +\SetKwInput{KwRezultat}{Rezultat}%KwResult +\SetKw{KwDo}{do}%KwTo +\SetKw{KwVrati}{vrati}%KwRet +\SetKw{Vrati}{vrati}%Return +\SetKwBlock{Pocetak}{po\v{c}etak}{kraj}%Begin +\SetKwRepeat{Ponavljaj}{ponavljaj}{dok ne bude}%Repeat +% +\SetKwIF{Ako}{InaceAko}{Inace}{ako}{onda}{ina\v{c}e ako}{ina\v{c}e}{kraj}%gIf +\SetKwSwitch{Granaj}{Slucaj}{Inace}{granaj}{\v{c}ini}{slu\v{c}aj}{ina\v{c}e}{kraj}{kraj}%Switch +\SetKwFor{Za}{za}{\v{c}ini}{kraj}%For +\SetKwFor{ZaPar}{za}{izvr\v{s}avaj paralelno}{kraj}%ForPar +\SetKwFor{ZaSvaki}{za svaki}{\v{c}ini}{kraj}%mForEach +\SetKwFor{ZaSvaku}{za svaku}{\v{c}ini}{kraj}%fForEach +\SetKwFor{ZaSvako}{za svako}{\v{c}ini}{kraj}%nForEach +\SetKwFor{ZaSve}{za sve}{\v{c}ini}{kraj}%ForAll +\SetKwFor{Dok}{dok}{\v{c}ini}{kraj}%While % % --- End %} @@ -2527,9 +2662,9 @@ \SetKwRepeat{Repeat}{r\'ep\'eter}{jusqu'\`a}% % \SetKwIF{If}{ElseIf}{Else}{si}{alors}{sinon si}{sinon}{fin si}% -\SetKwSwitch{Switch}{Case}{Other}{suivant}{faire}{cas o\`u}{autres cas}{fin d'alternative}% +\SetKwSwitch{Switch}{Case}{Other}{suivant}{faire}{cas o\`u}{autres cas}{fin cas}{fin d'alternative}% \SetKwFor{For}{pour}{faire}{fin pour}% -\SetKwFor{ForPar}{pour}{faire en parallèle}{fin pour}% +\SetKwFor{ForPar}{pour}{faire en parall\`ele}{fin pour}% \SetKwFor{ForEach}{pour chaque}{faire}{fin pour chaque}% \SetKwFor{ForAll}{pour tous les}{faire}{fin pour tous}% \SetKwFor{While}{tant que}{faire}{fin tq}% @@ -2546,14 +2681,14 @@ \SetKwRepeat{Repeat}{wiederhole}{bis}%Repeat % \SetKwIF{If}{ElseIf}{Else}{wenn}{dann}{sonst wenn}{sonst}{Ende wenn}%gIf -\SetKwSwitch{Switch}{Case}{Other}{unterscheide}{tue}{Fall}{sonst}{Ende Unt.}%Switch +\SetKwSwitch{Switch}{Case}{Other}{unterscheide}{tue}{Fall}{sonst}{Ende Fall}{Ende Unt.}%Switch \SetKwFor{For}{f\"ur}{tue}{Ende f\"ur}%For \SetKwFor{ForPar}{f\"ur}{tue gleichzeitig}{Ende gleichzeitig}%ForPar \SetKwFor{ForEach}{f\"ur jedes}{tue}{Ende f\"ur}%ForEach \SetKwFor{ForAll}{f\"ur alle}{tue}{Ende f\"ur}%ForAll \SetKwFor{While}{solange}{tue}{Ende solange}%While }{}% -\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{portugues}}{% +\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{portuguese}}{% \SetKwInput{KwIn}{Entrada}% \SetKwInput{KwOut}{Sa\'{i}da}% \SetKwInput{KwData}{Dados}% @@ -2565,7 +2700,7 @@ \SetKwRepeat{Repeat}{repita}{at\'{e}}% % \SetKwIF{If}{ElseIf}{Else}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim se}% -\SetKwSwitch{Switch}{Case}{Other}{selecione}{fa\c{c}a}{caso}{sen\~{a}o}{fim selec}% +\SetKwSwitch{Switch}{Case}{Other}{selecione}{fa\c{c}a}{caso}{sen\~{a}o}{fim caso}{fim selec}% \SetKwFor{For}{para}{fa\c{c}a}{fim para}% \SetKwFor{ForPar}{para}{fa\c{c}a em paralelo}{fim para} \SetKwFor{ForEach}{para cada}{fa\c{c}a}{fim para cada}% @@ -2581,21 +2716,61 @@ \SetKw{KwRet}{ritorna}% \SetKw{Return}{ritorna}% \SetKwBlock{Begin}{inizio}{fine}% -\SetKwRepeat{Repeat}{ripeti}{finché}% +\SetKwRepeat{Repeat}{ripeti}{finch\'e}% % \SetKwIF{If}{ElseIf}{Else}{se}{allora}{altrimenti se}{allora}{fine se}% -\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{endsw}% +\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{end case}{endsw}% \SetKwFor{For}{per}{fai}{fine per}% \SetKwFor{ForPar}{per}{fai in parallelo}{fine per}% \SetKwFor{ForEach}{per ciascun}{fai}{fine per ciascun}% \SetKwFor{ForAll}{per tutti i}{fai}{fine per tutti}% -\SetKwFor{While}{finché}{fai}{fine finché}% +\SetKwFor{While}{finch\'e}{fai}{fine finch\'e}% +}{}% +\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{spanish}}{% +\SetKwInput{KwIn}{Entrada}% +\SetKwInput{KwOut}{Salida}% +\SetKwInput{KwData}{Datos}% +\SetKwInput{KwResult}{Resultado}% +\SetKw{KwTo}{a}% +\SetKw{KwRet}{devolver}% +\SetKw{Return}{devolver}% +\SetKwBlock{Begin}{inicio}{fin}% +\SetKwRepeat{Repeat}{repetir}{hasta que}% +% +\SetKwIF{If}{ElseIf}{Else}{si}{entonces}{sin\'o, si}{en otro caso}{fin si} +\SetKwSwitch{Switch}{Case}{Other}{seleccionar}{hacer}{caso}{sin\'o}{fin caso}{fin seleccionar} +\SetKwFor{For}{per}{fai}{fine per}% +\SetKwFor{ForPar}{par}{hacer in paralelo}{fin para}% +\SetKwFor{ForEach}{para cada}{hacer}{fin para cada} +\SetKwFor{ForAll}{para todo}{hacer}{fin para todo} +\SetKwFor{While}{mientras}{hacer}{fin mientras} +}{}% +% +\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{croatian}}{% +\SetKwInput{KwIn}{Ulaz}%KwIn +\SetKwInput{KwOut}{Izlaz}%KwOut +\SetKwInput{KwData}{Podaci}%KwData +\SetKwInput{KwResult}{Rezultat}%KwResult +\SetKw{KwTo}{do}%KwTo +\SetKw{KwRet}{vrati}%KwRet +\SetKw{Return}{vrati}%Return +\SetKwBlock{Begin}{po\v{c}etak}{kraj}%Begin +\SetKwRepeat{Repeat}{ponavljaj}{dok ne bude}%Repeat +% +\SetKwIF{If}{ElseIf}{Else}{ako}{onda}{ina\v{c}e ako}{ina\v{c}e}{kraj}%gIf +\SetKwSwitch{Switch}{Case}{Other}{granaj}{\v{c}ini}{slu\v{c}aj}{ina\v{c}e}{kraj}{kraj}%Switch +\SetKwFor{For}{za}{\v{c}ini}{kraj}%For +\SetKwFor{ForPar}{za}{izvr\v{s}avaj paralelno}{kraj}%ForPar +\SetKwFor{ForEach}{za svaki}{\v{c}ini}{kraj}%ForEach +\SetKwFor{ForAll}{za sve}{\v{c}ini}{kraj}%ForAll +\SetKwFor{While}{dok}{\v{c}ini}{kraj}%While }{}% % %%%% old commands compatibility % \ifthenelse{\boolean{algocf@oldcommands}}{% \newcommand{\SetNoLine}{\SetAlgoNoLine}% +\newcommand{\SetNoline}{\SetAlgoNoLine}% \newcommand{\SetVline}{\SetAlgoVlined}% \newcommand{\SetLine}{\SetAlgoLined}% % @@ -2619,12 +2794,18 @@ \newcommand{\restylealgo}[1]{\RestyleAlgo{#1}}% % \newcommand{\Titleofalgo}[1]{\TitleOfAlgo{#1}}% +% \SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{endif} +\newcommand{\SetKwIf}[6]{\SetKwIF{#1}{#2#1}{#2}{#3}{#4}{#5 #1}{#5}{#6}} +% \SetKwIF{gSi}{gSinonSi}{gSinon}{si}{alors}{sinon si}{sinon}{fin si}% \SetKwIF{gIf}{gElsIf}{gElse}{if}{then}{else if}{else}{end if}% \SetKwIF{gIf}{gElseIf}{gElse}{if}{then}{else if}{else}{end if}% \SetKwIF{gWenn}{gSonstWenn}{gSonst}{wenn}{dann}{sonst wenn}{sonst}{Ende wenn}%gIf \SetKwIF{gSe}{gSenaoSe}{gSenao}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim se}% \SetKwIF{gSea}{gAltSe}{gAltrimenti}{se}{allora}{altrimenti se}{allora}{fine se}% +\SetKw{Ret}{return}% +\SetKwInput{Data}{Data}% +\SetKwInput{Result}{Result}% }{% \relax% }% diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds index 9ba6ddd3940..6911655d4f5 100755 --- a/Master/tlpkg/libexec/ctan2tds +++ b/Master/tlpkg/libexec/ctan2tds @@ -86,6 +86,7 @@ chomp ($Build = `cd $Master/../Build/source && pwd`); 'aecc', "&MAKEflatten", 'akktex', "&MAKEflatten", 'alatex', "die 'skipping, 1995 LaTeX generalization'", + 'algorithm2e', "&MAKEflatten", 'algorithmicx',"&MAKEnosymlinks", 'allrunes', "&MAKEflatten", 'alterqcm', "&MAKEaqcm", |