# Using the minted package breaks my paragraph indentation

I'm using the minted package for a paper that I'm writing and everything works perfectly fine and compiles without errors, except that, after the first time I use \begin{minted}{csharp} the usual paragraph indentations aren't working anymore. Before that, whenever I leave a blank line between paragraphs, the following paragraph is indented automatically (as it should be), but after the first occurrence of minted, the same thing does not produce an indent. This is what my code looks like and what it produces:

\documentclass{article}

\usepackage{subcaption}
\usepackage{float}
\usepackage{minted}
\usepackage{listings}

\usemintedstyle{friendly}
\setminted[csharp]{
breaklines,
mathescape,
obeytabs=true,
tabsize=4,
linenos,
numbersep=5pt,
frame=single,
numbersep=5pt,
xleftmargin=0pt,
}

\newcommand{\lstCapLbl}[2]{%
\vspace{-0.9\baselineskip}
\captionof{listing}{#1\label{lst:#2}}
\vspace{0.9\baselineskip}
}

\begin{document}

\section{Paragraph}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

\begin{minted}{csharp}
AudioSource audio = gameObject.GetComponent<AudioSource>();
\end{minted}
\lstCapLbl{Example Code Showing the Use of GetComponent}{}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

\end{document}


Using \indent to manually indent the paragraph isn't working either after this piece of code. Does anyone have an idea what might be causing this?

UPDATE: I found out that the \lstCapLbl command is causing the issue, any idea how to create such a caption without breaking the following paragraphs?

• As always on this site please post a full minimal example instead of sniplets. That makes it easier for others to test your code – daleif Aug 13 '20 at 10:24
• @daleif I tried to give a more specific example, hopefully this helps demonstrate the problem. – TheDawnAvenue Aug 13 '20 at 10:56
• This is still a sniplket. Others cannot copy and test this as is. There is no suitable (minimal) preamble and no document class. So in order to help we will have to guess, and we may guess wrong in comparison to your document because you did not tell us what you were doing. – daleif Aug 13 '20 at 11:12
• (tex.meta.stackexchange.com/questions/228/… you look at most other question on the site the requirement of a MWE ) is everywhere. – daleif Aug 13 '20 at 11:13
• @daleif thanks a lot, the link really helped :) by following the instructions I even found out what is causing the problem, although I still don't know how to fix it :) – TheDawnAvenue Aug 13 '20 at 11:34

Never ignore warnings. Your example document produces the following:

Package caption Warning: \captionsetup{type*=...} or \captionof
(caption)                outside box or environment on input line 39.
See the caption package documentation for explanation.



This is warning you that you have used \captionof at the outer level and this is the cause of your problem.

If you place it in an evironment, the warning goes and the following text indents.

You could define a custom environment, but I just use empty here:


\begin{empty}
\begin{minted}{csharp}
AudioSource audio = gameObject.GetComponent<AudioSource>();
\end{minted}
\lstCapLbl{Example Code Showing the Use of GetComponent}{}
\end{empty}


You should use the newfloat option to minted, in order to ensure better support by caption.

\documentclass{article}

\usepackage{caption}
\usepackage{subcaption}
\usepackage[newfloat]{minted}

\usemintedstyle{friendly}
\setminted[csharp]{
breaklines,
mathescape,
obeytabs=true,
tabsize=4,
linenos,
numbersep=5pt,
frame=single,
numbersep=5pt,
xleftmargin=0pt,
}

\captionsetup[listing]{position=bottom,skip=-0.5\baselineskip}

\begin{document}

\section{Paragraph}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.

\begin{listing}[!htp]
\begin{minted}{csharp}
AudioSource audio = gameObject.GetComponent<AudioSource>();
\end{minted}
\caption{Example Code Showing the Use of GetComponent\label{show}}
\end{listing}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.

\end{document}