I use the algorithmic package to create a pseudo-code-source in latex. I have a source with many short if-statements. The fact that the END (from EndIf) is put in a new line every time leads to a lengthy layout:
\documentclass[11pt,a4paper,leqno,fleqn]{article}
\usepackage{algpseudocode}
\usepackage[Algorithmus]{algorithm}
\begin{document}
\begin{algorithm}
\caption{WHILE-Modulo}
\begin{algorithmic}[1]
\Require f($x_1,x_2$)
\State $x_z := 1$
\While{$x_z \not = 0$}
\If{$x_z = 1$} \If{$x_1 = 0$} $x_z = 10$ \EndIf \EndIf
\If{$x_z = 2$} $x_3 := x_1 \dot{-}x_2$\EndIf
\If{$x_z = 3$} $x_4 := x_2 \dot{-}x_1$\EndIf
\If{$x_z = 4$} \If{$x_3 = 0$} $x_z = 7$\EndIf \EndIf
\If{$x_z = 5$} $x_1 := x_3$\EndIf
\If{$x_z = 6$} $x_z = 2$\EndIf
\If{$x_z = 7$} \If{$x_4 = 0$} $x_z = 9$\EndIf \EndIf
\If{$x_z = 8$} $x_z = 10$\EndIf
\If{$x_z = 9$} $x_1 := x_1 \dot{-} x_2$\EndIf
\If{$x_z = 10$} $x_z = 0$\EndIf
\If{$x_z = 11$} $x_z = 0$\EndIf
\EndWhile
\end{algorithmic}
\end{algorithm}
\end{document}
leads to this output:
However, I want single If-Statements to be in one line, similar to this:
Do you have ideas? I am grateful for all input
Best Answer
You can create your own "Intermediate IF" (or one-liner IF) statement using the following: