On Mon, November 8, 2004 14:04, Juergen Spitzmueller said:
> Also sprach Frederic F. Leymarie:
>> # Input lyx algorithm definitions
>> Input algorithm.inc
>
> Do you have this also (in the layouts directory?)

here it follows (I am including algolyx.sty after that, as it
is called in the algorithm.inc file)

-----------------

> more algorithm.inc
# Algorithm textclass definition file. Taken from initial LyX source code
# Author:  BG <[EMAIL PROTECTED]>
# Version: 0.3

# This file contains a text style related to the algorithm and algorithmic
# packages, in order to write some algorithms through lyx.

Style Algorithm
#  Margin               First_Dynamic
  LatexType             Item_Environment
  LatexName             algor
  NextNoIndent          1
  LeftMargin            MM
  LabelSep              xxx
  ItemSep               0
  TopSep                0.5
  BottomSep             0.5
  ParSep                0
  Align                 Block
  AlignPossible         Block, Left
  LabelType             Manual
  LabelString           MM
  FreeSpacing           0

  Font
    Size                tiny
  EndFont

  # label font definition
  LabelFont
    Series              Bold
  EndFont

  Preamble
    \usepackage{algolyx}
  EndPreamble
End

Style Algorithm_(num)
  CopyStyle             Algorithm
  LatexParam            [1]

End

---------------

> more algolyx.sty
%% Version: 0.3

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{algolyx}[2000/11/11 Algorithm support for LyX]
% \DeclareOption{noend}{ \usepackage[noend]{algorithmic} }

%% Needed packages
%% The algorithmic package is included later...
\RequirePackage{algorithm}

%% Default screen keywords definition
\newcommand{\keyif}{if}
\newcommand{\keyelseif}{elseif}
\newcommand{\keyelse}{else}
\newcommand{\keyendif}{endif}
\newcommand{\keyfor}{for}
\newcommand{\keyforall}{forall}
\newcommand{\keywhile}{while}
\newcommand{\keyrepeat}{repeat}
\newcommand{\keyuntil}{until}
\newcommand{\keyendfor}{endfor}
\newcommand{\keyendwhile}{endwhile}
\newcommand{\keyloop}{loop}
\newcommand{\keyendloop}{endloop}
\newcommand{\keyrequire}{Require:}
\newcommand{\keyensure}{Ensure:}

%% Lang keywords definition
[EMAIL PROTECTED]
  \renewcommand{\keyif}{si}
  \renewcommand{\keyelseif}{sinonsi}
  \renewcommand{\keyelse}{sinon}
  \renewcommand{\keyendif}{finsi}
  \renewcommand{\keyfor}{pour}
  \renewcommand{\keyforall}{pourtout}
  \renewcommand{\keywhile}{tantque}
  \renewcommand{\keyrepeat}{répéter}
  \renewcommand{\keyuntil}{jusqu'à}
  \renewcommand{\keyendfor}{finpour}
  \renewcommand{\keyendwhile}{fintantque}
  \renewcommand{\keyloop}{boucle}
  \renewcommand{\keyendloop}{finboucle}
  \renewcommand{\keyrequire}{Contexte}
  \renewcommand{\keyensure}{Vérifier}

  \renewcommand{\algorithmicrequire}{\textbf{Contexte :}}
  \renewcommand{\algorithmicensure}{\textbf{Vérifier :}}
  % \newcommand{\algorithmiccomment}[1]{\{#1\}}
  \renewcommand{\algorithmicend}{\textbf{fin}}
  \renewcommand{\algorithmicif}{\textbf{si}}
  \renewcommand{\algorithmicthen}{\textbf{alors}}
  \renewcommand{\algorithmicelse}{\textbf{sinon}}
  \renewcommand{\algorithmicfor}{\textbf{pour}}
  \renewcommand{\algorithmicforall}{\textbf{pour tout}}
  \renewcommand{\algorithmicdo}{\textbf{faire}}
  \renewcommand{\algorithmicwhile}{\textbf{tant que}}
  \renewcommand{\algorithmicloop}{\textbf{boucle}}
  \renewcommand{\algorithmicrepeat}{\textbf{répéter}}
  \renewcommand{\algorithmicuntil}{\textbf{jusqu'à}}

  \renewcommand{\listalgorithmname}{Liste des algorithmes}
  \floatname{algorithm}{Algorithme}
}
[EMAIL PROTECTED]
}

%% Lang setting command
[EMAIL PROTECTED]
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
  }}
}
%% Commands with comments
[EMAIL PROTECTED]
  \ifthenelse{\equal{#1}{\keyif}}{\IF[#3]{#2}}{%
  \ifthenelse{\equal{#1}{\keyelseif}}{\ELSIF[#3]{#2}}{%
  \ifthenelse{\equal{#1}{\keyfor}}{\FOR[#3]{#2}}{%
  \ifthenelse{\equal{#1}{\keyforall}}{\FORALL[#3]{#2}}{%
  \ifthenelse{\equal{#1}{\keywhile}}{\WHILE[#3]{#2}}{%
  \ifthenelse{\equal{#1}{\keyuntil}}{\UNTIL{#2}\COMMENT{#3}}{%
  \ifthenelse{\equal{#1}{\keyelse}}{\ELSE[#3]}{%
  \ifthenelse{\equal{#1}{\keyendif}}{\ENDIF\ \COMMENT{#3}}{%
  \ifthenelse{\equal{#1}{\keyendfor}}{\ENDFOR\ \COMMENT{#3}}{%
  \ifthenelse{\equal{#1}{\keyendwhile}}{\ENDWHILE\ \COMMENT{#3}}{%
  \ifthenelse{\equal{#1}{\keyrepeat}}{\REPEAT[#3]}{%
  \ifthenelse{\equal{#1}{\keyloop}}{\LOOP[#3]}{%
  \ifthenelse{\equal{#1}{\keyendloop}}{\ENDLOOP\ \COMMENT{#3}}{%
  \ifthenelse{\equal{#1}{\keyrequire}}{\REQUIRE #2}{%
  \ifthenelse{\equal{#1}{\keyensure}}{\ENSURE #2}{%
  \STATE #2 \COMMENT{#3}}}}}}}}}}}}}}}}
}

%% Commands without comments
[EMAIL PROTECTED]
  \ifthenelse{\equal{#1}{\keyif}}{\IF{#2}}{%
  \ifthenelse{\equal{#1}{\keyelseif}}{\ELSIF{#2}}{%
  \ifthenelse{\equal{#1}{\keyfor}}{\FOR{#2}}{%
  \ifthenelse{\equal{#1}{\keyforall}}{\FORALL{#2}}{%
  \ifthenelse{\equal{#1}{\keywhile}}{\WHILE{#2}}{%
  \ifthenelse{\equal{#1}{\keyuntil}}{\UNTIL{#2}}{%
  \ifthenelse{\equal{#1}{\keyelse}}{\ELSE}{%
  \ifthenelse{\equal{#1}{\keyendif}}{\ENDIF}{%
  \ifthenelse{\equal{#1}{\keyendfor}}{\ENDFOR}{%
  \ifthenelse{\equal{#1}{\keyendwhile}}{\ENDWHILE}{%
  \ifthenelse{\equal{#1}{\keyrepeat}}{\REPEAT}{%
  \ifthenelse{\equal{#1}{\keyloop}}{\LOOP}{%
  \ifthenelse{\equal{#1}{\keyendloop}}{\ENDLOOP}{%
  \ifthenelse{\equal{#1}{\keyrequire}}{\REQUIRE #2}{%
  \ifthenelse{\equal{#1}{\keyensure}}{\ENSURE #2}{%
  \STATE #2}}}}}}}}}}}}}}}
}

%% The core commands depend on the comments delimiters definitions
[EMAIL PROTECTED]

  %% Commands with comments
  \def\doalgwca[##1]##2##3#1{ \doalgwc[##1]{##2}##3 }
  \def\doalgwc[##1]##2##3#2{%
   \let\item=\stditem
   [EMAIL PROTECTED]
   \let\item=\myalg
  }

  %% Commands without comments
  \def\doalgnc[##1]##2{%
   \let\item=\stditem
   [EMAIL PROTECTED]
   \let\item=\myalg
   \ignorespaces
  }

  %% Lookup the comments delimiters
  \def\algparse[##1]##2#1##3\cr{%
   \ifthenelse{\equal{##3}{}}{
    \doalgnc[##1]{##2}
   }{
    \doalgwca[##1]{##2}##3
   }
  }

  %% Process the item
  \def\algitem[##1]##2{%
   \algparse[##1]##2#1\cr
  }
}

%% Default comments definition
[EMAIL PROTECTED]


%% Counter for item deeping
\newcounter{algcount}
\setcounter{algcount}{0}

\newenvironment{algor}[1][0]
{
 [EMAIL PROTECTED]
  \begin{algorithmic}[#1]
  \let\stditem=\item
  \let\item=\myalg
 }{}
 [EMAIL PROTECTED]
}{
 [EMAIL PROTECTED]
 \ifnum \value{algcount}=0
  \let\item=\stditem
  \end{algorithmic}
 \fi
}

%% User commands
%%
%% Global package option
\def\algoption#1{%
 [EMAIL PROTECTED]
}
%% Comments delimiters definition
\def\keycomment#1#2{
 [EMAIL PROTECTED]
}
%% User lang option
\def\algolang#1{%
  [EMAIL PROTECTED]
}

%% Algorithmic package is included after the user latex preamble,
%% in order to take into account the user options.
%%
\let\realmakeatother=\makeatother
\def\makeatother{ %
 [EMAIL PROTECTED]@pack}{%
   \usepackage{algorithmic}
 }{
   [EMAIL PROTECTED]
 }
 [EMAIL PROTECTED]@lang}{}{%
  [EMAIL PROTECTED]@lang}
 }
 \let\makeatother=\realmakeatother
 \makeatother
}


%% Main command, delimited by \par
\def\myalg[#1]#2\par{
  \algtokpar
  \algise[#1]#2\end\par
  \algexec[#1]#2\par
}

%% The item command is defined according to the delimiter
\def\algtokpar{
  \def\algexec[##1]##2\par{
    \algitem[##1]{##2}\par
  }
}
\def\algtokend{
  \def\algexec[##1]##2\end##3{
    \algitem[##1]{##2}\end{##3}
  }
}
\def\algtokend{
  \def\algexec[##1]##2\end##3{
    \algitem[##1]{##2}\end{##3}
  }
}
\def\algtok#1{
  \def\algexec[##1]##2#1##3\par{
    \algitem[##1]{##2}#1##3\par
  }
}

%% Check if the token delimiter is end, item or begin
\def\algise[#1]#2\end#3\par{
  \def\l{#3}
  \ifx\l\empty
  \else
    \algtokend
  \fi
  \algisi[#1]#2\item\end
}
\def\algisi[#1]#2\item#3\end{
  \def\l{#3}
  \ifx\l\empty
  \else
    \algtok{\item}
  \fi
  \algisb[#1]#2\begin\end
}
\def\algisb[#1]#2\begin#3\end{
  \def\l{#3}
  \ifx\l\empty
  \else
    \algtok{\begin}
  \fi
}
--------------------



Reply via email to