Abstand zwischen dem Absatz und Algorithm hinzufügen.

Antwort erstellen


Diese Frage dient dazu, das automatisierte Versenden von Formularen durch Spam-Bots zu verhindern.
Smilies
:D :) :( :o :shock: :? 8) :lol: :-x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:

BBCode ist eingeschaltet
[img] ist eingeschaltet
[flash] ist ausgeschaltet
[url] ist eingeschaltet
Smilies sind eingeschaltet

Die letzten Beiträge des Themas

Ich habe die Datenschutzerklärung gelesen und bin damit einverstanden.

   

Wenn du eine Datei oder mehrere Dateien anhängen möchtest, gib die Details unten ein.

Ansicht erweitern Die letzten Beiträge des Themas: Abstand zwischen dem Absatz und Algorithm hinzufügen.

von Johannes_B » Sa 3. Okt 2015, 19:09

An manchen Tagen fühle ich mich wie im falschen Film: Crosspost

von rais » Sa 3. Okt 2015, 18:23

zu 2 und 3:
\documentclass{article}
\usepackage[ruled, linesnumbered, commentsnumbered]{algorithm2e}
\renewcommand{\baselinestretch}{1.5}

\usepackage{listings}
\usepackage{blindtext}
\begin{document}
\blindtext

\vfill

\begin{algorithm}[H]
   \SetAlgoLined
   \KwData{$next\_id, speed,stop\_distance, mac$}
   \KwResult{Find the initializer. }
   int $next\_id1$ = find a  record with $speed > 30$ \\ for this $mac$ in the next table;\\
   \tcc{some comment}
   int $next\_id2$ = find record with $speed <7$ and \\ $stop\_distance < 60$ for this mac in the next table;\\
   \tcp{some other comment}
   \If{$next\_id1 < next\_id2$}{
      find the related $stop\_name$ for this mac;\\
      return  $stop\_name$;
   }
   \caption{Algorithm to find intializer.}
\end{algorithm}

\begin{lstlisting}[caption = {MYSQL query to find the initializer.}, label={lst: initializer}]
SELECT speed, stop_name
from next
where stop_distance < 60 and speed < 7  
and mac = ? and next_id > ?  LIMIT  1
\end{lstlisting}

\clearpage
\end{document}
siehe auch `texdoc algorithm2e'.

VG
Rainer

von Johannes_B » Sa 3. Okt 2015, 17:20

\documentclass{article}
\usepackage[ruled]{algorithm2e}
\renewcommand{\baselinestretch}{1.5}

\usepackage{listings}
\usepackage{blindtext}
\begin{document}
\blindtext

\vspace{2cm}

\begin{algorithm}[H]
	\SetAlgoLined
	\KwData{$next\_id, speed,stop\_distance, mac$}
	\KwResult{Find the initializer. }
	int $next\_id1$ = find a  record with $speed > 30$ \\ for this $mac$ in the next table;\\
	int $next\_id2$ = find record with $speed <7$ and \\ $stop\_distance < 60$ for this mac in the next table;\\
	\If{$next\_id1 < next\_id2$}{
		find the related $stop\_name$ for this mac;\\
		return  $stop\_name$;
	}
	\caption{Algorithm to find intializer.}
\end{algorithm}

\begin{lstlisting}[caption = {MYSQL query to find the initializer.}, label={lst: initializer}]
SELECT speed, stop_name
from next
where stop_distance < 60 and speed < 7  
and mac = ? and next_id > ?  LIMIT  1
\end{lstlisting}

\clearpage
\end{document}

von the_time » Sa 3. Okt 2015, 17:13

also \vspace geht nicht denn ich kriege "! Paragraph ended before \@vspace was complete."

mit \bigbreak and \medbreak funktioniert es.

Danke.

von Johannes_B » Sa 3. Okt 2015, 17:01

Abstände kannst du mit \vspace einfügen.Eventuell hilft dir auch \medbreak und \bigbreak.

Abstand zwischen dem Absatz und Algorithm hinzufügen.

von the_time » Sa 3. Okt 2015, 16:56

Hallo zusammen,

es geht mir um die erste Frage aber wenn jemand es weißt und Lust hat, kann er auch gerne die 2te und 3te Frage beantworten :) .

1. wie kann ich Abstand zwischen dem Absatz und Algorithm sowie zwischen dem Algorithm und Listing hinzufügen?
2. wie kann ich Numierung zu den Algorithm-Zeilen hinzufügen?
3. wie kann ich comment im Algorithm schreiben?

Schöne Grüße,
the_time

Code
\documentclass{article}
\usepackage[ruled]{algorithm2e}
\renewcommand{\baselinestretch}{1.5}

\usepackage{listings}
\usepackage{blindtext}
\begin{document}
\blindtext 

\begin{algorithm}[H]
\SetAlgoLined
\KwData{$next\_id, speed,stop\_distance, mac$}
\KwResult{Find the initializer. }
 int $next\_id1$ = find a  record with $speed > 30$ \\ for this $mac$ in the next table;\\
 int $next\_id2$ = find record with $speed <7$ and \\ $stop\_distance < 60$ for this mac in the next table;\\
 \If{$next\_id1 < next\_id2$}{
   find the related $stop\_name$ for this mac;\\
   return  $stop\_name$;
 }
\caption{Algorithm to find intializer.}
\end{algorithm}

\begin{lstlisting}[caption = {MYSQL query to find the initializer.}, label={lst: initializer}]
SELECT speed, stop_name
from next 
where stop_distance < 60 and speed < 7  
and mac = ? and next_id > ?  LIMIT  1
\end{lstlisting}

\clearpage
\end{document}

Nach oben