1

I would like to draw simple table without borders but the problem the the content of the second column exceeds the margins of document How can I fix that problem

enter image description here

\documentclass{article}
\usepackage{tabularx} 

\begin{document}
    \begin{tabular}{cl}
    Year 2023-2024 & Very long very long text Very long very long text Very long very long text  \\
    Year 2022-2023 & Very long very long text Very long very long text Very long very long text \\
    Year 2021-2022 & Very long very long text Very long very long text Very long   \\
    Year 2020-2021 & Very long very long text Very long very long text Very long very long text  \\
    Year 2019-2020 & Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text  \\
    Year 2018-2019 & Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text  \\
    \end{tabular}
\end{document}
  • 2
    Just replace l by p{8cm} or whatever length instead of 8cm. Of course there are packages which compute the remaining distance for you like tabularx and so on. – marmot May 6 '18 at 21:17
  • It's works just fine – Educ May 6 '18 at 21:19
  • @marmot you can turn your comment into solution – Educ May 6 '18 at 21:21
5

Use tabularx and the X column type. This should be fine:

\begin{tabularx}{\linewidth}{c>{\arraybackslash}X}
Year 2023-2024 & Very long very long text Very long very long text Very long very long text  \\
Year 2022-2023 & Very long very long text Very long very long text Very long very long text \\
Year 2021-2022 & Very long very long text Very long very long text Very long   \\
Year 2020-2021 & Very long very long text Very long very long text Very long very long text  \\
Year 2019-2020 & Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text  \\
Year 2018-2019 & Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text  \\
\end{tabularx}
  • 1
    Could you please add possibility to add border in case if we need it to the same table – Educ May 6 '18 at 21:23
  • @Bernard - I guess you don't need \arraybackslash here, please correct me if I'm missing something obvious. – AboAmmar May 6 '18 at 21:58
  • @AboAmmar: You're probably right (I don't know well the details). I always add it just in case… I don't think it does any harm: it's just to ensure `\\` for a new row has no problem. – Bernard May 6 '18 at 22:12

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.