I’d like to place a Nassi-Schneiderman diagram into my LaTeX document but also to have the source code for the shown algorithm beside it. Drawing the diagram worked just fine using the StrukTeX
package, showing the source code isn’t a problem either.
The problem is: I can’t think of a way to have text (or in this case: the sourcecode) on the left and the diagram on the right (or vice versa). How do I solve this?
Here is the part of my code that is necessary for this question:
\documentclass{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[german,curves]{struktex}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{listings}
\usepackage{courier}
\lstset{
basicstyle=\footnotesize\ttfamily, % Standardschrift
numbers=left, % Ort der Zeilennummern
numberstyle=\tiny, % Stil der Zeilennummern
numbersep=5pt, % Abstand der Nummern zum Text
tabsize=3, %
extendedchars=true, %
breaklines=true, %
keywordstyle=\color{RoyalBlue}\textbf,
commentstyle=\color{ForestGreen},
frame=bottomline,
stringstyle=\color{WildStrawberry}\ttfamily, % Farbe der String
xleftmargin=17pt,
framexleftmargin=17pt,
framexrightmargin=5pt,
framexbottommargin=4pt,
}
\begin{document}
\begin{lstlisting}[language=Java]
int eingabe = 13;
int vrbeingabe = eingabe;
String ergebnis = "";
while(vrbeingabe > 0) {
if(vrbeingabe % 2 == 0) {
ergebnis = ("0"+ergebnis);
vrbeingabe = vrbeingabe / 2;
} else {
ergebnis = ("1"+ergebnis);
vrbeingabe = vrbeingabe / 2;
}
}
System.out.println("Die Dezimalzahl "+eingabe+" entspricht der Binaerzahl "+ergebnis);
\end{lstlisting}
\begin{struktogramm}(85,20)[Umwandlung dezimaler in binäre Zahlen]
\assign[10]{Eingabe $i$}
\assign[10]{bs $\gets \emptyset$}
\while[8]{solang $i > 0$}
\ifthenelse[15]{5}{6}
{Rest bei $\frac{i}{2}$}{\sTrue}{\sFalse}
\assign{bs $\gets$ "1" $+$ bs}
\change
\assign{bs $\gets$ "0" $+$ bs}
\ifend
\assign{i $\gets \frac{i}{2}$}
\whileend
\assign[10]{Ausgabe bs}
\end{struktogramm}
\end{document}
So far, the output looks like this:
With the minipage environment suggested in one of the answers, it looks like this:
EDIT: Added the actual part of the code. Sorry for the inconvenience of my bad example.