2

I need to add a \caption to some textual examples. For example:

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged

Example 1. Lorem Ipsum

However, what is caption type in such cases? There is obviously no \captionof{example}{Lorem Ipsum}. I could only find \captionof{figure} and \captionof{table} but this is pretty limiting.

1
  • Should this content float within the document?
    – Werner
    Dec 4, 2016 at 19:16

1 Answer 1

2

You will have to create your own caption type if you wish to use a non-default \caption. caption provides this functionality, as does float:

enter image description here

\documentclass{article}

\usepackage{newfloat,caption,float}

\DeclareFloatingEnvironment[
  fileext = loe,
  listname = Examples,
  name = Example,
  placement = H,
  within = none,
  ]{example}
\captionsetup[example]{labelfont=bf}

\begin{document}

Some text before.

\begin{example}
Lorem Ipsum is simply dummy text of the printing and typesetting industry. 
Lorem Ipsum has been the industry's standard dummy text ever since the~1500s, 
when an unknown printer took a galley of type and scrambled it to make a type 
specimen book. It has survived not only five centuries, but also the leap into 
electronic typesetting, remaining essentially unchanged.

\caption{Lorem Ipsum}
\end{example}

Some text after.

\end{document}

While example is considered a float, the positioning is set to [H]ere by default and therefore will not float. It seems reasonable that the construction should not be broken across the page boundary, as it would not make sense otherwise.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .