19
\documentclass{mwrep}
\usepackage[font=small,compatibility=false]{caption}
\usepackage[chapter]{minted}
\usepackage{lipsum}
\begin{document}
\chapter{Test}
\lipsum[2-3]
\captionof{listing}{Caption of listing}

\lipsum[2-3]
\end{document}

In the provided example, using of \captionof causes all paragraph indents to disappear (after \captionof). How can it be fixed?

18

One way is to use \captionof inside a group.

\documentclass{mwrep}
\usepackage[font=small,compatibility=false]{caption}
\usepackage{listings}
\usepackage{lipsum}
\begin{document}
\chapter{Test}
\lipsum[2-3]
\begingroup
\captionof{lstlisting}{Caption of listing}
\endgroup

\lipsum[2-3]
\end{document}
  • i seem to have said "it's probably best to use \captionof within an enclosing group", in the documentation (i had forgotten that!). it's not actually easy to make \captionof execute \caption inside a group -- it's actually \caption that causes the problem, and in the normal course of events, \caption is in a float, and hence in a group. – wasteofspace Jul 10 '12 at 18:33
12

caption warns you:

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

Put a group or environment around the command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.