0

till now my tables were like this:

\documentclass{article}

\usepackage{capt-of}

\begin{document}

\begin{table}    
\begin{minipage}[h!]{\linewidth}    
\centering    
\begin{tabular}{p{2cm}p{2cm}p{2cm}}
    \hline    
     \rule{0pt}{8pt}    
     \textbf{column a} & \textbf{column b} & \textbf{column c} \\      
        \hline    
        \rule{0pt}{8pt}    
        text    &   text        & text   \\    
        \rule{0pt}{8pt}    
        text    &   text        & text   \\
        \hline    
        \rule{0pt}{8pt}    
        text    &   text        & text   \\    
    \hline    
    \hline    
    \end{tabular}
    \captionof{table}{text for the listing}{caption} \label{tab:table}     
    \end{minipage}    
    \end{table}

\end{document}

well, the problem is, that some table's appear above the caption. My idea was to put these ones in a non-floating environment. Since I have more than 60 figures and tables I don't want to change them all in a tabular or tabularx-environment.

Is there a way to put some figures or tables in a non-floating-environment AND to leave the rest in a table - environment.

With: \captionof....

And they need to be numbered =(

4
  • Change table by center and use \captionof – skpblack Aug 27 '14 at 10:45
  • 1
    \begin{minipage}[h!]{\linewidth} isn't doing anything: a linewidth wide minipage in a table takes up the whole table and minipage does not have an optional argument that takes [h!] that syntax would be legal 9but generate a warning) if used on the table environment. – David Carlisle Aug 27 '14 at 10:49
  • There is no need to use captionof inside a table: just use \caption – David Carlisle Aug 27 '14 at 10:49
  • Your question is not clear: you say that some tables appear above the caption, but latex does not move the caption relative to the tabular: if you put the caption below the tabular as here, it will always come below it in the output – David Carlisle Aug 27 '14 at 11:40
1

If you wish to mix-and-match the use of a floating and non-floating figure or table, then you should use the float package's [H] float specifier. Here's a small example:

enter image description here

\documentclass{article}
\usepackage[margin=1in]{geometry}% Just for this example
\usepackage{float,lipsum,graphicx}
\begin{document}
\lipsum[1]
\begin{figure}[H]% Non-floating figure float
  \centering
  \includegraphics[width = .7\linewidth, height = 50pt]{example-image-a}
  \caption{A figure}
\end{figure}
\lipsum[2]
\begin{figure}[t]% Regular floating figure
  \centering
  \includegraphics[width = .7\linewidth, height = 50pt]{example-image-b}
  \caption{Another figure}
\end{figure}
\lipsum[3]
\end{document}

The above works for any of the default floats (figure and table, as well as new ones defined via the float package). Additionally, there's no need for using capt-of as the floats provide sufficient \captioning.

The above example also highlights one of the problems of mixing non-floating floats with other/regular floats. The numbering will still work, but the visual placement of numbering might be mixed (Figure 2 has floated to the top of the page, visually appearing before the non-floating Figure 1 which was placed [H]ERE).

1

What's wrong with captionof? Just put your non-floating tabular in a minipage and use captionof. Maybe I'm missing something? I'm using this in a document currently, and it's working fine.

\documentclass{article}

\usepackage{capt-of}

\begin{document}

\noindent\begin{minipage}{\textwidth}
    \begin{tabular}{p{2cm}p{2cm}p{2cm}}
    \hline    
     \rule{0pt}{8pt}    
     \textbf{column a} & \textbf{column b} & \textbf{column c} \\      
        \hline    
        \rule{0pt}{8pt}    
        text    &   text        & text   \\    
        \rule{0pt}{8pt}    
        text    &   text        & text   \\
        \hline    
        \rule{0pt}{8pt}    
        text    &   text        & text   \\    
    \hline    
    \hline    
    \end{tabular}
    \captionof{table}{text for the listing}{caption} \label{tab:table}
\end{minipage}



\end{document}

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.