Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to use both the program and algorithmic packages in a paper; however, after adding \usepackage{program}, algorithmic is now broken. For a reduced example,

\documentclass{article}
\usepackage{algorithmic}
% \usepackage{program}

\begin{document}

\begin{algorithmic}
\STATE a
\STATE b
\end{algorithmic}

\end{document}

This should print "a" then "b" on two lines; enabling the [commented] third line gives errors for me.

! LaTeX Error: Command \AND already defined.
               Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.8 \STATE
           a
? q

I'm using texlive 2010 via OpenSuSE RPMs.

share|improve this question
    
What is the motivation for using the program package? I guess your minimal example does not effectively show its use. –  Werner Aug 3 '11 at 21:06
    
@Werner, yes, of course, it's a reduced example. afaik algorithmic doesn't expose method names for recursive definitions. However, I'm finding more and more that it's a somewhat inopportune package, overriding sensible things like the absolute value / pipe character in math mode. –  gatoatigrado Aug 4 '11 at 4:31
add comment

1 Answer

up vote 5 down vote accepted

I see at least two solutions:

1) Instead of using algorithmic, use the algorithmicx package, which gives you more functionality and flexibility:

\documentclass{article}
\usepackage{algorithmicx,algpseudocode}
\usepackage{program}

\begin{document}

\begin{algorithmic}
\State a
\State b
\end{algorithmic}

\end{document}

2) Use the savesym package, and the technique I explained in Two conflicting packages in one document — doable? to prevent name clashes:

\documentclass{article}
\usepackage{savesym}
\usepackage{program}
\savesymbol{AND}
\savesymbol{OR}
\savesymbol{NOT}
\savesymbol{TO}
\savesymbol{COMMENT}
\savesymbol{BODY}
\savesymbol{IF}
\savesymbol{ELSE}
\savesymbol{ELSIF}
\savesymbol{FOR}
\savesymbol{WHILE}
\usepackage{algorithmic}

\begin{document}

\begin{algorithmic}
\STATE a
\STATE b
\end{algorithmic}

\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.