TeX - LaTeX Asked by Raja Ayaz on December 1, 2020
I am trying to use listings
package for writing algorithm. I have used algorithm2e but its hard and i cannot customize it specially the fonts.
I am following this stackexchange answer:
documentclass{article}
usepackage{listings}
usepackage{caption}
lstset{
language=C++,
basicstyle=smallttfamily,
numbers=left,
numbersep=5pt,
xleftmargin=20pt,
frame=tb,
framexleftmargin=20pt
}
renewcommand*thelstnumber{arabic{lstnumber}:}
DeclareCaptionFormat{mylst}{hrule#1#2#3}
captionsetup[lstlisting]{format=mylst,labelfont=bf,singlelinecheck=off,labelsep=space}
begin{document}
begin{lstlisting}
#include <iostream>
using namespace std;
int main()
{
cout << "Welcome to the wonderful world of C++!!!n";
return 0;
}
end{lstlisting}
end{document}
this code produces output which looks like this:
Is it possible to make the output look like this?
Any ideas how to achieve this using listings
?
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP