1

I am making tables with NiceTabular environment from nicematrix package and S-type columns from siunitx package. These tables have multi-line side headings. In accordance with guidelines for tables composition numbers must be centered vertically in cells or aligned bottom (A. Wolański, Edycja Tekstów):

Adam Wolański, Edycja tekstów, PWN, p. 216 Adam Wolański, Edycja tekstów, PWN, p. 216

It is done with the use of m-type column for side heading, which was suggested by @Werner here. Moreover in the case of multiline cells in side heading it is necessary to indent all lines with exception for the first line:

enter image description here

How to modify the code to get this effect? I tried apply the solution given here, but without success. How to force the text in the m-type column to be left-justified?

Code:

\documentclass{standalone}
\usepackage{nicematrix}         % for NiceTabular environment
\usepackage{siunitx}            % for proper horizontal alignments of numbers
\usepackage{booktabs}       % for commands \toprule, \midrule, \bottomrule

\begin{document}
\begin{NiceTabular}{
    >{\setlength{\parindent}{-1em}}m{2cm}
    S[table-format=2.2]
    S[table-format=3.1]
}
    \toprule
    \multicolumn{1}{c}{First descr.} & \multicolumn{1}{c}{Second descr.} & \multicolumn{1}{c}{Third descr.}\\
    \midrule
    Long first side heading & 1.1 & 11.1\\
    Also long second side heading & 11.11 & 111.1\\
    \bottomrule
\end{NiceTabular}
\end{document}
  • 2
    >{\hangindent1em}m{2cm} – Fran Oct 14 at 20:01
3

Using @Fran comment and the answer concerning ragged right text in the cell I got:

\documentclass{standalone}
\usepackage{nicematrix}      % for NiceTabular environment
\usepackage{siunitx}         % for proper horizontal alignments of numbers
\usepackage{booktabs}        % for commands \toprule, \midrule, \bottomrule
\usepackage{ragged2e}        % for ragged right text

\begin{document}
\begin{NiceTabular}{
    >{\RaggedRight\arraybackslash\hangindent1em}m{3.5cm}
    S[table-format=2.2]
    S[table-format=3.1]
}
    \toprule
    \multicolumn{1}{c}{First descr.} & \multicolumn{1}{c}{Second descr.} & \multicolumn{1}{c}{Third descr.}\\
    \midrule
    Long text in the first side heading cell & 1.1 & 11.1\\
    Also long text in the second side heading cell & 11.11 & 111.1\\
    \bottomrule
\end{NiceTabular}
\end{document}

enter image description here

| improve this answer | |

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.