Search code examples
latextabularmiktextexworks

Getting weird form of table


Hi all if anyone can help me. I am new to latex. I am trying to add table in my latex. I know the format but i don't know what I am doing wrong because my table is not in the form I want moreover it is giving me the error when I add caption.

I need some thing like this in the image

enter image description here

but I am getting this when I compile my latex code

enter image description here

Here is my code:

\begin{center}
 \begin{tabular}[!ht]{||c c ||} 
        \caption{Dataset Specifications}
        \centering \label{data}
 \hline
 Dataset & Samples \\ [0.5ex] 
 \hline\hline
 Vovid & 349 \\ 
 \hline
 noncovid & 397  \\ [1ex] 
 \hline


\end{tabular}
\end{center}

Solution

  • My minimal code:

    \documentclass{article}
    
    \setlength{\tabcolsep}{1em}
    \renewcommand{\arraystretch}{1.5}
    
    \begin{document}
    
    \begin{table}[htbp]
      \centering
      \begin{tabular}{|c|c|}
        \hline
        Dataset & Samples \\
        \hline
        Covid & 349 \\ 
        Non Covid & 397 \\
        \hline
      \end{tabular}
      \caption{Dataset Specifications}
      \label{tab:data}
    \end{table}
    
    \end{document}
    

    and its output:

    screenshot of output

    Please comment below here if any feature is missing or something is not clear to you :)