## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ Longtable : Cell jumps current page and exceeds the page after Topic is solved

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

Hello guys

I'm a beginner and I'm using Overleaf for making a CV

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 :

\documentclass{article}\usepackage[utf8]{inputenc}\usepackage{longtable}\usepackage{lipsum} \begin{document}     \begin{longtable}[c]{| c | p{5cm} |}        \hline         2019 - 2020 & Test        \hline        2019 - 2020 & \lipsum        \hline         2019 - 2020 & Test        \hline     \end{longtable}\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).

Thank you very much for helping me

Ijon Tichy
Posts: 269
Joined: Mon Dec 24, 2018 10:12 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.
\documentclass{article}\usepackage[utf8]{inputenc}% not needed since LaTeX 2018-04-01\usepackage{lipsum}\usepackage{scrextend}% provides labeling environment \begin{document} \begin{labeling}{2019--2020}% the argument is a length pattern\item[2019--2020] Test\item[2019--2020] \lipsum\item[2019--2020] Test\end{labeling}\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:
\documentclass{article}\usepackage{xltabular}% combination of longtable and tabularx\usepackage{lipsum} \begin{document} \begin{xltabular}{\linewidth}{|c|X|}% combination of longtable and tabularx    \hline     2019--2020 & Test \\    \hline    2019--2020 & \lipsum[1-4] \\% splitted to allow page break               & \lipsum[5-7] \\% continue    2019--2020 & Test \\    \hline \end{xltabular}\end{document}

Akexandre
Posts: 9
Joined: Thu Mar 26, 2020 3:31 am
Thank you very much for responding so quickly

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
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 ?

\begin{labeling}{2019--2020}\end{labeling} \begin{labeling}{2019}\end{labeling} \begin{labeling}{2019 - 2018 - 2020}\end{labeling}

to have something like this :
$variable = 3cm (or a define ?) \begin{labeling}{$variable}\end{labeling} \begin{labeling}{$variable}\end{labeling}\begin{labeling}{$variable}\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

Ijon Tichy
Posts: 269
Joined: Mon Dec 24, 2018 10:12 am
You can use \newenvironment{cv}{\labeling{2019--2020}}{\endlabeling} in your document preamble and then use
\begin{cv}\item[2018] …\item[2019--2020]…\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
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