27
\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?

lockstep
  • 250,273
Ichibann
  • 8,381

2 Answers2

26

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}
lockstep
  • 250,273
  • 1
    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
14

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.

Ulrike Fischer
  • 327,261