[Tex/LaTex] How to fix table’s caption that is overlapping the content.

captionstables

I have an table:

\begin{table}[h]
\begin{center}
\caption{Test wydajnosci wykonanej aplikacji mierzony w czasie odpowiedzi serwera 000webhost.com w milisekundach na wybrane zapytania.}
 \begin{tabular}{| p{6cm} | p{2.5cm} | p{1.5cm} | p{2.4cm} | } 
 \hline
 & \multicolumn{3}{ |c| }{ {\bf Czasy odpowiedzi:} } \\ \hline
 {\bf  Typy zapytań}  &  {\bf  Srednia \mbox{arytmetyczna}} & {\bf Mediana} & {\bf Odchylenie standardowe} \\ \hline

 Próba przeniesienia karty & 0.0 & 0.0 & 0.0 \\ \hline
 Żądania generowane podczas standardowej rozgrywki & 0.0 & 0.0 & 0.0 \\ \hline
 Zapytania niedozwolone (wbrew regułom) & 0.0 & 0.0 & 0.0 \\ \hline
 Zapytania niedozwolone (niepoprawny format) & 0.0 & 0.0 & 0.0 \\ \hline
 Odsyłanie literału & 0.0 & 0.0 & 0.0 \\ \hline
 Przeglądanie strony www opartej o WordPress & 0.0 & 0.0 & 0.0 \\ \hline

 \end{tabular}
\end{center}
\end{table}

Which render to this:
enter image description here

The table's caption is obviously bad positioned, overlapping the table's content.

How can I fix that and make the caption appear above the table?

Best Answer

Please provide an MWE which shows your actual state. Your provided code does not result in an error. However, I fixed it a bit for you. Here is how I would type it (including a booktabs-version in the end:

% arara: pdflatex

\documentclass{article}
\usepackage[polish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{caption}
\usepackage{siunitx}
\usepackage{array}
\usepackage{ragged2e}
\usepackage{booktabs}
\usepackage{microtype}
\usepackage{hyperref}

\newcommand{\specialcell}[2][c]{%
    \begin{tabular}[#1]{@{}l@{}}#2\end{tabular}}

\begin{document}
\begin{table}[h]
    \centering
    \caption{Test wydajnosci wykonanej aplikacji mierzony w czasie odpowiedzi serwera \url{000webhost.com} w milisekundach na wybrane zapytania.}
    \begin{tabular}{| >{\RaggedRight}p{4.25cm} |  *{3}{S[table-format=1.1]|} } 
        \hline
        & \multicolumn{3}{ c| }{ \textbf{Czasy odpowiedzi}: } \\ \hline
        \textbf{Typy zapytań}  &  {\specialcell{\textbf{Srednia}\\\textbf{arytmetyczna}}} & \textbf{Mediana} & {\specialcell{\textbf{Odchylenie}\\\textbf{standardowe}}} \\ \hline          
        Próba przeniesienia karty & 0.0 & 0.0 & 0.0 \\ \hline
        Żądania generowane podczas standardowej rozgrywki & 0.0 & 0.0 & 0.0 \\ \hline
        Zapytania niedozwolone (wbrew regułom) & 0.0 & 0.0 & 0.0 \\ \hline
        Zapytania niedozwolone (niepoprawny format) & 0.0 & 0.0 & 0.0 \\ \hline
        Odsyłanie literału & 0.0 & 0.0 & 0.0 \\ \hline
        Przeglądanie strony www opartej o WordPress & 0.0 & 0.0 & 0.0 \\ \hline         
    \end{tabular}
\end{table}
%
\setcounter{section}{4}\setcounter{subsection}{4}\setcounter{subsubsection}{1}
\subsubsection{Testy regresyjne}
%
\begin{table}
    \centering
    \caption{Booktabs-version}
    \begin{tabular}{ >{\RaggedRight}p{4.3cm} *{3}{S[table-format=1.1]} } 
        \toprule
        & \multicolumn{3}{ c }{ \textbf{Czasy odpowiedzi}: } \\ \cmidrule{2-4}
        \textbf{Typy zapytań}  &  {\specialcell{\textbf{Srednia}\\\textbf{arytmetyczna}}} & \textbf{Mediana} & {\specialcell{\textbf{Odchylenie}\\\textbf{standardowe}}} \\ \midrule            
        Próba przeniesienia karty & 0.0 & 0.0 & 0.0 \\\cmidrule{1-4}
        Żądania generowane podczas standardowej rozgrywki & 0.0 & 0.0 & 0.0 \\\cmidrule{1-4}
        Zapytania niedozwolone (wbrew regułom) & 0.0 & 0.0 & 0.0 \\\cmidrule{1-4}
        Zapytania niedozwolone (niepoprawny format) & 0.0 & 0.0 & 0.0 \\\cmidrule{1-4}
        Odsyłanie literału & 0.0 & 0.0 & 0.0 \\\cmidrule{1-4}
        Przeglądanie strony www opartej o WordPress & 0.0 & 0.0 & 0.0 \\ \bottomrule            
    \end{tabular}
\end{table}
\end{document}

enter image description here