0

Hello I am trying to draw long table in latex in two pages. I have used longtable package but still every thing is overlapped on one another. It looks like in picture. My code is as follows:

\usepackage{longtable}
\begin{document}
    \begin{longtable}[H]
    \centering
      \setlength\extrarowheight{5pt}
   \begin{tabular}{ |p{3.5cm}||p{3.3cm}|p{3.3cm}|p{3.3cm}| }
\hline
System parameters  &Steady state simulation at cell voltage 1.35\si{V} &Steady state simulation at cell voltage 1.35\si{V} &Transient simulation \\
 \hline
a   &0.075  &0.075  &0.075\\
fv  &823.15 &823.15 &823.15\\
dsf &136720.0729    &136720.0733    &136720.073\\
ff  &60929.13415    &67052.77939    &48254.41811\\
ff  &430227.8227&774469.0564&293576.401\\
ff  &6930.843614    &13759.54063    &4397.631169\\
ff) &724.9280926    &759.3822837    &702.3558378\\
ff  &126.9999073    &532.1625423    &138.6410601\\
ff  &3.406775256    &17.32352093    &6.106443651\\
ff  &0.493541105&0.651667849    &0.347160992\\
ffE (\si{mol/s}) &0.179303961   &0.911764259    &0.321391771\\
ff  &778.8335281    &917.5963789    &692.7669968\\
ff  &2.490772357    &2.864034271    &2.667914307\\
ff  &892.1580047    &954.4744642    &857.87485\\
ff  &885.8513695    &942.4909806    &853.6193071\\
ff  &2.133114059    &1.433408993    &1.845442049\\
ff  &1.651490524    &2.866734694    &1.152784727\\
ff&0.436040703  &0.688364718    &0.382576613\\
ff  &0.751203837    &0.837535957    &0.682169459\\
ff  &0.56352883 &0.476290559    &0.518885236\\
ff  &197649.207 &203772.8527    &185392.804\\
ff  &7655.771707    &14518.92292    &5131.232447\\
ff  &126.9999073    &532.1625423    &135.8647496\\
ff  &7782.771614    &15051.08546    &5267.097196\\
ff  &627877.0297    &978241.9092    &480469.8634\\
dg  &7782.771614    &15051.08546    &5267.097196\\
fb  &635659.8013    &993292.9946    &485736.9606\\

\hline \end{tabular} \caption{nxxxxxxx} \label{tab:my_label} \end{longtable} \end{document}

enter image description here

leandriis
  • 62,593
VISHNU
  • 85
  • The longtable environment should replace the tabular environment, not surround it. You should reviece a bunch of error messages from your code. Please don't ignore them! Even if you get something that on first glance resembles a pdf file, there can still be issues with it. After an error, TeX only tries to recover enough to syntax check more of the file, it does not try to make sensible output after an error. – leandriis Aug 07 '20 at 19:28
  • Unrelated, but 1.35\si{V} should be replaced with \SI{1.35}{\volt} or \SI{1.35}{\V} – leandriis Aug 07 '20 at 19:31
  • Is your table really longer than a single page? To me it looks like it should fit onto a single page, while it indeed could be quite a bit wider than the textwidth. – leandriis Aug 07 '20 at 19:33
  • Also unrelated to the issue itself: Why do column 2 and 3 share the same column header text? What is the difference between the entries in the two columns? – leandriis Aug 07 '20 at 19:37
  • yes, the table is quite long. the header is a small mistake. ty for the units correction. – VISHNU Aug 07 '20 at 19:44

2 Answers2

1

It is not clear what is your problem (in your MWE the preamble of document is missed). Anyway, see if the following proposition works for you:

\documentclass{article}
\usepackage{geometry}
\usepackage{makecell, xltabular}
\newcommand\mcx[1]{\multicolumn{1}{>{\centering\arraybackslash}X|}{#1}}
\usepackage{siunitx}

\begin{document} \begingroup \setcellgapes{3pt} \makegapedcells \begin{xltabular}{\linewidth}{ |l||S|S|S| } \caption{nxxxxxxx} \label{tab:my_label}\ \Xhline{1pt} \makecell[t]{System\ parameters} & \mcx{Steady state simulation at cell voltage \SI{1.35}{V}} & \mcx{Steady state simulation at cell voltage \SI{1.35}{V}} & \mcx{Transient simulation} \ \Xhline{0.6pt} \endfirsthead \caption[]{nxxxxxxx} \ \Xhline{1pt} \makecell{System\ parameters} & \mcx{Steady state simulation at cell voltage \SI{1.35}{V}} & \mcx{Steady state simulation at cell voltage \SI{1.35}{V}} & \mcx{Transient simulation} \ \Xhline{0.6pt} \endhead \Xhline{0.6pt} \multicolumn{4}{r}{\small\textit{Continue on the next page}} \endfoot \Xhline{1pt} \endlastfoot a &0.075 &0.075 &0.075\ fv &823.15 &823.15 &823.15\ dsf &136720.0729 &136720.0733 &136720.073\ ff &60929.13415 &67052.77939 &48254.41811\ ff &430227.8227 &774469.0564 &293576.401\ ff &6930.843614 &13759.54063 &4397.631169\ ff) &724.9280926 &759.3822837 &702.3558378\ ff &126.9999073 &532.1625423 &138.6410601\ ff &3.406775256 &17.32352093 &6.106443651\ ff &0.493541105 &0.651667849 &0.347160992\ ffE (\si{mol/s})
&0.179303961 &0.911764259 &0.321391771\ ff &778.8335281 &917.5963789 &692.7669968\ ff &2.490772357 &2.864034271 &2.667914307\ ff &892.1580047 &954.4744642 &857.87485\ ff &885.8513695 &942.4909806 &853.6193071\ ff &2.133114059 &1.433408993 &1.845442049\ ff &1.651490524 &2.866734694 &1.152784727\ ff &0.436040703 &0.688364718 &0.382576613\ ff &0.751203837 &0.837535957 &0.682169459\ ff &0.56352883 &0.476290559 &0.518885236\ ff &197649.207 &203772.8527 &185392.804\ ff &7655.771707 &14518.92292 &5131.232447\ ff &126.9999073 &532.1625423 &135.8647496\ ff &7782.771614 &15051.08546 &5267.097196\ ff &627877.0297 &978241.9092 &480469.8634\ dg &7782.771614 &15051.08546 &5267.097196\ fb &635659.8013 &993292.9946 &485736.9606\ \hline \end{xltabular} \endgroup

  • Is your table longer than one page? If not, instead of used xltabular table environment you can use tabularx which can be inserted into table float.
  • In above MWE instead of longtable is used xltabular (which is combination of longtable and tabularx tables environments).
  • for horisontal rulles are used rules defined in the makecellpackage
  • numbers are aligned at decimal point by use of the S column type defined in the siunitx package
  • I wonder if you really need 9 decimal digits?

enter image description here

Edit: If you not like to have numbers aligned at decimal points, than replace

    \begin{xltabular}{\linewidth}{ |l||S|S|S| }

with

    \begin{xltabular}{\linewidth}{ |l||*{3}{>{\hskip 3em}X|} }

and you will get:

enter image description here

Zarko
  • 296,517
1

With the folllwing redesign that avoids vertical lines and uses just some horizontal lines in combination with evenly distribued white gaps to act as a guide to the eye, your table easily fits onto a single page:

enter image description here

\documentclass{article}
\usepackage{siunitx}
\sisetup{per-mode=symbol}
\usepackage{tabularx}
\usepackage{makecell}
\renewcommand{\theadfont}{\normalsize}
\usepackage{booktabs}
\begin{document}

\begin{table} \centering \caption{nxxxxxxx} \label{tab:my_label} \begin{tabular}{llll} \toprule \thead{System\ parameters}
&\multicolumn{2}{c}{\thead{Steady state simulation \at cell voltage}} & \thead{Transient\ simulation} \ \cmidrule{2-3} & \thead{\SI{1.35}{\V}} & \thead{\SI{1.35}{\V}} \ \midrule a & 0.075 & 0.075 & 0.075 \ fv & 823.15 & 823.15 & 823.15 \ dsf & 136720.0729 & 136720.0733 & 136720.073 \ \addlinespace ff & 60929.13415 & 67052.77939 & 48254.41811 \ ff & 430227.8227 & 774469.0564 & 293576.401 \ ff & 6930.843614 & 13759.54063 & 4397.631169 \ \addlinespace ff) & 724.9280926 & 759.3822837 & 702.3558378 \ ff & 126.9999073 & 532.1625423 & 138.6410601 \ ff & 3.406775256 & 17.32352093 & 6.106443651 \ \addlinespace ff & 0.493541105 & 0.651667849 & 0.347160992 \ ffE (\si{\mol\per\s}) & 0.179303961 & 0.911764259 & 0.321391771 \ ff & 778.8335281 & 917.5963789 & 692.7669968 \ \addlinespace ff & 2.490772357 & 2.864034271 & 2.667914307 \ ff & 892.1580047 & 954.4744642 & 857.87485 \ ff & 885.8513695 & 942.4909806 & 853.6193071 \ \addlinespace ff & 2.133114059 & 1.433408993 & 1.845442049 \ ff & 1.651490524 & 2.866734694 & 1.152784727 \ ff & 0.436040703 & 0.688364718 & 0.382576613 \ \addlinespace ff & 0.751203837 & 0.837535957 & 0.682169459 \ ff & 0.56352883 & 0.476290559 & 0.518885236 \ ff & 197649.207 & 203772.8527 & 185392.804 \ \addlinespace ff & 7655.771707 & 14518.92292 & 5131.232447 \ ff & 126.9999073 & 532.1625423 & 135.8647496 \ ff & 7782.771614 & 15051.08546 & 5267.097196 \ \addlinespace ff & 627877.0297 & 978241.9092 & 480469.8634 \ dg & 7782.771614 & 15051.08546 & 5267.097196 \ fb & 635659.8013 & 993292.9946 & 485736.9606 \

\bottomrule \end{tabular} \end{table} \end{document}

leandriis
  • 62,593