I have to put the source code with this kind of format inside my report. I've read other questions. Most of them are just putting listing
or minted
inside tabular environment. But not the source code with it's line side by side.
Maybe the possible method is changing the way minted represent it's number and the box around it. If this is not possible. Maybe put listing inside table. But I have no idea to achieve it. The desired result looks like this:
I tried some MWE but it's far from perfect. I have to add lines manually and the result is so bad.
\documentclass{report}
\usepackage[top=3cm,bottom=3cm,left=4cm,right=3cm]{geometry}
\usepackage{longtable}
\usepackage{listings}
\lstset{
language=Python,
basicstyle=\small,
breaklines=true
}
\begin{document}
\begin{longtable}[c]{|p{1cm}|p{7cm}|}
\caption{Unit testing example} \label{tab:unit-testing-example}\\
\hline
\textbf{No} & \textbf{Source Code} \\
\hline
\endhead % <-- on every page
1 \newline 2 \newline 3 &
\begin{lstlisting}
def hallo(nama):
if nama == "Budi":
return "Hai " + nama
else:
return "Nama Kosong"
def test_case_1():
assert hallo("Budi") == "Hai Budi"
def test_case_2():
assert hallo("Ani") == "Nama Kosong"
\end{lstlisting}
\\\hline
\end{longtable}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
Really need your help folks, to get this reports done.
Thanks a ton in advance.