I have the following code, which works fine when package caption is inactive. However with caption the title of the "steckbrief" moves out of the box. What is it that caption changes that the title moves to the outside?

I had previously the boxedminipae environment gone into the \fs@my block but that produced overfull boxes. Removing the \fs@my block puts the caption below the factsheet.

Any help appreciated.

Kind regards


(this has been asked on comp.text.tex without any answer.)

\usepackage{calc,boxedminipage2e,float, capt-of}
\newcommand\fs@my{%Caption im Rahmen
\newfloat{factsheet}{hbtp}{los} % Steckbrief, Factsheet
{  \end{list}%enddefinition
\begin{FS}{Bildung und Ziel}%
 {Thyrotropin"=Releasing Hormon}{trh}
\item [Gen]Chromosom: 3; Genort: 3q13.3-q21
\item [Sequenz]\textbf{p{EHP}-NH$_2$}
\item [Bildung und Ziel] TRH wird vor allem im{PVN} gebildet...
  • Your example does not compile
    – user31729
    Commented Jan 17, 2016 at 10:03
  • it does now, sorry Commented Jan 17, 2016 at 10:12
  • Related: groups.google.com/forum/#!topic/de.comp.text.tex/ow-XIRlbgmU
    – Johannes_B
    Commented Jan 17, 2016 at 13:26
  • it looks the same but is not, in that topic it was the overfull boxes, which here are avoided. Here it is a strange behaviour of caption that I donot understand and which has not been answered in the comp.text.tex newsgroup. Commented Jan 17, 2016 at 14:34
  • What exactly are you trying to do? If you want this to be a new type of float, then why would you want the caption to be as if it was a figure? caption is sensitive to this kind of new float, and therefore tries to do the right thing. But that assumes that what you are asking it to do makes sense. Here, it really doesn't.
    – cfr
    Commented Jan 17, 2016 at 22:58

1 Answer 1


Without caption package, \captionof{figure} simply expands to \def\@captype{figure}\caption. \caption has been redefined by the float package. The float package author has decided to make this redefinition globally. (A different approach would be redefining \caption only inside own environments.) Since the redefinition is globally, the new code of \caption needs something to detect if it was called within a float controlled by the float package or not. It uses the following code:

\ifx \csname @float@c@\@captype \endcsname \relax
% no environment of the float package
% environment controlled by the float package

So what happens when compiling your code? The environment factsheet starts. \captionof is used which changes \@captype from factsheet to figure and uses \caption afterwards. \caption checks for \ifx \csname @float@c@\@captype \endcsname \relax which is true since \@captype was redefined from factsheet to figure and figure is not controlled by the float package. So the float package thinks it's not responsible for this caption and therefore the ordinary caption code will be used. As result the caption will be typeset inside the box and there is no caption outside the box since the float package behaves as there was no \caption inside factsheet at all.

In total your code uses the following undocumented(!) facts:

  1. \caption is redefined by the float package globally
  2. \caption uses \@captype to distinguish between ordinary floating environments and ones controlled by the float package

If the implementation of the float package would differ in only one of these two points your caption would be typeset outside the box, since this is the documented(!) way the float package operates. The only reason why it's typeset inside the box (which is the unexpected behaviour!) is that using \captionof makes the check of the float package doomed to fail. (Try using \caption instead of \captionof and you'll see that the caption won't be inside the box either.)

Remember: You have even told the float package where to put captions of factsheet: \let\@fs@iftopcapt\iftrue which means "Typeset the caption on top of the float body".

If you don't want the caption to be typeset outside the float body, one could use the documented(!) way to tell this to the float package:

There is a \restylefloat* command which will restyle an existing float type but will keep the new float style from taking over the \caption command. In this case the user is responsible for handling their own captions.

So adding \restylefloat*{factsheet} right after \newfloat{factsheet}... is the documented way to tell the float package that you would like to typeset the caption inside the float body and not outside.

So far I have answered the question "Why is the caption typeset inside the box which is opposite to the documented and therefore expected behavior of the float package?". Now I would like to answer "Why is the caption without caption package within the box and with caption outside?". Well that's an easy one. Since the caption package redefines \caption as well it cannot emulate every internal implementation detail of the float package (and all the other packages the new \caption code has to work with). Instead it tries to emulate the documented behavior of the packages (or as cfr has expressed it in the comments above: "tries to do the right thing"), which means in your case: "Typeset the caption outside the float body, on top of it."

So when adding \restylefloat*{factsheet} you should see the same behavior with and without caption package.

BTW: Why are you defining factsheet anyway, why don't you simply use figure and \caption instead of factsheet and \captionof{figure}?

  • 1
    Thank you! factsheets are supposed to contain condensed information in my book about a hormone and a hormone building enzyme, figures are for illustrations Commented Jan 26, 2016 at 11:57
  • When you change \def\@fs@pre{}% \def\@fs@post{}% to \def\@fs@pre{\setlength{\fboxsep}{2pt}\begin{boxedminipage}[t][\relax][c]{0.96\linewidth}}% \def\@fs@post{\end{boxedminipage}} than you see that the outer box is to large by some pt. I have difficulties to understand this. I have already asked Scott Pakin and I also has no idea. I would appreciate if you have a solution for this problem. Bernhard Commented Jan 27, 2016 at 15:22
  • @BernhardKleine I will take a look at it at Saturday, and report.
    – user2574
    Commented Jan 28, 2016 at 19:54
  • @BernhardKleine When I add \restylefloat*{factsheet} and make your code changes, I get no difference between "without caption package" and "with caption package". What difference do you get?
    – user2574
    Commented Jan 31, 2016 at 12:38
  • sorry I dit not see your comment. I will check and come back Commented Feb 9, 2016 at 18:24

You must log in to answer this question.

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