Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
\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?

share|improve this question
add comment

2 Answers 2

up vote 8 down vote accepted

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}
share|improve this answer
    
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
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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