I'm referring to the pdf linked here.
Specifically, how can I recreate this part on the first page?
I'm guessing it's using the verbatim environment somehow, but how can I get those vertical lines in there too? Thanks in advance.
I'm referring to the pdf linked here.
Specifically, how can I recreate this part on the first page?
I'm guessing it's using the verbatim environment somehow, but how can I get those vertical lines in there too? Thanks in advance.
A quick solution based on the package documentation for algorithm2e
\documentclass{standalone}
\usepackage{algorithm2e}
\begin{document}
\begin{algorithm}[H]
\SetStartEndCondition{ }{}{}%
\SetKwProg{Fn}{def}{\string:}{}
\SetKwIF{If}{ElseIf}{Else}{if}{:}{elif}{else:}{}%
\SetKwFunction{FnFoo}{foo}
\DontPrintSemicolon
\SetAlgoLined
\Fn{\FnFoo{}}{
\If {something}{
\FuncSty{Do} something\;
\FuncSty{Do} something\;
}
\FuncSty{Do} something last\;
}
\end{algorithm}
\end{document}
Uses my answer at pseudo code with vertical line, modified to make rules gray in color.
\documentclass{article}
\usepackage{xcolor}
\def\lindent{.5ex}
\def\rindent{2ex}
\def\rthk{1.5pt}
\newcommand\block[3]{\unskip%
\noindent\parbox[b]{\textwidth}{\strut\ignorespaces#1\strut}\\
\setbox0=\hbox{\parbox[b]{\textwidth}{\strut\ignorespaces#2\strut}}%
\hspace*{\lindent}\textcolor{gray!50}{\rule[-.5\dp\strutbox]{\rthk}{\ht0}}%
\hspace{\rindent}\box0\\\parbox[b]{\textwidth}{\strut\ignorespaces#3\strut}%
\ignorespaces}
\begin{document}
\ttfamily
\block{
def foo():
}{
\block{
if something
}{
do something\\
do more things
}{
do something last}
}
{}
\end{document}