I use the package listings to add code snippet in my document. my problem is for the character ~. It's placed at the top of the line, like if it was above a letter, while I want it at the middle of the line.
Here is an example:
\documentclass{report}
\usepackage{xcolor}
%%%
% For source code
%%%
\definecolor{mgreen}{rgb}{0.0, 0.4, 0.0}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\usepackage{listings}
\lstset{frame=tblr,
language=c++,
basicstyle=\scriptsize,
aboveskip=3mm,
belowskip=3mm,
captionpos=b,
showstringspaces=false,
% Numbering
numbers=left,
numberstyle=\tiny\color{gray},
keywordstyle=\color{blue},
commentstyle=\color{mgreen},
stringstyle=\color{mauve},
breaklines=true,
breakatwhitespace=true,
}
\begin{document}
\begin{lstlisting}
class Foo {
public:
// Constructor
Foo();
// Destructor
~Foo();
};
\end{lstlisting}
\end{document}