Graphics, Figures & TablesImproper Alignment on using Long Table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Deep33
Posts: 1
Joined: Tue Sep 14, 2021 9:18 am

Improper Alignment on using Long Table

Post by Deep33 »

Hi,
I have just started with Latex ( a beginner in Latex). I am using Long tables for my report. But for some reason, the alignment of the tables are not proper. I'm unable to identify the cause for this.
NEED HELP TO DEBUG.

Code: Select all

\documentclass[demo]{article}
\usepackage[T1]{fontenc}
\usepackage{dcolumn}
\usepackage[a4paper,vmargin=0.5in,hmargin=1in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsfonts,amssymb,graphicx,wrapfig,float,multirow}
\usepackage{pgfplots}
\usepackage{parskip,array,booktabs}
\usepackage[11pt]{moresize}
\usepackage{longtable}
\usepgfplotslibrary{dateplot}
\pgfplotsset{compat=1.8}
\graphicspath{C:\Users\priyankas\Desktop}
\renewcommand{\familydefault}{\sfdefault}

\begin{document}
\restylefloat{table}
\begin{table}
\begin{tabular}{p{0.45\textwidth}>{\raggedleft}p{0.52\textwidth}}
\includegraphics[width=4cm,height=1cm]{logo.png}&\includegraphics[width=4cm,height=1cm]{hortisortlogo.png}
\end{tabular}
\vskip 0.3cm
\noindent\rule{0.8\paperwidth}{1.5pt}
\end{table}

\begin{large}
\begin{center}
\textbf{Apple Processing Plant}
\end{center}
\end{large}

\vskip 0.5cm

\begin{table}[H]
\setlength\extrarowheight{4pt}
\centering
\begin{tabular}{llll}
\textbf{Lot No:}  &\multicolumn{3}{l}{L210907143732}\\
\textbf{Grower Name:} &\multicolumn{3}{l}{}\\
\textbf{Program Name:} &\multicolumn{3}{l}{TemplateOB}\\
\textbf{Start Date:} &07-09-2021 &\textbf{Start Time:} &02:37 PM  \\
\textbf{End Date:} &07-09-2021 &\textbf{Start Time:} &02:41 PM  \\
\end{tabular}
\end{table}

\begin{large}
\textbf{Summary:}
\end{large}

\begin{table}[H]
\setlength\extrarowheight{2.5pt}
\begin{tabular}{|l|l|l|}
\hline
\textbf{Total Fruits} & 26\\
\hline
\textbf{Total Weight (Kg)} & 0.000\\
\hline
\end{tabular}
\end{table}

\vskip 0.5cm
\begin{large}
\textbf{Outlet-wise Report:}
\end{large}

\setlength\extrarowheight{2.5pt}
\begin{longtable}[l]{|c|c|c|c|}\hline\textbf{Outlet} & \textbf{Category} & \textbf{Count} & \textbf{Outlet Count}\\\hline
\endhead\multirow{4}{*}{1} & C2 - HiOrange S4 - 60    & 13 & \multirow{4}{*}{26}\\\cline{2-3}& C2 - HiOrange S3 - 40    & 13 & \\\cline{2-3}& C2 - HiOrange S2 - 30    & 0 & \\\cline{2-3}& C2 - HiOrange S1 - 14    & 0 & \\\hline\multirow{4}{*}{2} & C2 - HiRed S8 - Chura    & 0 & \multirow{4}{*}{0}\\\cline{2-3}& C2 - HiRed S7 - 140    & 0 & \\\cline{2-3}& C2 - HiRed S6 - 110    & 0 & \\\cline{2-3}& C2 - HiRed S5 - 80    & 0 & \\\hline\multirow{4}{*}{3} & C3 - HiGreen S4 - 60    & 0 & \multirow{4}{*}{0}\\\cline{2-3}& C3 - HiGreen S3 - 40    & 0 & \\\cline{2-3}& C3 - HiGreen S2 - 30    & 0 & \\\cline{2-3}& C3 - HiGreen S1 - 14    & 0 & \\\hline\multirow{4}{*}{4} & C3 - HiGreen S8 - Chura    & 0 & \multirow{4}{*}{0}\\\cline{2-3}& C3 - HiGreen S7 - 140    & 0 & \\\cline{2-3}& C3 - HiGreen S6 - 110    & 0 & \\\cline{2-3}& C3 - HiGreen S5 - 80    & 0 & \\\hline\multirow{4}{*}{5} & C4 - HiYellow S4 - 60    & 0 & \multirow{4}{*}{0}\\\cline{2-3}& C4 - HiYellow S3 - 40    & 0 & \\\cline{2-3}& C4 - HiYellow S2 - 30    & 0 & \\\cline{2-3}& C4 - HiYellow S1 - 14    & 0 & \\\hline\multirow{4}{*}{6} & C4 - HiYellow S8 - Chura    & 0 & \multirow{4}{*}{0}\\\cline{2-3}& C4 - HiYellow S7 - 140    & 0 & \\\cline{2-3}& C4 - HiYellow S6 - 110    & 0 & \\\cline{2-3}& C4 - HiYellow S5 - 80    & 0 & \\\hline\multirow{8}{*}{7} & C1 - MixColour S1 - 14    & 0 & \multirow{8}{*}{0}\\\cline{2-3}& C1 - MixColour S3 - 40    & 0 & \\\cline{2-3}& C1 - MixColour S8 - Chura    & 0 & \\\cline{2-3}& C1 - MixColour S7 - 140    & 0 & \\\cline{2-3}& C1 - MixColour S6 - 110    & 0 & \\\cline{2-3}& C1 - MixColour S5 - 80    & 0 & \\\cline{2-3}& C1 - MixColour S4 - 60    & 0 & \\\cline{2-3}& C1 - MixColour S2 - 30    & 0 & \\\hline\end{longtable}


\vskip 0.5cm
\begin{large}
\textbf{Grade-wise Report:}
\end{large}

\setlength\extrarowheight{2.5pt}
\begin{longtable}[l]{|c|c|c|}
\hline\textbf{Color} &\textbf{Size} &\textbf{Count}\\
\hline
\endhead
\multirow{4}{*}{C2 - HiOrange} & \multirow{1}{*}{S4 - 60} & 13\\\cline{2-3}&\multirow{1}{*}{S3 - 40}&13\\\cline{2-3}&\multirow{1}{*}{S2 - 30}&0\\\cline{2-3}&\multirow{1}{*}{S1 - 14}&0\\\cline{2-3}\hline\multirow{4}{*}{C2 - HiRed} & \multirow{1}{*}{S8 - Chura} & 0\\\cline{2-3}&\multirow{1}{*}{S7 - 140}&0\\\cline{2-3}&\multirow{1}{*}{S6 - 110}&0\\\cline{2-3}&\multirow{1}{*}{S5 - 80}&0\\\cline{2-3}\hline\multirow{8}{*}{C3 - HiGreen} & \multirow{1}{*}{S4 - 60} & 0\\\cline{2-3}&\multirow{1}{*}{S3 - 40}&0\\\cline{2-3}&\multirow{1}{*}{S2 - 30}&0\\\cline{2-3}&\multirow{1}{*}{S1 - 14}&0\\\cline{2-3}&\multirow{1}{*}{S8 - Chura}&0\\\cline{2-3}&\multirow{1}{*}{S7 - 140}&0\\\cline{2-3}&\multirow{1}{*}{S6 - 110}&0\\\cline{2-3}&\multirow{1}{*}{S5 - 80}&0\\\cline{2-3}\hline\multirow{8}{*}{C4 - HiYellow} & \multirow{1}{*}{S4 - 60} & 0\\\cline{2-3}&\multirow{1}{*}{S3 - 40}&0\\\cline{2-3}&\multirow{1}{*}{S2 - 30}&0\\\cline{2-3}&\multirow{1}{*}{S1 - 14}&0\\\cline{2-3}&\multirow{1}{*}{S8 - Chura}&0\\\cline{2-3}&\multirow{1}{*}{S7 - 140}&0\\\cline{2-3}&\multirow{1}{*}{S6 - 110}&0\\\cline{2-3}&\multirow{1}{*}{S5 - 80}&0\\\cline{2-3}\hline\multirow{8}{*}{C1 - MixColour} & \multirow{1}{*}{S1 - 14} & 0\\\cline{2-3}&\multirow{1}{*}{S3 - 40}&0\\\cline{2-3}&\multirow{1}{*}{S8 - Chura}&0\\\cline{2-3}&\multirow{1}{*}{S7 - 140}&0\\\cline{2-3}&\multirow{1}{*}{S6 - 110}&0\\\cline{2-3}&\multirow{1}{*}{S5 - 80}&0\\\cline{2-3}&\multirow{1}{*}{S4 - 60}&0\\\cline{2-3}&\multirow{1}{*}{S2 - 30}&0\\\cline{2-3}\hline
\end{longtable}


\end{document}
1.PNG
1.PNG (55.78 KiB) Viewed 3190 times
2.PNG
2.PNG (42.34 KiB) Viewed 3190 times
3.PNG
3.PNG (32.43 KiB) Viewed 3190 times
4.PNG
4.PNG (21.47 KiB) Viewed 3190 times
Last edited by Stefan Kottwitz on Tue Sep 14, 2021 11:49 am, edited 2 times in total.
Reason: code tags fixed, demo option to make compilable without logo

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

Improper Alignment on using Long Table

Post by Ijon Tichy »

With longtable you need more than one LaTeX run. See the message:
Package longtable Warning: Table widths have changed. Rerun LaTeX.
in your log file.

After at least two runs you should get the same result with your local LaTeX installation as you get here after clicking to the Run LaTeX here button.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
Post Reply