I have the code below to generate minted code inside box (credit:Ignasi). That format (code inside box) is heavely needed in my previous report paper.
\documentclass[12pt,a4paper,oneside]{report}
\usepackage{listings}
\usepackage[newfloat,chapter]{minted}
\usepackage[labelfont=bf]{caption}
\newenvironment{code}{\captionsetup{type=listing}}{}
\SetupFloatingEnvironment{listing}{name=Tabel Kode}
\usepackage{tcolorbox}
\tcbuselibrary{listings,minted,skins,breakable}
\newtcblisting{ignasicblock}[1][]{%
breakable,
colback=white,
colframe=black,
colbacktitle=white,
sharp corners,
enhanced,
listing engine=minted,
listing only,
left=10mm,
title=Source Code,
halign title=center,
overlay={\draw[line width=.5mm] ([xshift=8mm]frame.south west)
-- ([xshift=8mm]frame.north west);
\node[right] at (title.west) {No};},
minted style=colorful,
minted language=Python,
minted options={%
linenos=true,
fontsize=\footnotesize,
numbersep=6mm,
texcl=true,
breaklines=true,
autogobble=true},
coltitle=black,
#1
}
\definecolor{codebg}{rgb}{0.95,0.95,0.95}
\renewcommand\theFancyVerbLine{\footnotesize\arabic{FancyVerbLine}}
\begin{document}
\begin{code}
\captionof{listing}{\emph{Pseudocode function} fizzbuzz}
\label{pc:construct-ed}
\begin{ignasicblock}[title=fizzbuzz,minted language=text]
program fizzbuzz
Do i = 1 to 100
set print_number to true
If i is divisible by 3
print "Fizz"
set print_number to false
If i is divisible by 5
print "Buzz"
set print_number to false
If print_number, print i
print a newline
end do
\end{ignasicblock}
\end{code}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% TeX-command-extra-options: "-shell-escape"
%%% End:
The code above will generate:
Now I need to give a mark like figure1 or figure2. The mark will be a curly braces that stretch from line X until line Y.
So we can define:
- starting line:x
- end line:y
- number:z
- (if possible) we can dynamically change the mark, for just one line, we can use line instead of curly braces e.g in figure2
Figure1:
Figure2:
I heavily need this format for my current report. Thanks a ton in advance for the help. Thank you.