# Minted Linenos not working after using RecustomVerbatimEnvironment

Currently I am trying to work with the minted package. My aim is to have a code snippet with the numbering for each line, which is centered in a figure.

My top level configuration looks like following:

\documentclass[parskip=full, fontsize=12pt, twoside=false]{scrreprt}

\usepackage{graphicx}
\usepackage{minted}
\setminted{linenos=true}
\RecustomVerbatimEnvironment{Verbatim}{BVerbatim}{}

\begin{document}
\begin{figure}[!htb]
\centering
\begin{minted}{javascript}
let parser = new Parser();
\end{minted}
\end{figure}
\end{document}


The result looks like this:

The good thing is that it is centered in the document but the bad thing is that the numbering is missing.

If i comment out following line i get the numbering but the code is not centered anymore.

%\RecustomVerbatimEnvironment{Verbatim}{BVerbatim}{}


Result looks like following then:

So is there any way how i can achieve both options? Centered and numbered? Hopefully someone has an answer! :)

• Don't show only snippets but a complete document that can be compiled and tested. – Ulrike Fischer Dec 9 '18 at 15:36
• I Changed it! :) – Dariusch Dec 9 '18 at 17:29

I don't think that BVerbatim can be numbered in the standard way, but you could try this

\documentclass[parskip=full, fontsize=12pt, twoside=false]{scrreprt}

\usepackage{graphicx}
\usepackage{minted}
\setminted{linenos=true}
\newcommand\mynumberformat{\def\FancyVerbFormatLine##1{{\theFancyVerbLine} ##1}}
\RecustomVerbatimEnvironment{Verbatim}{BVerbatim}
{formatcom=\mynumberformat}

\begin{document}

\begin{figure}[!htb]
\centering
\begin{minted}{javascript}

• The definition of \theFancyVerbLine is \def\theFancyVerbLine{\rmfamily\tiny\arabic{FancyVerbLine}} and you can guess what the problem was. – egreg Dec 9 '18 at 23:23
• What would the definition look like, if it was better or even perfect? Is there just a \space missing at the end or what is the issue? – thymaro Dec 10 '18 at 10:03