4

I want to write pseudo-codes in my survey using program package. Since I'm writing in other languages rather than English, I have to alter the names of those environments, like theorem and proof, etc (these environments are all from amsthm). I use the command

\renewcommand{\proofname}{XXX}

in order to alter the proof name, but after loading the program package the name turns back into Proof in bold font, instead of XXX that I want.

Another confliction happened in the usage of vertical bar. The program package use |variable_name| in both normal text and math expression, and thus when I write the following equations:

\[f|_{\mathsf{ker} A}=g|_{\mathsf{Ker} A}\]

where the vertical bar refers to function restriction, it is expalined to be a variable and the compiler claims error:

! LaTeX Error: \mathsf allowed only in math mode.

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

l.208     \[f|_{\mathsf
                       {ker} A}=g|_{\mathsf{Ker} A}\]

How can I resolve these problems? I know that algorithmicx or some similar packages are also able to do the pseudo-code job, but I really dislike their strict end or end if fashions.

Thanks in advance.

Wei Zhan
  • 145

1 Answers1

4
  1. program redefined \proof without considering its previous definition. As such, you're better of storing its original definition (made by amsthm), then load program and restore the original definition of \proof.

    \usepackage{amsthm,letltxmacro}
    \LetLtxMacro\oldproof\proof% Store \proof
    \usepackage{program}
    \LetLtxMacro\proof\oldproof% Restore \proof
    

    Note the use of letltxmacro since \proof actually takes an optional argument. See When to use \LetLtxMacro?

  2. program provides \normalbaroutside to restore the original \catcode of | rather than let it be active "in a different way". Alternatively, use \vert.

Here is a complete minimal example showing the above discussion:

enter image description here

\documentclass{article}
\usepackage{amsthm,letltxmacro}
\LetLtxMacro\oldproof\proof% Store \proof
\usepackage{program}
\LetLtxMacro\proof\oldproof% Restore \proof
\begin{document}
|variable_name|

\[f\vert_{\mathsf{ker} A} = g\vert_{\mathsf{Ker} A}\]

\[\normalbaroutside
f|_{\mathsf{ker} A} = g|_{\mathsf{Ker} A}\]
\end{document}
Werner
  • 603,163