1

In the algorithmicx package, you can define your own algorithm blocks with the \algblock command. How can I use special characters inside the definition of such a block? I want to create a German version of the for-loop. The German word for "for" is "für". The standard approaches such as {\"u}, etc. don't work.

Minimal working example:

\documentclass{article}

\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage{algpseudocode}
\algblock[<block>]{für}{endfur}
\algtext*{endfur}

\begin{document}

\begin{algorithm}
\begin{algorithmic}
\für x
\State y
\endfur
\end{algorithmic}
\end{algorithm}

\end{document}
4
  • 2
    Welcome to TeX.SX! Can you please show your setup and a minimal example?
    – egreg
    Jun 19, 2018 at 10:13
  • 2
    Isn't it easier to do \algrenewcommand\algorithmicfor{\textbf{für}} and use the standard \For and \EndFor?
    – egreg
    Jun 19, 2018 at 10:57
  • @egreg I wanted to get rid of the\EndFor part.
    – tripleJ
    Jun 19, 2018 at 20:04
  • 3
    \usepackage[noend]{algpseudocode}
    – egreg
    Jun 19, 2018 at 20:09

2 Answers 2

1

If you don't want the End tag in a For cycle, you want it in no other situation.

\documentclass{article}

\usepackage{algorithm}
%\usepackage{algorithmicx}% not along with algpseudocode
\usepackage[noend]{algpseudocode}

\algrenewcommand\algorithmicfor{\textbf{für}}


\begin{document}

\begin{algorithm}
\begin{algorithmic}
\For{x}
\State y
\EndFor
\end{algorithmic}
\end{algorithm}

\end{document}

enter image description here

0

Okay, I found a (rather ugly) workaround. I only use the letter "f" inside the definition and add the rest as bold text:

\documentclass{article}

\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage{algpseudocode}
\algblock[<block>]{f}{endfur}
\algtext*{endfur}

\begin{document}

\begin{algorithm}
\begin{algorithmic}
\f\textbf{\"ur} x
\State y
\endfur
\end{algorithmic}
\end{algorithm}

\end{document}

It works, but it's really not elegant.

4
  • At the moment your answer and question isn't helpful for other people.
    – Bobyandbob
    Jun 19, 2018 at 10:17
  • 1
    @Bobyandbob Why do you believe that? It would have been helpful for me, so why shouldn't it be helpful for anybody else in a similar situation?
    – tripleJ
    Jun 19, 2018 at 10:23
  • 1
    Because we need more informations. At least compilable code, starting with \documentclass and ending with \end{document}(for your question & answer). Then it should be helpful.
    – Bobyandbob
    Jun 19, 2018 at 10:26
  • 1
    @Bobyandbob Fixed it.
    – tripleJ
    Jun 19, 2018 at 10:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .