1

Below I have the code to create a table in latex, but the horizontal dashed line is not drawn over the full width of the table.

\begin{table}[H]
\caption{Aggregated sales data of all products} % title of Table
\label{dfbig}
\centering % used for centering table
\begin{tabular}{| c | c | c | c | c | c |} % centered columns (7 columns)
\hline\hline %inserts double horizontal lines
Product & Week & Sales Quantity & Subgroup & Group & Category\\ [0.5ex] % inserts table
%heading
\hline % inserts single horizontal line
$p_1$ & $w_1$ & $Q_1(p_1,\ell_{j})$ & $S(p_1)$ & $R(p_1)}$ & $C(p_1)$ \\ 
$p_1$ & $w_2$ & $Q_2(p_1,\ell_{j})$ & $S(p_1)$ & $R(p_1)$ & $C(p_1)$ \\ 
$\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ \\
$p_1$ & $w_{n_w}$ & $Q_{w_n}(p_1,\ell_{j})$ & $S(p_1)$ & $R(p_1)$ & $C(p_1)$ \\ 
\hdashline
$p_2$ & $w_1$ & $Q_1(p_2,\ell_{j})$ & $S(p_2)$ & $R(p_2)$ & $C(p_2)$ \\ 
$p_2$ & $w_2$ & $Q_2(p_2,\ell_{j})$ & $S(p_2)$ & $R(p_2)$ & $C(p_2)$ \\ 
$\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ \\
$p_2$ & $w_{n_w}$ & $Q_{w_n}(p_2,\ell_{j})$ & $S(p_2)$ & $R(p_2)$ & $C(p_2)$ \\
\hdashline
$\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ \\
$\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ \\
\hdashline
$p_{n_p}$ & $w_1$ & $Q_1(p_n,\ell_{j})$ & $S(p_{n_p})$ & $R(p_{n_p})$ & $C(p_{n_p})$ \\ 
$p_{n_p}$ & $w_2$ & $Q_2(p_n,\ell_{j})$ & $S(p_{n_p})$ & $R(p_{n_p})$ & $C(p_{n_p})$ \\ 
$\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ \\
$p_{n_p}$ & $w_{n_w}$ & $Q_{w_n}(p_n,\ell_{j})$ & $S(p_{n_p})$ & $R(p_{n_p})$ & $C(p_{n_p})$ \\ [1ex] % [1ex] adds vertical space
\hline %inserts single line
\end{tabular}
\end{table}

I get this:

enter image description here

Does anyone know how to fix this?

2
  • 3
    Show us the definition of the command \hdashline. I guess it contains some \cline{}!
    – Sigur
    Commented Jan 14, 2019 at 15:09
  • 2
    @Sigur Maybe the \hdashline is from the arydshln package.
    – user156344
    Commented Jan 14, 2019 at 15:15

1 Answer 1

2

In the first row, you had an extra brace in $R(p_1)}$, remove this and recompile.

\documentclass{article}
\usepackage{arydshln}

\begin{document}

\begin{table}
\caption{Aggregated sales data of all products} % title of Table
\label{dfbig}
\centering % used for centering table
\begin{tabular}{| *7{c|} } % centered columns (7 columns)
\hline\hline %inserts double horizontal lines
Product & Week & Sales Quantity & Subgroup & Group & Category\\ [0.5ex] % inserts table
%heading
\hline % inserts single horizontal line
$p_1$ & $w_1$ & $Q_1(p_1,\ell_{j})$ & $S(p_1)$ & $R(p_1)$ & $C(p_1)$ \\ 
$p_1$ & $w_2$ & $Q_2(p_1,\ell_{j})$ & $S(p_1)$ & $R(p_1)$ & $C(p_1)$ \\ 
$\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ \\
$p_1$ & $w_{n_w}$ & $Q_{w_n}(p_1,\ell_{j})$ & $S(p_1)$ & $R(p_1)$ & $C(p_1)$ \\ 
\hdashline
$p_2$ & $w_1$ & $Q_1(p_2,\ell_{j})$ & $S(p_2)$ & $R(p_2)$ & $C(p_2)$ \\ 
$p_2$ & $w_2$ & $Q_2(p_2,\ell_{j})$ & $S(p_2)$ & $R(p_2)$ & $C(p_2)$ \\ 
$\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ \\
$p_2$ & $w_{n_w}$ & $Q_{w_n}(p_2,\ell_{j})$ & $S(p_2)$ & $R(p_2)$ & $C(p_2)$ \\
\hdashline
$\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ \\
$\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ \\
\hdashline
$p_{n_p}$ & $w_1$ & $Q_1(p_n,\ell_{j})$ & $S(p_{n_p})$ & $R(p_{n_p})$ & $C(p_{n_p})$ \\ 
$p_{n_p}$ & $w_2$ & $Q_2(p_n,\ell_{j})$ & $S(p_{n_p})$ & $R(p_{n_p})$ & $C(p_{n_p})$ \\ 
$\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ \\
$p_{n_p}$ & $w_{n_w}$ & $Q_{w_n}(p_n,\ell_{j})$ & $S(p_{n_p})$ & $R(p_{n_p})$ & $C(p_{n_p})$ \\ [1ex] % [1ex] adds vertical space
\hline %inserts single line
\end{tabular}
\end{table}

\end{document}

enter image description here

You must log in to answer this question.

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