Article View: comp.text.tex
Article #11861A style for typesetting keywords
From: Miguel ALABAU
Date: Wed, 26 Apr 1995 00:00
Date: Wed, 26 Apr 1995 00:00
418 lines
14191 bytes
14191 bytes
Hello Netters,
As a companion to the style Programs.sty I have put on the net a short
while before, here follows a style called Keywords.sty whose main
purpose is to provide a parameterized way to typeset keywords.
This style may be used in conjunction with the Programs.sty file, but
this is not necessary.
What you can do is, for instance, to type a program where keywords
will appear boldfaced. It suffices to issue the \ProgKeywords command
(global scope), and then to type the text, for instance:
\BEGIN
\FOR I := 1 \TO 10 \DO
....
\ENDDO
\END
In this example, the keywords are commands defined in the second part
of the Keywords.sty file. If the environment is such that spaces are
obeyed (like in the verbatim environment or by using the Programs.sty
file), then keywords can be typed as is; otherwise (i.e. in normal
text) they must be typed followed by a "\" character
(e.g.: \BEGIN\ ...).
Assume now, that you want that the program above is typed with
keywords written with an emphazised font and underlined, and that
words appear in French instead of English.
Then take the same program, but just change the "\ProgKeywords"
command that precedes it to "\UFAlgoKeywords" (for: Underlined French
AlgoKeywords).
I have sorted keywords in lexicographic order.
If you need to change or add a definition go anywhere among the
keywords and type (e.g. definition of the keyword FOO):
#1{\FOO}{this is an example}[bla bla]%
Then if you chose commands where the 'F' does not appear in the
beginning of the name, any occurrence of "\FOO" is replaced by the
sentence "this is an example"; otherwise, the sentence "bla bla" will
be used.
If your wish is that the same expansion is performed for all the
commands, the omit tht fourth parameter:
#1{\FOO}{this is an example}
The commands provided are:
-------------------------------------------------------------------------
English keywords French keywords
-------------------------------------------------------------------------
\tt BOLDFACE DISPLAY \ProgKeywords \FProgKeywords
\tt NORMAL DISPLAY \ttKeywords \FttKeywords
\em DISPLAY \AlgoKeywords \FAlgoKeywords
underlined \em DISPLAY \UAlgoKeywords \UFAlgoKeywords
normal (\rm) DISPLAY \NormalKeywords \FNormalKeywords
-------------------------------------------------------------------------
As I am French, I have used English and French languages; however you
can use any couple of languages you want. I recall that if parameter 4
in keyword definition is omitted, then only the first language is
used.
The file terminates by a command that selects the default mode (in the
current case this is \UFAlgoKeywords).
OK, have fun !
Miguel
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Miguel ALABAU
LaBRI, Universite BORDEAUX I
351, cours de la Liberation 33405 TALENCE Cedex (FRANCE)
phone: (33) 56-84-69-08 / fax: (33) 56-84-66-69
e-mail: Miguel.Alabau@labri.u-bordeaux.fr
html: http://www.labri.u-bordeaux.fr/~alabau/main.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Keywords.sty======================CUT HERE==================================
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Keywords.sty Miguel Alabau, 1993, 1994
%
% Keywords for typesetting programs and algorithms
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\typeout{Document style `Keywords.sty' <1993, 1994>}
\expandafter\ifx\csname AlreadyDefined@@Keywords\endcsname\relax%
\expandafter\def\csname AlreadyDefined@@Keywords\endcsname{}%
\else\endinput\fi
\@ifundefined{reset@font}{\global\let\reset@font\relax}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% THE MACROS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%--------------------------------------------------------
% display of programs (English keywords) ---> command '\ProgKeywords'
% display of programs (French keywords) ---> command '\FProgKeywords'
%
% ** tt boldface display *
%--------------------------------------------------------
\def\ProgKeyword#1#2{\@ifnextchar [{\@@prgkwrd{#1}{#2}}{\@@prgkwrd{#1}{#2}[0]}}
\def\@@prgkwrd#1#2[#3]{\def#1{\mbox{\reset@font\tt\bf{}#2}}}
\def\ProgKeywords{\Keywords{\ProgKeyword}}
\def\FProgKeyword#1#2{\@ifnextchar [{\@@fprgkwrd{#1}{#2}}{\@@fprgkwrd{#1}{#2}[#2]}}
\def\@@fprgkwrd#1#2[#3]{\def#1{\mbox{\reset@font\tt\bf{}#3}}}
\def\FProgKeywords{\Keywords{\FProgKeyword}}
%--------------------------------------------------------
% display of programs (English keywords) ---> command '\ttKeywords'
% display of programs (French keywords) ---> command '\FttKeywords'
%
% ** tt normal display *
%--------------------------------------------------------
\def\ttKeyword#1#2{\@ifnextchar [{\@@ttkwrd{#1}{#2}}{\@@ttkwrd{#1}{#2}[0]}}
\def\@@ttkwrd#1#2[#3]{\def#1{\mbox{\reset@font\tt{}#2}}}
\def\ttKeywords{\Keywords{\ttKeyword}}
\def\FttKeyword#1#2{\@ifnextchar [{\@@fttkwrd{#1}{#2}}{\@@fttkwrd{#1}{#2}[#2]}}
\def\@@fttkwrd#1#2[#3]{\def#1{\mbox{\reset@font\tt\bf{}#3}}}
\def\FttKeywords{\Keywords{\FttKeyword}}
%--------------------------------------------------------
% display of algorithms (English keywords) ---> command '\AlgoKeywords'
% display of algorithms (French keywords) ---> command '\FAlgoKeywords'
%
% ** emphasized display *
%--------------------------------------------------------
\def\AlgoKeyword#1#2{\@ifnextchar [{\@@algkwrd{#1}{#2}}{\@@algkwrd{#1}{#2}[0]}}
\def\@@algkwrd#1#2[#3]{\def#1{\mbox{\reset@font\em{}#2\/}}}
\def\AlgoKeywords{\Keywords{\AlgoKeyword}}
\def\FAlgoKeyword#1#2{\@ifnextchar [{\@@falgkwrd{#1}{#2}}{\@@falgkwrd{#1}{#2}[#2]}}
\def\@@falgkwrd#1#2[#3]{\def#1{\mbox{\reset@font\em{}#3\/}}}
\def\FAlgoKeywords{\Keywords{\FAlgoKeyword}}
%--------------------------------------------------------
% display of algorithms (underlined English keywords) ---> command '\UAlgoKeywords'
% display of algorithms (underlined French keywords) ---> command '\UFAlgoKeywords'
%
% ** underlined emphasized display *
%--------------------------------------------------------
\def\UAlgoKeyword#1#2{\@ifnextchar [{\@@ualgkwrd{#1}{#2}}{\@@ualgkwrd{#1}{#2}[0]}}
\def\@@ualgkwrd#1#2[#3]{\def#1{\mbox{\reset@font\em{}\underline{#2}\/}}}
\def\UAlgoKeywords{\Keywords{\UAlgoKeyword}}
\def\UFAlgoKeyword#1#2{\@ifnextchar [{\@@ufalgkwrd{#1}{#2}}{\@@ufalgkwrd{#1}{#2}[#2]}}
\def\@@ufalgkwrd#1#2[#3]{\def#1{\mbox{\reset@font\em{}\underline{#3}\/}}}
\def\UFAlgoKeywords{\Keywords{\UFAlgoKeyword}}
%--------------------------------------------------------
% unchanged display (English keywords) ---> command '\NormalKeywords'
% unchanged display (French keywords) ---> command '\FNormalKeywords'
%
% ** normal (roman) display *
%--------------------------------------------------------
\def\NormalKeyword#1#2{\@ifnextchar [{\@@normkwrd{#1}{#2}}{\@@normkwrd{#1}{#2}[0]}}
\def\@@normkwrd#1#2[#3]{\def#1{\mbox{#2}}}
\def\NormalKeywords{\Keywords{\NormalKeyword}}
\def\FNormalKeyword#1#2{\@ifnextchar [{\@@fnormkwrd{#1}{#2}}{\@@fnormkwrd{#1}{#2}[#2]}}
\def\@@fnormkwrd#1#2[#3]{\def#1{\mbox{#3}}}
\def\FNormalKeywords{\Keywords{\FNormalKeyword}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% General English syntax
% ----------------------
% Lines must be typed in
% the following way: #1{#2}{#3}[#4]
%
% #1 : unprecised parameter (command to be defined)
% #2 : name of the keyword
% #3 : English translation
% #4 : French translation (optional)
%
% If #4 is not precised, then default value is #3.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\Keywords #1{%
#1{\ABORT}{abort}[avorter]%
#1{\ABS}{abs}%
#1{\ABSTRACT}{abstract}[abstrait]%
#1{\ACCEPT}{accept}[accepter]%
#1{\ACCESS}{access}[acc\`es]%
#1{\ALIASED}{aliased}[alias\'e]%
#1{\ALL}{all}[tout]%
#1{\ALT}{alt}%
#1{\AND}{and}[et]%
#1{\APPEND}{append}[ajouter\_\-en\_\-fin]%
#1{\ARRAY}{array}[tableau]%
#1{\ASSERT}{assert}[assertion]%
#1{\ASSIGN}{:=}%
#1{\AT}{at}%
#1{\BEGIN}{begin}[d\'ebut]%
#1{\BLOCK}{block}[bloc]%
#1{\BOOLEAN}{boolean}[bool\'een]%
#1{\BODY}{body}%
#1{\BOT}{$\bot$}%
#1{\BOX}{$<>$}%
#1{\BY}{by}[pas]%
#1{\CASE}{case}[choix]%
#1{\CATINDEX}{catindex}%
#1{\CHAN}{chan}[canal]%
#1{\CHANNEL}{channel}[canal]%
#1{\CHAR}{char}[car]%
#1{\CHARACTER}{character}[caract\`ere]%
#1{\CLOSE}{close}[fermer]%
#1{\CO}{co}%
#1{\COBEGIN}{cobegin}%
#1{\COEND}{coend}%
#1{\COMMUTATIVE}{commutative}[commutatif]%
#1{\COMPLEX}{complex}[complexe]%
#1{\COMPUTE}{compute}[calculer]%
#1{\CONNECT}{$\longrightarrow$}%
#1{\CONNECTB}{$\Longrightarrow$}%
#1{\CONST}{const}%
#1{\CONSTANT}{constant}[constante]%
#1{\CONSTRAINTS}{constraints}[contraintes]%
#1{\CONTINUE}{continue}%
#1{\DATA}{data}[donn\'ee]%
#1{\DECLARE}{declare}%
#1{\DECOMPOSE}{decompose}%
#1{\DELAY}{delay}[d\'elai]%
#1{\DELTA}{delta}%
#1{\DEPTH}{depth}[profondeur]%
#1{\DIGITS}{digits}[chiffres]%
#1{\DIMENSION}{dimension}%
#1{\DIST}{dist}%
#1{\DISTRIBUTE}{distribute}[r\'epartir]%
#1{\DIV}{div}%
#1{\DO}{do}[faire]%
#1{\DOALL}{doall}[faire en parall\`ele]%
#1{\DOM}{dom}%
#1{\DOMAIN}{domain}[domaine]%
#1{\DOMAINS}{domains}[domaines]%
#1{\DONE}{done}[fait]%
#1{\DOPAR}{dopar}[faire en parall\`ele]%
#1{\DOWNTO}{downto}[jusqu'\`a]%
#1{\DYNAMIC}{dynamic}[dynamique]%
#1{\EACH}{each}[chaque]%
#1{\EGO}{MyId}[EGO]%
#1{\ELSE}{else}[sinon]%
#1{\ELSIF}{elsif}[sinon si]%
#1{\END}{end}[fin]%
#1{\ENDCASE}{end case}[fin choix]%
#1{\ENDIF}{end if}[finsi]%
#1{\ENDDO}{end do}[fait]%
#1{\ENDLOOP}{end loop}[fait]%
#1{\ENTRY}{entry}[entr\'ee]%
#1{\EOT}{eot}%
#1{\EQ}{$=$}%
#1{\EXCEPTION}{exception}%
#1{\EXIT}{exit}[sortir]%
#1{\EXTERNAL}{external}[externe]%
#1{\FI}{fi}[finsi]%
#1{\FILE}{file}[fichier]%
#1{\FIRST}{first}[premier]%
#1{\FOR}{for}[pour]%
#1{\FORALL}{forall}[pour tout]%
#1{\FOREACH}{foreach}[pour chaque]%
#1{\FORWARD}{forward}%
#1{\FUNCTION}{function}[fonction]%
#1{\GE}{$\geq$}%
#1{\GENERIC}{generic}[g\'en\'erique]%
#1{\GETNODE}{getnode}[prendre\_\-noeud]%
#1{\GOTO}{goto}[aller\_\-\`a]%
#1{\GRAPH}{graph}[graphe]%
#1{\GT}{$>$}%
#1{\IF}{if}[si]%
#1{\IMPLICATION}{$\Rightarrow$}%
#1{\IMPLY}{$\Rightarrow$}%
#1{\IMPORT}{import}[importer]%
#1{\IN}{in}[dans]%
#1{\IND}{ind}%
#1{\INDEX}{index}%
#1{\INIT}{init}%
#1{\INOUT}{inout}%
#1{\INPORT}{inport}%
#1{\INPUT}{input}%
#1{\INTEGER}{integer}[entier]%
#1{\INTO}{into}%
#1{\IS}{is}[est]%
#1{\LABEL}{label}[\'etiquette]%
#1{\LAST}{last}[dernier]%
#1{\LE}{$\leq$}%
#1{\LENGTH}{length}[longueur]%
#1{\LIMITED}{limited}[limit\'e]%
#1{\LOOP}{loop}[faire]%
#1{\LT}{$<$}%
#1{\MAP}{map}[placer]%
#1{\MOD}{mod}%
#1{\MODULE}{module}%
#1{\MODULO}{modulo}%
#1{\MULTIPLE}{multiple}%
#1{\MYID}{MyId}[EGO]%
#1{\NE}{$\neq$}%
#1{\NEIGHBOUR}{neighbour}[voisin]%
#1{\NEIGHBOURS}{neighbours}[voisins]%
#1{\NEW}{new}[nouveau]%
#1{\NEWBLOCK}{newblock}%
#1{\NIL}{nil}%
#1{\NODE}{node}[noeud]%
#1{\NOT}{not}[non]%
#1{\NUL}{nul}%
#1{\NULL}{null}[nul]%
#1{\OD}{od}[fait]%
#1{\ODPAR}{odpar}[fait]%
#1{\OF}{of}%
#1{\ON}{on}%
#1{\OPEN}{open}[ouvrir]%
#1{\OR}{or}[ou]%
#1{\OTHERS}{others}%
#1{\OUT}{out}%
#1{\OUTPORT}{outport}%
#1{\OUTPOUT}{outpout}%
#1{\PACKAGE}{package}[paquetage]%
#1{\PARALLEL}{parallel}%
#1{\PARFOR}{parfor}[en parall\`ele: pour]%
#1{\PAR}{par}[en parall\`ele]%
#1{\PERCENT}{\%}%
#1{\PLACE}{place}[placer]%
#1{\PORT}{port}%
#1{\PRAGMA}{pragma}%
#1{\PRI}{pri}%
#1{\PRIVATE}{private}[priv\'e]%
#1{\PROCEDURE}{procedure}[proc\'edure]%
#1{\PROCESS}{process}[processus]%
#1{\PROGRAM}{program}[programme]%
#1{\PROTECTED}{protected}[prot\'eg\'e]%
#1{\RAISE}{raise}[lever]%
#1{\RANGE}{range}[intervalle]%
#1{\READ}{read}[lire]%
#1{\READY}{ready}[pr\^et]%
#1{\REAL}{real}[r\'eel]%
#1{\RECORD}{record}[enregistrement]%
#1{\RECV}{recv}[recevoir]%
#1{\RECEIVE}{receive}[recevoir]%
#1{\REM}{rem}%
#1{\RENAMES}{renames}[renomme]%
#1{\REPEAT}{repeat}[r\'ep\'eter]%
#1{\REQUEUE}{requeue}%
#1{\RESET}{reset}%
#1{\RETURN}{return}[retour]%
#1{\REVERSE}{reverse}%
#1{\REWIND}{rewind}%
#1{\REWRITE}{rewrite}%
#1{\ROOT}{root}[racine]%
#1{\SELECT}{select}%
#1{\SEND}{send}[\'emettre]%
#1{\SENDEOT}{sendeot}[\'emettre eot]%
#1{\SEPARATE}{separate}[s\'epar\'ement]%
#1{\SEQ}{seq}%
#1{\SET}{set}%
#1{\SIZE}{size}[taille]%
#1{\SKIP}{skip}[sauter]%
#1{\STRING}{string}[cha\^{\i}ne de caract\`eres]%
#1{\SUBTYPE}{subtype}[sous\_\-type]%
#1{\SWITCH}{switch}%
#1{\TAGGED}{tagged}[\'etiquett\'e]%
#1{\TASK}{task}[t\^ache]%
#1{\TERMINATE}{terminate}[terminer]%
#1{\THEN}{then}[alors]%
#1{\TO}{to}[jusqu'\`a]%
#1{\TOWARDS}{towards}[vers]%
#1{\TRANSMIT}{transmit}[\'emettre]%
#1{\TUPLE}{tuple}[n\_\-uplet]%
#1{\TYPE}{type}%
#1{\UNDEF}{undef}[ind\'efini]%
#1{\UNTIL}{until}[jusqu'\`a]%
#1{\USE}{use}%
#1{\VAR}{var}%
#1{\VARIABLE}{variable}%
#1{\WHEN}{when}[si]%
#1{\WHERE}{where}[si]%
#1{\WHILE}{while}[tant que]%
#1{\WITH}{with}[avec]%
#1{\WRITE}{write}[\'ecrire]%
#1{\XOR}{xor}%
%
%--------------------------------------------------------%
% French syntax%
%--------------------------------------------------------%
%
#1{\EMETTRE}{send}[\'emettre]%
#1{\RECEVOIR}{receive}[recevoir]%
%%
#1{\POUR}{for}[pour]%
#1{\FAIRE}{do}[faire]%
#1{\FAIT}{end do}[fait]%
%%
#1{\SI}{if}[si]%
#1{\ALORS}{then}[alors]%
#1{\SINON}{else}[sinon]%
#1{\FINSI}{end if}[fin si]%
%%
#1{\DEBUT}{begin}[d\'ebut]%
#1{\FIN}{end}[fin]%
}
\UFAlgoKeywords % default value
==================================CUT HERE==================================
Technical Details
Message-ID:
<3nltpv$rum@serveur.cribx1.u-bordeaux.fr>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f9e16,d0dd04d92dac5759,start X-Google-Attributes: gidf9e16,public X-Google-Thread: 10ee61,d0dd04d92dac5759,start X-Google-Attributes: gid10ee61,public From: alabau@aergistal (Miguel ALABAU) Subject: A style for typesetting keywords Date: 1995/04/26 Message-ID: <3nltpv$rum@serveur.cribx1.u-bordeaux.fr> X-Deja-AN: 101604460 organization: Laboratoire Bordelais de Recherche en Informatique newsgroups: comp.text.tex,fr.comp.text.tex