1

Very short question: How to put table inside of the ntheorem environment?

Simple first try

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}

\usepackage{ntheorem}
\usepackage{amsmath}
\usepackage{thmtools}
\usepackage[dvipsnames]{xcolor}

\definecolor{defbckgcolor}{RGB}{200,220,240}
\theoremstyle{break}
\declaretheorem[
name=Definition,
shaded={margin=0.5em, bgcolor=defbckgcolor},
%thmbox=M,
numberwithin=section]
{definition}

%opening
\title{Table in ntheorem}
\author{John Doe}

\begin{document}

\maketitle

\section{Example}
intro
\begin{definition}
Some text
\begin{table}[htbp]
\begin{tabular}{lll}
\hline
1 & 2 & 3\\
4 & 5 & 6\\
7 & 8 & 9\\
\hline
\end{tabular}
\caption{Example}  
\end{table}
more text.
\end{definition}
conclusion

\end{document}

gives an error:

Overfull \hbox (6.0pt too wide) in paragraph at lines 40--40
[][] 
[1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}]

! LaTeX Error: Float(s) lost.

Didn't yet try, but how about figures? Same issue?

8
  • Same issue. Always refer to figures and tables. You never know where they end up. Besides, it is not a good idea to place a figure inside a paragraph any ways.
    – daleif
    Oct 2, 2013 at 10:01
  • 1
    BTW: in this particular situation you may wan to try \begin{table}[htbp] instead. By default the h (here about) is not included.
    – daleif
    Oct 2, 2013 at 10:02
  • It is working OK with \begin{table}[htbp]. But, it's not working with ntheorem.
    – sivic
    Oct 2, 2013 at 10:11
  • Then please post a full minimal example instead of just a snipplet.
    – daleif
    Oct 2, 2013 at 10:13
  • 1
    You are shading the theorem, thus it cannot contain floats. You will need to \captionof from the caption package in order to a a caption to a non-float. An be careful that other floats does not float past the theorem and mess up the numbering.
    – daleif
    Oct 2, 2013 at 10:52

2 Answers 2

4

Use the \captionof or \captionof* command from the caption package (see § 3.1, p. 18 of the doc). You should write something like:

\begin{center}  
   \begin{tabular}{lll}  
      \hline  
      1 & 2 & 3\\  
      4 & 5 & 6\\  
      7 & 8 & 9\\  
      \hline  
   \end{tabular}  
\captionof{table}{Example}  
\end{center}  
1
  • In its current form your answer is very short but seems to point into the right direction. Maybe you want to elaborate a bit more and also add some code example? Oct 2, 2013 at 12:25
1

"floats lost" means you've put a float inside another float, or in a minipage, or similar. floats put there can't "get out" to the float placement mechanism.

i assume you really don't want a table float; you want the tabular environment to appear "where you typed it".

so just delete \begin{table} and \end{table}, and the problem will go away.

1
  • This is a partial solution, but how can I put table caption?
    – sivic
    Oct 2, 2013 at 10:43

You must log in to answer this question.

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