I'd like to have the line numbers corresponding to code highlighted using the minted
package displayed in the output of a preview
environment. Perhaps because the line numbers are set in the margin, they turn out not to be displayed. I've used the xleftmargin
option provided by the minted
package, but it's been to no avail. How can this be done?
The document is compiled over pdfTeX
.
Follows an MWE (the C++ code therein is nonsense, just for the sake of providing some content):
\documentclass{memoir}
\usepackage[active,pdftex,tightpage,psfixbb]{preview}
\usepackage{xcolor}
\usepackage{minted}
\pagestyle{empty}
\begin{document}
\begin{preview}
\begin{minted}[xleftmargin=\parindent,linenos]{cpp}
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
unsigned short i;
int main() {
for (i = 0; i <= 5; i++) {
// whatever
}
return 0;
}
\end{minted}
\end{preview}
\end{document}