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.

$\item last bla bla$supposed to do?! And the reason why\sectioncan 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 03 '15 at 07:53$\item last bla bla$rather than \item $last bla bla$ – touhami Aug 03 '15 at 07:56\sectioninside 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 03 '15 at 09:18\itemyou don't think same? – touhami Aug 03 '15 at 14:53many incorrect inputs? – touhami Aug 03 '15 at 14:56\documentclass{article} \begin{document} \section[z]{\section{aa}} \fbox{\egroup\egroup aaa\bgroup\bgroup} \end{document}– David Carlisle Aug 03 '15 at 15:32