[Tex/LaTex] How to combine ‘float’ and ‘longtable’ packages functionality

floatslongtabletables

I want to use exact placement for my table. As I read on SO it can be done with [H] option for table environment provided by ‘float’ package. But this doesn't seem to work with longtable which I have to use due to the fact that my table is really long.

What I tried so far

% Preamble
\usepackage{longtable}
\usepackage{float}
\restylefloat{longtable} % as \restylefloat{table} doesn't take effect

…

% Long table
\begin{longtable}[H]{| c | c | c | c |}
\hline
1        & 5 & 6 & 7  \\ \hline
1        & 5 & 6 & 7  \\ \hline
1        & 5 & 6 & 7  \\ \hline
% and so on, many rows
\end{longtable}

This gives me a bunch of errors like

Misplaced \noalign. [\hline]
Misplaced alignment tab character &. [1          &]

Maybe there are some other ways to get desired behaviour of longtable?

EDIT: I add the screenshot of exact problem with longtable placement. In short: it is placed before the paragraph, while I wrote it after.
longtable problem

Best Answer

As clarified in comments the problem is unrelated to floating environments.

\documentclass{article}
\usepackage{longtable}


\begin{document}

\paragraph{zz}

\begin{longtable}{| c | c | c | c |}
\hline
1        & 5 & 6 & 7  \\ \hline
1        & 5 & 6 & 7  \\ \hline
1        & 5 & 6 & 7  \\ \hline
% and so on, many rows
\end{longtable}

aa

\end{document}

\paragraph is an inline heading (designed to be used after \subsubsection) the heading is held back and added to the first line of the following paragraph.

longtable does not start a paragraph so the heading gets added to aa.

To fix this add an empty paragraph

\documentclass{article}
\usepackage{longtable}


\begin{document}

\paragraph{zz}
\mbox{}%<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

\begin{longtable}{| c | c | c | c |}
\hline
1        & 5 & 6 & 7  \\ \hline
1        & 5 & 6 & 7  \\ \hline
1        & 5 & 6 & 7  \\ \hline
% and so on, many rows
\end{longtable}

aa

\end{document}

But are you sure you want an inline rather than a display heading in this context?