3

I have a table with really long sentences like the following

\documentclass{article}
\usepackage{nicematrix}
\usepackage{xltxtra,xunicode}
\setmainfont{DejaVu Sans}
\begin{document}
\begin{table}[htpb]
    \centering
    \caption{Two types of error in P3b.}
    \label{tab:P3b}
    \begin{NiceTabular}{c|c|c|c}
        \RowStyle{\bfseries}
        Error & \Block{1-2}{Example} & & Description and Why \\
        \hline \hline
        \Block{3-1}{Repetition} & source & Các tiêu đề gần đây trông như thế này khi Ban Điều hành Biến đổi khí hậu Liên chính phủ , gọi tắt là IPCC đưa ra bài nghiên cứu của họ về hệ thống khí quyển . & \Block{3-1}{Model tends to repeat itself.} \\ \cline{2-3}
                                & target & Recently the headlines looked like this when the <unk> Panel on Climate Change , or IPCC , put out their report on the state of understanding of the atmospheric system . &  \\ \cline{2-3}
                                & prediction & The way that the disturbing time that we \&apos;re trying to do with the fluorescence of the National <unk> , the <unk> , the <unk> , the <unk> , the <unk> of the <unk> . &  \\
        \Block{1-1}{Unable to Understand Number} & source & Trong 9 tháng đầu tiên chúng tôi cho chạy 25 câu lạc bộ dọc nước Anh , cho những nhóm trẻ em từ 5 đến 18 tuổi xem một bộ phim không bị ngắt quãng trong 90 phút . & \Block{1-1}{Model cannot understand numbers.} \\ \cline{2-3}
                                & target & In the first nine months we ran 25 clubs across the U.K. , with kids in age groups between five and 18 watching a film uninterrupted for 90 minutes . &  \\ \cline{2-3}
                                & prediction & In the first four months of <unk> Bay in New York , they were <unk> from the <unk> to the <unk> of the <unk> <unk> who was in the <unk> <unk> <unk> where the <unk> was sitting in the front page .&
    \end{NiceTabular}
\end{table}

\end{document}

enter image description here But it gives the table that is out of the page. From here it seems that nicematrix comes with an X column that is designed to solve this, but when I use

\begin{NiceTabular}{c|c|X|c}

it seems to be broken enter image description here

I wonder what might be the issue? I am guessing that there were something wrong with the second block, because when I compile the following

\begin{table}[htpb]
    \centering
    \caption{Two types of error in P3b.}
    \label{tab:P3b}
    \begin{NiceTabular}{c|c|X|c}
        \RowStyle{\bfseries}
        Error & \Block{1-2}{Example} & & Description and Why \\
        \hline \hline
        \Block{3-1}{Repetition} & source & Các tiêu đề gần đây trông như thế này khi Ban Điều hành Biến đổi khí hậu Liên chính phủ , gọi tắt là IPCC đưa ra bài nghiên cứu của họ về hệ thống khí quyển . & \Block{3-1}{Model tends to repeat itself.} \\ \cline{2-3}
                                & target & Recently the headlines looked like this when the <unk> Panel on Climate Change , or IPCC , put out their report on the state of understanding of the atmospheric system . &  \\ \cline{2-3}
                                & prediction & The way that the disturbing time that we \&apos;re trying to do with the fluorescence of the National <unk> , the <unk> , the <unk> , the <unk> , the <unk> of the <unk> . &  \\ \midrule 
% NO SECOND BLOCK!!!
    \end{NiceTabular}
\end{table}

it seems to give me the desired output. enter image description here I'm using nicematrix 2022/09/17 together with xelatex. Any help is highly appreciated!

6
  • When using NiceTabular you need to compile your document several times before the page stabilises, so this might be the problem. Please give a full minimal working example. A MWE should start with a \documentclass command, have a minimal preamble and then \begin{document}...\end{document}. it is much easier to help you if you give us close to working code to start from. Commented Oct 18, 2022 at 4:22
  • Thanks @3141592653589793238, I have included a MWE in the post. The MWE should be compiled with xelatex. Commented Oct 18, 2022 at 5:11
  • It seems that you use wrong column specifier. If you like to have that long text in some column will be automatically broken into severe lines, you should use V or X column type for this column.See page 20 -- 22 of package manual
    – Zarko
    Commented Oct 18, 2022 at 6:09
  • Hi @Zarko, thanks for the suggestion. I gave the output of X in the description and it seems that it did not work :(. I didn't know V exists but seems like something like V{3cm} also doesn't work. Commented Oct 18, 2022 at 6:47
  • Are you compile three time? Correct result appear after then.
    – Zarko
    Commented Oct 18, 2022 at 6:56

1 Answer 1

4

It is not entirely clear, what you doing. The following two examples:

  • first with NiceTabular, which require three compilation for final result, and
  • the second with tabularray package, which gives final result already after one compilation of MWE

gives result as I said im my comments:

\documentclass{article}
\usepackage{xltxtra,xunicode}
%\setmainfont{DejaVu Sans} % I haven't this font, but it not influence on table formating

\usepackage{nicematrix}

\usepackage{tabularray}

\begin{document}
\begin{table}[htpb]
    \centering
    \caption{Two types of error in P3b (NiceTabular).}
    \label{tab:P3b}
    \begin{NiceTabular}{c|c|X[3]|X}  % <---
        \RowStyle{\bfseries}
Error   & \Block{1-2}{Example} &  & Description and Why \\
        \hline \hline
\Block{3-1}{Repetition}
        & source
            & Các tiêu đề gần đây trông như thế này khi Ban Điều hành Biến đổi khí hậu Liên chính phủ , gọi tắt là IPCC đưa ra bài nghiên cứu của họ về hệ thống khí quyển .
                & \Block{3-1}{Model tends to repeat itself.}    \\
    \cline{2-3}
        & target
            & Recently the headlines looked like this when the <unk> Panel on Climate Change , or IPCC , put out their report on the state of understanding of the atmospheric system .
                &   \\
    \cline{2-3}
        & prediction
            & The way that the disturbing time that we \&apos;re trying to do with the fluorescence of the National <unk> , the <unk> , the <unk> , the <unk> , the <unk> of the <unk> .
                &  \\
    \hline
    \end{NiceTabular}
\end{table}


\begin{table}[htpb]
    \centering
    \caption{Two types of error in P3b. (tabularray)}
    \label{tab:P3b}
    \begin{tblr}{hline{2,Z}=1pt, hline{3-Y}=solid,
                 vline{2-Y},
                 colspec={l l X[3, j] X},
                 row{1}={font=\bfseries, c, m}
                  }
Error   & \SetCell[c=2]{c}  Example
            &   & Description and Why   \\
\SetCell[r=3]{l}    Repetition
        & source
            & Các tiêu đề gần đây trông như thế này khi Ban Điều hành Biến đổi khí hậu Liên chính phủ , gọi tắt là IPCC đưa ra bài nghiên cứu của họ về hệ thống khí quyển .
                & \SetCell[r=3]{l}  Model tends to repeat itself.   \\
        & target
            & Recently the headlines looked like this when the <unk> Panel on Climate Change , or IPCC , put out their report on the state of understanding of the atmospheric system .
                &   \\
        & prediction
            & The way that the disturbing time that we \&apos;re trying to do with the fluorescence of the National <unk> , the <unk> , the <unk> , the <unk> , the <unk> of the <unk> .
                &  \\
    \end{tblr}
\end{table}
\end{document}

enter image description here

2
  • Thanks!! You are right it requires multiple compilations. I was compiling multiple times with latexmk and it didn't work. But it turns out that I need to compile with actual xelatex... Do you happen to know why? Commented Oct 18, 2022 at 15:18
  • @dragon_and_dracula, for compilation I never use latexmk, in my editor (WinEdt) the engines TeX, LaTeX, pdfLaTeX, XeLaTeX, luaTeX and luaLaTeX is very simply to activate, and I liked to have manually control over number of needed compilations.
    – Zarko
    Commented Oct 18, 2022 at 15:22

You must log in to answer this question.

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