LaTeX forum ⇒ Graphics, Figures & TablesLongtable : Cell jumps current page and exceeds the page after

Information and discussion about graphics, figures & tables in LaTeX documents.
Akexandre
Posts: 9
Joined: Thu Mar 26, 2020 3:31 am

Longtable : Cell jumps current page and exceeds the page after

Postby Akexandre » Thu Mar 26, 2020 4:15 am

Hello guys

I'm a beginner and I'm using Overleaf for making a CV 8-)

Here my issue :
I want something like an array with Column left date and Colomn right the related tasks (and over things inside like List / custom parbox / etc : so containt is really big).

It appears by using this approach, the column left is nicely sized but if the right cell has a bad behaviorand disappearsby exceeding the page from bottom.

Here the code to better explain with lipsum to fill in with big amount of data :

Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \documentclass{article}
  2. \usepackage[utf8]{inputenc}
  3. \usepackage{longtable}
  4. \usepackage{lipsum}
  5.  
  6. \begin{document}
  7.  
  8. \begin{longtable}[c]{| c | p{5cm} |}
  9. \hline
  10. 2019 - 2020 & Test
  11. \hline
  12. 2019 - 2020 & \lipsum
  13. \hline
  14. 2019 - 2020 & Test
  15. \hline
  16. \end{longtable}
  17. \end{document}


This is simple but I do not find after hours and hours comparing 150 different CV how to solve this (even if it's possible). :shock:

I'm opened to any idea about this issue or if you have a better design to suggest, I would be happy to better understand and improve my comprehension about this.

Thank you very much for helping me :)

User avatar
Ijon Tichy
Posts: 233
Joined: Mon Dec 24, 2018 10:12 am

Postby Ijon Tichy » Thu Mar 26, 2020 9:19 am

Your example is not working, because of the missing \\ or \tabularnewline at the end of the table rows. However, I don't think, that this is your main problem. You main problem is, that longtable does not provide page breaks inside a table cell but only after table rows. If you really need page breaks everywhere, you can use a list instead of a table. Lists provide page breaks almost everywhere. But lists do not provide vertical rules/lines. However you should always avoid vertical rules, because they decline the readability.
Code: [Select all] [Expand/Collapse] [Download] (labelingexample.tex)
  1. \documentclass{article}
  2. \usepackage[utf8]{inputenc}% not needed since LaTeX 2018-04-01
  3. \usepackage{lipsum}
  4. \usepackage{scrextend}% provides labeling environment
  5.  
  6. \begin{document}
  7.  
  8. \begin{labeling}{2019--2020}% the argument is a length pattern
  9. \item[2019--2020] Test
  10. \item[2019--2020] \lipsum
  11. \item[2019--2020] Test
  12. \end{labeling}
  13. \end{document}

If you really need the ugly boxed layout, you have to do the page breaks manually by splitting the related table cell to two table rows:
Code: [Select all] [Expand/Collapse] [Download] (manualsplittingexample.tex)
  1. \documentclass{article}
  2. \usepackage{xltabular}% combination of longtable and tabularx
  3. \usepackage{lipsum}
  4.  
  5. \begin{document}
  6.  
  7. \begin{xltabular}{\linewidth}{|c|X|}% combination of longtable and tabularx
  8. \hline
  9. 2019--2020 & Test \\
  10. \hline
  11. 2019--2020 & \lipsum[1-4] \\% splitted to allow page break
  12. & \lipsum[5-7] \\% continue
  13. 2019--2020 & Test \\
  14. \hline
  15. \end{xltabular}
  16. \end{document}

Akexandre
Posts: 9
Joined: Thu Mar 26, 2020 3:31 am

Postby Akexandre » Thu Mar 26, 2020 2:55 pm

Thank you very much for responding so quickly :shock:

I like the first approach and It sounds to fit the expected layout I'm looking for ;)

So I'm going to play with labelling and scrextend

Have a very good day and take care of you (especially during this period)

Akexandre
Posts: 9
Joined: Thu Mar 26, 2020 3:31 am

Postby Akexandre » Thu Mar 26, 2020 8:05 pm

Hello

May I ask you a quick question related to the useful example you provide ? (with labeling)
I'm going to use it mutlitple time but I would like to have the same size on multiple instance

Here my question : do we have something like variable where I can set a size and I'll use it each time ?

Instead of this :
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \begin{labeling}{2019--2020}
  2. \end{labeling}
  3.  
  4. \begin{labeling}{2019}
  5. \end{labeling}
  6.  
  7. \begin{labeling}{2019 - 2018 - 2020}
  8. \end{labeling}


to have something like this :
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. $variable = 3cm (or a define ?)
  2.  
  3. \begin{labeling}{$variable}
  4. \end{labeling}
  5.  
  6. \begin{labeling}{$variable}
  7. \end{labeling}
  8. \begin{labeling}{$variable}
  9. \end{labeling}


It will align the 3 labeling with the same size (if not possible, I'll take the longest text). But I would like to know best practise, that's why I'm asking you help ;)

Thank you for helping me :)

User avatar
Ijon Tichy
Posts: 233
Joined: Mon Dec 24, 2018 10:12 am

Postby Ijon Tichy » Thu Mar 26, 2020 8:33 pm

You can use \newenvironment{cv}{\labeling{2019--2020}}{\endlabeling} in your document preamble and then use
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \begin{cv}
  2. \item[2018] …
  3. \item[2019--2020]…
  4. \end{cv}

One of the advantages of LaTeX is, that you can define your own commands and enviroments using already existing commands and environment (or the commands, that are used to begin and end existing environment). And it is recommended to do so to improve the separation of form and content. Whenever you need code more than once, it is a good idea to ask yourself: Is is a good idea to define a command or environment for this.

Hint: To set a width of 3cm you can use \hspace{3cm} as pattern. But this will not give exactly 3cm, because the label separation will be added additionally.

BTW: There are other package, that can be used to define a new type of list, e.g., enumitem, Using scrextend's labeling environment was only a easy and quick suggestion.

Akexandre
Posts: 9
Joined: Thu Mar 26, 2020 3:31 am

Postby Akexandre » Sun Mar 29, 2020 12:58 am

Hello Ijon Tichy

This is absolutely perfect. The example you gave to me cover exactly the expected result and your additional information gaves me opportunity to reach the next level of my CV (with newenv).

I would like to thank you for your help

Have a very good evening :)


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 3 guests