2

I am writing my code in pseudocode package and I would need to change the name "Algorithm" to "Algoritmus".

Is there any possibility how to do this in this package? I have found it just for package algorithm, but I have everything written and I don't want to change my whole work to different environment.

Thank you for any help.

Lucie
  • 23

2 Answers2

2

packages should use \xxxname commands for fixed strings so that they can be easily changed as you request but unfortunately this uses the fixed text in the middle of a large command setup.

However you can patch the definition as follows

enter image description here

\documentclass{article}

\usepackage{pseudocode}
\usepackage{etoolbox}
\expandafter\patchcmd\csname\string\pseudocode\endcsname{Algorithm}{Algoritmus}{\typeout{good}}{\typeout{bad}}
\expandafter\patchcmd\csname\string\pseudocode\endcsname{Algorithm}{Algoritmus}{\typeout{good}}{\typeout{bad}}
\begin{document}

\begin{pseudocode}{a}{b}

\end{pseudocode}

\end{document}
David Carlisle
  • 757,742
  • \xpatchcmd{\pseudocode}{Algorithm}{Algoritmus}{}{} is easier, with \xpatch. Nice package, isn't it? – egreg Apr 24 '17 at 22:47
1

David's patch is good, but it can be largely improved, for instance making the name language aware and adding easy support for changing the formatting of the header.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,czech]{babel}

\usepackage{pseudocode}
\usepackage{xpatch}

% fix the bad code in pseudocode.sty
\xpatchcmd\pseudocode{\bfseries Algorithm }{\algorithmheadformat\algorithmname\ }{}{}
\xpatchcmd\pseudocode{\bfseries Algorithm }{\algorithmheadformat\algorithmname\ }{}{}
\providecommand{\algorithmname}{Algorithm}
\providecommand{\algorithmheadformat}{\bfseries}
% end of fix

\addto\captionsczech{\renewcommand{\algorithmname}{Algoritmus}}
\addto\captionsenglish{\renewcommand{\algorithmname}{Algorithm}}
\renewcommand{\algorithmheadformat}{\scshape}

\begin{document}

\begin{pseudocode}{CelsiusToFahrenheit}{c}
  f \GETS {9c/5} + 32\\
  \RETURN{f}
\end{pseudocode}

\selectlanguage{english}

\begin{pseudocode}{CelsiusToFahrenheit}{c}
  f \GETS {9c/5} + 32\\
  \RETURN{f}
\end{pseudocode}

\end{document}

I added \renewcommand{\algorithmheadformat}{\scshape} just by way of example.

enter image description here

egreg
  • 1,121,712