1

Is there a way to have my content inside my cells please ?

I've tried to "cut" the content of my second column and put it in additionnal row (i've tried makecell) so the content remains in the cell. But for my last column, the content goes beyond the cell. So why is the width of my last column not automatically increased especially when there is space to increase it and remains my content inside of my cell??!

   \documentclass{article}
    \usepackage{xcolor}
    \usepackage{tabularray}
    \usepackage{makecell}
    
    \begin{document}
    \begin{table}[htb]
    \begin{tblr}{hlines={blue}, vlines={blue},
                 colspec = {*{3}{X[l]}},
                 row{1}  = {c, font=\bfseries, fg=white, bg=blue},
                 row{even} = {bg=blue!10}
                 }
XXXXXXXX    &  \makecell{XXXXXXXXXX\\ XX}  & [email protected]\\
XXXXXXXX    &  \makecell{XXXXXXXXXX\\ XX}  &  [email protected]\\
XXXXXXXX    &  \makecell{XXXXXXXXXX\\ XX}  &  [email protected]\\
XXXXXXXX    &  \makecell{XXXXXXXXXX\\ XX} &   [email protected]\\
    \end{tblr}
    \end{table}
    \end{document}

See the render please :enter image description here

6
  • 1
    Welcome to TeX.SX! It is not clear to me what you want, but maybe setting colspec = {*{2}l X[l]} helps? Jul 26, 2022 at 10:29
  • In showed example not. If the text is longer (than column width), it will be automatically broken into several lines. Please provide more realistic table content (you can simulate it by some dummy text). So far it is not clear, what you after.
    – Zarko
    Jul 26, 2022 at 12:14
  • Please, make a more sensible example of what you're trying to achieve. In the code you show there are only unbreakable items, so using X columns is useless. And, as it stands, the natural width of the table with l columns is a bit more than 18cm.
    – egreg
    Jul 26, 2022 at 12:52
  • Is it better please ?
    – Zokulko
    Jul 26, 2022 at 14:13
  • There's space? No there isn't, that's the whole page margin.
    – user202729
    Jul 26, 2022 at 15:30

1 Answer 1

0

you should be aware, that put an elephant into lady pears is not possible :-(. So, you should be very, very careful, what to put in table and how the cell contents can eventually be broken into more lines. This we can't do for you because haven't any information about your document and its desired design.

One of possible solution can base on:

  • increasing \textwidth (with use of the geometry package)
  • decrease font size, for example to \footnotesize
  • at least in one column enable to break text into several lines

An example:

\documentclass{article}
\usepackage{geometry}

\usepackage{xcolor}
\usepackage{tabularray}

\begin{document}
    \begin{table}[htb]
    \small % \footnotesize
    \begin{tblr}{hlines={blue}, vlines={blue},
                 colspec = {l X[0.8, l] X[1.2, l]},
                 colsep=3pt,
                 row{1}  = {c, font=\bfseries, fg=white, bg=blue},
                 row{even} = {bg=blue!10}
                 }
XXXXXXXX    &  XXXXXX XXXXXXX XXXXX &   [email protected]\\
XXXXXXXX    &  XXXXXXXXX XXXXXXXXX &   [email protected]\\
XXXXXXXX    &  XXXXXXXXX XXXXXXXXX &   [email protected]\\
XXXXXXXX    &  XXXXXX XXXXXXXXXXXX &   myververyveryveryveryver[email protected]\\
    \end{tblr}
    \end{table}
\end{document}

Above MWE produce:

enter image description here

Note: For more possibilities and details about tabularray package see/read package documentation.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .