0

I've got a problem : the width of the longtable body and head are not the same :

Here the code :

\begin{center}
\begin{longtable}{ | c | c | c | c | c | c |} \hline
Num de logt : & \makecell{type de \\ financement}  &  \makecell{surface utile \\ ponderree} & taux de loyer & loyer & total charges\\ \hline
\endfirsthead

Num de logt : & \makecell{type de \\ financement}  &  \makecell{surface utile \\ ponderree} & taux de loyer & loyer & total charges\\ \hline
\endhead

\hline \multicolumn{6}{|r|}{{Continued on next page}} \\ \hline
\endfoot

\\
\endlastfoot

1054& HLM/O  & 74.00 & 4.69  &  347.361 &  64.811 \\ \hline
1054& HLM/O  & 74.00 & 4.69  &  347.361 &  64.811 \\ \hline
1054& HLM/O  & 74.00 & 4.69  &  347.361 &  64.811 \\ \hline
1054& HLM/O  & 74.00 & 4.69  &  347.361 &  64.811 \\ \hline
1054& HLM/O  & 74.00 & 4.69  &  347.361 &  64.811 \\ \hline
\end{longtable}

here an image of the result : https://drive.google.com/file/d/1h8xkPUXgC5fVSNgEAklf2C3pCLFIEK7d/view?usp=sharing

  • Welcome to TeX SX! Guilty of what? I have no problem. Did you compile twice? Also: don't use the ` center` environment with longtables: they're automatically centred. – Bernard Mar 29 '18 at 8:52
  • it works on the many page table but when it's a one page table the width bug – Jules Mar 29 '18 at 8:58
  • it works fine. you need to compile it twice. also your definition of \endlastfoot is wrong. correct is \hline \endlastfoot, not \\ \endlastfoot. – Zarko Mar 29 '18 at 9:05
  • you should get a message at the end of the document, telling you the widths have changed and to re-run latex. – David Carlisle Mar 29 '18 at 11:05
2

with your code after second compilation i obtain:

enter image description here

spurious last row is consequence of your definition of lastfoot:

\\
\endlastfoot

if you remove \\ than you will obtain

enter image description here

remember: longtable had to be compiled twice!

complete code for your table:

\documentclass{article}
\usepackage{longtable, makecell} 

\begin{document}    
\begin{longtable}{ | c | c | c | c | c | c |} \hline
Num de logt : & \makecell{type de \\ financement}  &  \makecell{surface utile \\ ponderree} & taux de loyer & loyer & total charges\\ \hline
\endfirsthead
Num de logt : & \makecell{type de \\ financement}  &  \makecell{surface utile \\ ponderree} & taux de loyer & loyer & total charges\\ \hline
\endhead
\hline
\multicolumn{6}{|r|}{{Continued on next page}} \\ 
\hline% i would omit it, it gives ugly result
\endfoot
\endlastfoot
%
1054& HLM/O  & 74.00 & 4.69  &  347.361 &  64.811 \\ \hline
1054& HLM/O  & 74.00 & 4.69  &  347.361 &  64.811 \\ \hline
1054& HLM/O  & 74.00 & 4.69  &  347.361 &  64.811 \\ \hline
1054& HLM/O  & 74.00 & 4.69  &  347.361 &  64.811 \\ \hline
1054& HLM/O  & 74.00 & 4.69  &  347.361 &  64.811 \\ \hline
\end{longtable}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.