3

I have the following code:

\documentclass[preprint,12pt]{elsarticle}
\usepackage{amssymb}
\usepackage{lineno}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\usepackage{mathtools}
\usepackage{multicol}
\usepackage{wrapfig}

\begin{document}

\begin{table}[H!]
   \begin{center}
       \caption{Blah blah blah}
        \begin{tabular}{|c|c|c|c|}
           \hline
            & Training & Validation & Testing \\
            \hline
            Normal & 9727 & 194 & 605\\
            \hline
            Dos & 3128 & 782 & 2298\\
            \hline
            Prob & 320 & 82 & 41\\
            \hline
            R2L & 4 & 1 & 7\\
           \hline
           U2R & 5 & 7 &4 \\
           \hline
       \end{tabular}
    \end{center}    
\end{table}

\end{document}

And I keep getting the following error:

Runaway argument?
{table}[H!] \begin {center} \caption {Dataset size used in  experiment\ETC.
Paragraph ended before \@float@HH was complete.
<to be read again> 
               \par 
l.298 

Any ideas? I seem to be missing the point.

3
  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. May 13, 2015 at 17:52
  • 2
    If I was going to guess at the solution, it'd be that [H!] isn't a standard placement. Perhaps the example you started from uses an additional package like float. May 13, 2015 at 17:54
  • you can't end paragraph in \caption
    – touhami
    May 13, 2015 at 17:54

2 Answers 2

3

H is a very special float placement specifier in the sense that it changes the traditional float into a non-float. Therefore, it would be completely strange to suggest a float specification that includes both suggested locations (like h, t, b, ...) together with a forced non-float H; that is, use something of the form

\begin{table}[htH]
  ...
\end{table}

say, since there's no precedence/consideration between "the traditional specifiers" and H. The same goes for ! (one of the force-suggested float specifiers).

So, use only

\begin{table}[H]
  ...
\end{table}

Internally float redefines the traditional float macros specifically to look for an [H] specifier. This search is very specific - [H] only and nothing else. Anything else and it would revert to the original float specifications. Read about this in the float documentation (section 4.2 Adapting LaTeX internals).

Also read up on When should we use \begin{center} instead of \centering?

2
  • You're missing the correct answer: “don't use [H].
    – egreg
    May 13, 2015 at 21:00
  • 1
    I like [H]. It helps me put the objects I create exactly where I want them...
    – milia
    May 14, 2015 at 23:41
0

\documentclass[preprint,12pt]{article} \usepackage{amssymb} \usepackage{lineno}

\usepackage{mathtools} \usepackage{multicol} \usepackage{wrapfig}

\begin{document}

\begin{table}[h]
    \begin{center}
        \caption{Blah blah blah}
        \begin{tabular}{|c|c|c|c|}
            \hline
            & Training & Validation & Testing \\
            \hline
            Normal & 9727 & 194 & 605\\
            \hline
            Dos & 3128 & 782 & 2298\\
            \hline
            Prob & 320 & 82 & 41\\
            \hline
            R2L & 4 & 1 & 7\\
            \hline
            U2R & 5 & 7 &4 \\
            \hline
        \end{tabular}
    \end{center}    
\end{table}

\end{document}

The statement is for5, c values and you have given just 4 c values. This may be the error. Now it works well. I have removed many packages which you can add. I do not have them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.