[Tex/LaTex] Minted line numbers outside frame and outside margin

alignmentmintedsourcecode

I have a code snippet where I use minted for nice display:

\begin{figure}[H]
    \begin{minted}[
        frame=single,
        obeytabs=true,
        tabsize=4,
        linenos,
        numbersep=6pt
    ]{json}
    {  
        "employee": {  
            "name": "test",   
            "salary": 56000,   
            "married": true  
        }  
    }  
    \end{minted}
\end{figure}

However, I can't get the line numbers to be inside the frame.
This seems to be a common problem and was discussed before, but other solution suggested to use xleftmargin=\parindent, which did not help.
How can I fix this problem?

Best Answer

From your post, I understood that you need to print the line numbers inside the frame, if my assumption is correct, then please try with the below mentioned MWE:

\documentclass{book}
\usepackage{minted}

\begin{document}

\begin{figure}[H]
    \begin{minted}[
        frame=single,
        obeytabs=true,
        tabsize=4,
        linenos,
        numbersep=-10pt
    ]{json}
    {  
        "employee": {  
            "name": "test",   
            "salary": 56000,   
            "married": true  
        }  
    }  
    \end{minted}
\end{figure}
\end{document}

Output

enter image description here

Please excuse me, if my understanding is wrong...