I would like to print a code in my document in the format that is very common to see online in many websites like this:
But when I try to compile, a fatal error occurs. The problem is in the command to print some text inside the square aligned to the left...
\documentclass[a4paper, 11pt]{article}
\usepackage{lipsum} %This package just generates Lorem Ipsum filler text.
\usepackage{fullpage} % changes the margin
\usepackage[utf8]{inputenc}
\usepackage{array}
\usepackage{gensymb}
\usepackage{graphicx}
\usepackage{mwe}
\usepackage{indentfirst}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows, shapes.arrows,decorations.pathmorphing, matrix,chains,scopes,positioning,fit,shapes.gates.logic.US, shapes.gates.logic.IEC, calc,
decorations.markings,arrows.meta,bending}
\usepackage{courier}
\definecolor{red}{HTML}{FF0000}
\definecolor{blue}{HTML}{0000FF}
\definecolor{lavender}{HTML}{E6E6FA}
\definecolor{lightgray}{HTML}{D3D3D3}
\begin{document}
\begin{tikzpicture}
\fill[lavender, draw=lightgray] (0,0.2) rectangle (14,3.8);
\node at (-0.25,6*4/7) {1};
\node at (-0.25,5*4/7) {2};
\node at (-0.25,4*4/7) {3};
\node at (-0.25,3*4/7) {4};
\node at (-0.25,2*4/7) {5};
\node at (-0.25,1*4/7) {6};
%\node at (2.5,6*4/7) {\texttt{\#include $<$iostream$>$}};
%\node at (2.3,5*4/7) {\texttt{\#include $<$string$>$}};
%\node at (2.2,4*4/7) {\texttt{\#include "math.h"}};
%\node at (2.6,3*4/7) {\texttt{using namespace std;}};
%\node at (1.7,1*4/7) {\texttt{int main ()\{ }};
\draw (0.25, 0.25) node[above left, align=left] {\texttt{\#include $<$iostream$>$}\par \texttt{\#include $<$string$>$} \par \texttt{\#include "math.h"} \par \texttt{using namespace std;} \par \par \texttt{int main()}};
\end{tikzpicture}
\end{document}
With the commands in commentary in the above code, the output is like the bigger picture attached. However, If I do this way, I have to adjust the horizontal space for each line I might add in the program.
(If someone also knows how can I make the letters darker(not bold) it would very good!)


listingsand/or (more advanced)minted. – Paul Gessler Nov 20 '15 at 14:20tikzpicturecannot possibly be a good solution here, even if you resolve the errors. I know nothing about typesetting code listings but the approaches suggested to you are surely saner than the one you are using at the moment ;). – cfr Nov 28 '15 at 04:23