4

How to correct insert an image in some X cell that its width is determined by cell widths?

\documentclass{article}
\usepackage{geometry}
\usepackage[export]{adjustbox}
\usepackage{tabularray}

\setlength\parindent{0pt}

\begin{document}
case 1:
    \begin{center}
    \adjustboxset{height=0.15\textwidth,  % determined by trial
                  keepaspectratio,
                  valign=M}
\begin{tblr}{hlines, vlines,
             colspec={X[0.6,l,m] *{3}{X[1,c,m]}},
             rowsep=4pt,
             }
some description of images
    &   \adjincludegraphics{example-image-duck}
        &   \adjincludegraphics{example-image-duck} 
            &   \adjincludegraphics{example-image-duck} \\
\end{tblr}
    \end{center}
case 2:
    \begin{center}
    \adjustboxset{width=\linewidth,
                  keepaspectratio,
                  valign=M}
\begin{tblr}{hlines, vlines,
             colspec={X[0.6,l,m] *{3}{X[1,c,m]}},
             rowsep=4pt,
             }
some description of images
    &   \adjincludegraphics{example-image-duck}
        &   \adjincludegraphics{example-image-duck}
            &   \adjincludegraphics{example-image-duck} \\
\end{tblr}
    \end{center}
\end{document}

In the first case the result is as desired, but in the second case are inserted huge space above and below images. The writing table as shown in the first case (where are explicit determined height of image by guessing) is quite annoying, so the second case (where is width of images defined by width of columns) is preferable way to write of table, but result is terrible. I would like that in the second case the result of MWE is the same as it is at the first case.

So the question is, why at the second case code doesn't gives the same result as at the first case

If in the second case one use tabularx table, such problem doesn't arise, even more in such a case for nice result some small vertical space should be added. I expect, that similar situation will happen at tabularray too.

Do I miss something at tabularray settings or this is bug or it does not yet have this property?

enter image description here

3
  • So, you want to remove the excessive vertical space? Because the widths of all 4 columns seem to be identical in both tables ... // Ok, you wrote it. Suggestion: Why don't you move the paragraph, at least its question, upfront? Also the title doesn't seem to reflect your question. May be adjust the title, too?
    – MS-SPO
    Aug 22, 2021 at 18:47
  • @MS-SPO, I rewrite my question in big hope, that it is now more clear.
    – Zarko
    Aug 22, 2021 at 19:32
  • @MS-SPO, I change question's title accordingly (as suggested by tabularray package author in github.com/lvjr/tabularray/issues/80.
    – Zarko
    Aug 23, 2021 at 0:56

1 Answer 1

3

See https://github.com/lvjr/tabularray/issues/80

When at first we meaure cell widths, \linewidth is equal to \textwidth. But when later we typeset cells with \parbox, \linewidth is equal to the computed column width. These differences cause the problem. The solution is to reset @row-height after adjusting widths for X columns.

This bug has been fixed. You may download the latest package file from

https://github.com/lvjr/tabularray/raw/main/tabularray.sty

or wait for the next version 2021N scheduled on September 1st.

enter image description here

5
  • Dear L.J.R, thank you very much for answer. Unfortunately, tabularray style in given link doesn't reproduce showed result in your answer. So, I will wait to new official style version and than accept your answer (I already upvote it).
    – Zarko
    Aug 23, 2021 at 1:00
  • Maybe you were saving the flie as tabularray.sty.txt; should save it as tabularray.sty.
    – L.J.R.
    Aug 23, 2021 at 1:06
  • Nope, I overwrite existing .sty file with file in given link (yes, I know that this has not been very smart ...). Short overview of it I didn't observe any difference (except file header) from existed version 2021M (2021-08-01).
    – Zarko
    Aug 23, 2021 at 1:23
  • Strange. I tried it again in my computer and it worked well.
    – L.J.R.
    Aug 23, 2021 at 1:29
  • Sorry, my big mistake. I overwrite wrong .style file :-( ! Now I correct my mismatch and compilation of my test file works as you advertise :-). Thank you very much and receive my deep regret for my false alarms. I really enjoy with your package (and seem that I steel need to learn much about it)
    – Zarko
    Aug 23, 2021 at 1:47

You must log in to answer this question.

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