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.

  • Consider reading algpseudocode without end block text. – Werner May 24 '15 at 7:04
  • 1
    You give no mention of what theorem-related package you're using. – Werner May 24 '15 at 7:06
  • @Werner I edited it. And thanks for the alternative solution, and I prefer to see whether there is a solution under the program package. – Willard Zhan May 24 '15 at 7:09
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}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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