[NTG-context] algorithms style : need \starttyping with TeX and math feature

Maurice Diamantini Maurice.Diamantini at ensta.fr
Mon Jan 3 15:52:01 CET 2005


Le 25 déc. 04, à 20:03, John Culleton a écrit :

> On Friday 24 December 2004 09:23, Mojca Miklavec wrote:
>> Maurice Diamantini wrote:
>>> Well I agree that it's no more "typing" any more!
>>> So a special option for \setuplines would be more appropriate?
>>
>> Exactly, \starttyping does exactly that what you don't want: it 
>> disables
>> math and expansion of TeX commands.
>>
>>> Also, perhaps my request is simply an option of \startlines
>>> which keep not only the lines break, but also the first
>>> spaces of each line (in a verbatim font fors these space)

Happy new year !
Thanks to Mojca and John, I use \startlines for the
algorithms environment.

In the "Algo" environment, I defined some short names command
to help dealing with indent spacing (\0, \1, ..., \5)
and with itemize like indent (i.e. space with the
same length as "- "

Here is the environment I defined. It could be better
(to keep the use of it event simpler)
But as the "père Noël" Hans give me a "Christmas present"
(see next post) It is no more usefull!

     \definestartstop[Algo][
        before={
             \start
             \tx
             \def\H{\phantom{- }}% H for Hyphen (espace correspondant à 
"- "
             \def\0{\hskip0em}  % indent 0
             \def\1{\hskip2em}  % indent 1
             \def\2{\hskip4em}  % indent 2
             \def\3{\hskip6em}  % indent 3
             \def\4{\hskip8em}  % indent 5
             \def\5{\hskip10em} % indent 6
             \setupinterlinespace[small]
             \startframedtext[
                  width=\makeupwidth,
                  framecolor=blue,
             ]
             \startlines
        },
        after={
             \stoplines
             \stopframedtext
             \stop
        },
     ]

Just a "french like" algorithm

\startAlgo
\0  Entrée :
\1   - nom de l'instance à traiter (e.g. ucp8, ...)
\1   - LDS\_Limit Nombre maximum de discordances (e.g. 1 pour LDS\_1, 
...)
\0  Sortie :
\1   - affichage des meilleures solutions primale et duale
\0  Algorithme :
\1   - initialisation :
\2      - LDS\_Counter := 0 (nombre de discordances courantes)
\2      - lecture de l'instance
\2      - propagation initiale
\1   - relaxation lagrangienne principale avec primalisations interne
\1\H   $\Rightarrow$  on connait bestDualValue,  bestPrimalValue et les 
coûts réduits
\1   - explorer le noeud racine (i.e. toutes les variables étant libres)
\1   - afficher les résultats
\stopAlgo

Thanks you very much !

Maurice



More information about the ntg-context mailing list