1

I am trying to run the following code:

\documentclass{article}
\usepackage{lmodern}    
\usepackage{amsthm}
\usepackage[T1]{fontenc}        
\usepackage[utf8]{inputenc}
\usepackage{lastpage}           
\usepackage{indentfirst}        
\usepackage{color}          
\usepackage{graphicx}       
\usepackage{microtype} 
\usepackage{multirow}
\usepackage{multicol}
\counterwithin{figure}{chapter}
\counterwithin{table}{chapter}
\begin{document}
\chapter{CHAPTER}

I will show the Table \ref{First} and the Table \ref{Second}.
\begin{table}[h!]\begin{minipage}[b]{0.45\linewidth}
\centering
 \begin{tabular}{|c|c|c|c|c|}\hline\label{First} \cline{1-5}
\multicolumn{5}{|l|}{XXXXXXXXXXXXXXXXX}\\ \hline\hline
XX & XX &XX &XX &XX \\ \hline\hline
YY  &   YY  &   YY  &YY &YY \\ \hline
YY  &   YY  &   YY  &YY &YY \\ \hline
YY  &   YY  &   YY  &YY &YY \\ \hline
\end{tabular}
\caption{AAAAAAAAAAAAAAA}
\end{minipage}
\hspace{1 cm} \begin{minipage}[b]{0.45\linewidth}
\centering
 \begin{tabular}{|c|c|c|c|c|}\hline\label{Second} \cline{1-5}
\multicolumn{5}{|l|}{XXXXXXXXXXXXXXXXX}\\ \hline\hline
XX & XX &XX &XX &XX \\ \hline\hline
YY  &   YY  &   YY  &YY &YY \\ \hline
YY  &   YY  &   YY  &YY &YY \\ \hline
YY  &   YY  &   YY  &YY &YY \\ \hline
\end{tabular}
\caption{AAAAAAAAAAAAAAA}
\end{minipage}
\end{table}

\end{document}

However, I've got strange lines at top and do not get the references:

enter image description here

Many thanks for any light in advance!

1 Answer 1

3

enter image description here

  • \label{...} had to be after caption or referable counter in a table (which aren't present in your table).
  • Document class article doesn't define \chapter{...} . For it you neeed to use report or book document class (or other similar package, for example memoir)
\documentclass{article}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{microtype}

\begin{document}
\section{CHAPTER ?}

I will show the Table \ref{First} and the Table \ref{Second}.
    \begin{table}[ht]
\begin{minipage}[b]{0.45\linewidth}
\centering
 \begin{tabular}{|c|c|c|c|c|}\hline
\multicolumn{5}{|l|}{XXXXXXXXXXXXXXXXX}\\ \hline\hline
XX & XX &XX &XX &XX \\ \hline\hline
YY  &   YY  &   YY  &YY &YY \\ \hline
YY  &   YY  &   YY  &YY &YY \\ \hline
YY  &   YY  &   YY  &YY &YY \\ \hline
\end{tabular}
\caption{AAAAAAAAAAAAAAA}
\label{First}
\end{minipage}
\hspace{1 cm} \begin{minipage}[b]{0.45\linewidth}
\centering
 \begin{tabular}{|c|c|c|c|c|}\hline 
\multicolumn{5}{|l|}{XXXXXXXXXXXXXXXXX}\\ \hline\hline
XX & XX &XX &XX &XX \\ \hline\hline
YY  &   YY  &   YY  &YY &YY \\ \hline
YY  &   YY  &   YY  &YY &YY \\ \hline
YY  &   YY  &   YY  &YY &YY \\ \hline
\end{tabular}
\caption{AAAAAAAAAAAAAAA}
\label{Second}
\end{minipage}
    \end{table}
\end{document}
3
  • 1
    Is there really a reason to put a \hline\cline{1-5}? Sep 26, 2020 at 11:10
  • @Zarko, thank you! Sep 26, 2020 at 13:13
  • 1
    @F.Pantigny, of course not. That is just consequence copy-past your code. It should be \hline ... Now corrected!
    – Zarko
    Sep 26, 2020 at 13:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .