# Bug or feature of floats mechanism

If I type $\section{Second section}$ or

\begin{enumerate}
\item first bla bla
\item second bla bla
$\item last bla bla$
\end{enumerate}


I get the error message ! Missing $inserted... or ! LaTeX Error: Command \item invalid in math mode. But if I compile the following code, I get the (correct) output, but let say, stringe output. \documentclass{article} \usepackage{lipsum} \begin{document} \section{First section} \lipsum[1] \begin{table} \section{Second section} \caption{Just a table} \end{table} \begin{enumerate} \item first bla bla \item second bla bla \begin{table} \item last bla bla \caption{Just a table} \end{table} \end{enumerate} \section{Last section} \lipsum[1] \end{document}  Is this a bug? floating objects can go (any where) e.g. an \item goes before preceding items or worse within items of another enumerate. Is it a feature? numbering still correct, and one can need this. main question: why latex doesn't prevent \section, \item, ... commands from going inside a float environment and we know, conversely that \caption doesn't work outside floating environments. i.e. why there is no \gdef\@infloaterr#1{% \relax \ifx\@captype\@undefined \else \@latex@error{Command \protect#1 inside float} \fi}  similar to \@inmatherr. • Hello, what in the world is $\item last bla bla$ supposed to do?! And the reason why \section can be placed inside floats is probably that disallowing it would cost a lot of resources, which were very precious back in the 90s. – yo' Aug 3 '15 at 7:53 • Here to show goodness of (La)TeX if by arror you type $\item last bla bla$ rather than \item$last bla bla\$ – touhami Aug 3 '15 at 7:56
• A speed limit signal tells you that you shouldn't go faster than allowed, but has no way to prevent you from doing so. – egreg Aug 3 '15 at 7:56
• @touhami Ah it seems I missed the fact that it should be wrong, sorry :D – yo' Aug 3 '15 at 7:57
• There are many incorrect inputs that do not generate an error message. \section inside a float is an error it is just not trapped by the system (it would have taken an unreasonable amount of memory to do so at the point that latex was designed.) – David Carlisle Aug 3 '15 at 9:18

There are many incorrect inputs that do not generate an error message. (\section[z]{\section{aa}} for example).
\section inside a float is an error it is just not trapped by the system (it would have taken an unreasonable amount of memory to do so at the point that latex was designed.)
Similarly \caption needs to know what type of caption to make (stored internally in \@captype) so the test there is much easier as the default definition is that it generates an error, \caption just locally works in contexts that enable captions.