0

Hi there I am trying align the "2403 Y" to the top of the 4 connected rows and not in the middle of the 4 connected rows.

\begin{longtblr}[
    caption = {Ergebnisse der Gitterschnittprüfung der bei $40^{\circ}C$ gehärteten Proben PUA 2403 X, -Y und -Z},
    label = {tblr:GT 40 grad},
    ]
{width=\linewidth,colspec={X[1,c]|X[1,c]|X[1,c]|X[1,c]|X[1,c]|X[1,c]|X[1,c]|X[1,c]}}
\hline
 \textbf{PUA Nr.} & \textbf{Substrat} & \textbf{Blech Nr.} & \textbf{GT Nr. 1} & \textbf{GT Nr. 2} & \textbf{GT Nr. 3} & \textbf{Mittelwert} & \textbf{Stabw. S}\\
\hline
\SetCell[r=4]{c} \rotatebox[origin=c]{90}{2403 X}& Oxsilan & 4 & 0 & 0 & 0 & 0 & 0\\\hline
&Fe Phosphatiert & 5 & 0 & 0 & 0 & 0 & 0 \\\hline
&Zn Phosphatiert & 1 & 0 & 0 & 0 & 0 & 0 \\\hline
&Gestrahltes Aluminium & 1 & 0 & 0 & 0 & 0 & 0 \\
\hline
\SetCell[r=4]{c} \rotatebox[origin=c]{90}{2403 Y}& Oxsilan & 3 & 0 & 0 & 0 & 0 & 0\\\hline
&Fe Phosphatiert & 4 & 0 & 0 & 0 & 0 & 0 \\\hline
&Zn Phosphatiert & 2 & 0 & 0 & 0 & 0 & 0 \\\hline
&Gestrahltes Aluminium & 1 & 0 & 0 & 0 & 0 & 0 \\
\hline
\SetCell[r=4]{c} \rotatebox[origin=c]{90}{2403 Z}& Oxsilan & 1 & 0 & 0 & 0 & 0 & 0\\\hline
&Fe Phosphatiert & 4 & 0 & 0 & 0 & 0 & 0 \\\hline
&Zn Phosphatiert & 2 & 0 & 0 & 0 & 0 & 0 \\\hline
&Gestrahltes Aluminium & 1 & 0 & 0 & 0 & 0 & 0 \\
\hline
\end{longtblr}

Ty for any help

Zarko
  • 296,517
Abibo
  • 55

2 Answers2

1

Please, next time, give a MWE (starts with \documentclass and ends with \end{document}

The key is cell{6}{1} = {r=4,c=1}{h,cmd=\rotatebox{90}},

I made a few changes:

  • colspec={X[1,c]|X[1,c]|X[1,c]|X[1,c]|X[1,c]|X[1,c]|X[1,c]|X[1,c] by colspec={*{8}{X[c]}},
  • vline{1} = {1-Z}{0pt} and vline{9} = {1-Z}{0pt} for special cases
  • Setcells with the new \cell interface
  • for non-centered alignment, replace with f or h
  • EDIT: caption in bold

The code

\documentclass{article}
%https://tex.stackexchange.com/questions/690054/top-alignment-of-setcell-command
\usepackage[margin=1cm]{geometry}
\usepackage{tabularray}
\usepackage{adjustbox}
\usepackage{caption}
\begin{document}

\SetTblrStyle{caption-tag}{font=\bfseries}%<<< edit

\begin{longtblr}[ caption = {Ergebnisse der Gitterschnittprüfung der bei $40^{\circ}C$ gehärteten Proben PUA 2403 X, -Y und -Z}, label = {tblr:GT 40 grad}, ] { width=\linewidth, colspec={*{8}{X[c,m]}}, hlines,vlines, % vline{1} = {1-Z}{0pt}, % vline{9} = {1-Z}{0pt}, vline{1,9} = {1-Z}{0pt},%<-- in one line row{1}={font=\bfseries}, % cell{2}{1} = {r=4,c=1}{c,cmd=\rotatebox{90}}, cell{6}{1} = {r=4,c=1}{h,cmd=\rotatebox{90}}, % cell{10}{1} = {r=4,c=1}{c,cmd=\rotatebox{90}}, cell{2,10}{1} = {r=4,c=1}{c,cmd=\rotatebox{90}},%<-- in one line } % PUA Nr. & Substrat & Blech Nr. & GT Nr. 1 & GT Nr. 2 & GT Nr. 3 & Mittelwert & Stabw. S\ % 2403 X& Oxsilan & 4 & 0 & 0 & 0 & 0 & 0\% &Fe Phosphatiert & 5 & 0 & 0 & 0 & 0 & 0 \% &Zn Phosphatiert & 1 & 0 & 0 & 0 & 0 & 0 \% &Gestrahltes Aluminium & 1 & 0 & 0 & 0 & 0 & 0 \ % 2403 Y& Oxsilan & 3 & 0 & 0 & 0 & 0 & 0\% &Fe Phosphatiert & 4 & 0 & 0 & 0 & 0 & 0 \% &Zn Phosphatiert & 2 & 0 & 0 & 0 & 0 & 0 \% &Gestrahltes Aluminium & 1 & 0 & 0 & 0 & 0 & 0 \ % 2403 Z& Oxsilan & 1 & 0 & 0 & 0 & 0 & 0\% &Fe Phosphatiert & 4 & 0 & 0 & 0 & 0 & 0 \% &Zn Phosphatiert & 2 & 0 & 0 & 0 & 0 & 0 \% &Gestrahltes Aluminium & 1 & 0 & 0 & 0 & 0 & 0 \ % \end{longtblr}

\end{document}

enter image description here

pascal974
  • 4,652
  • Thank you very very much. Next time ill create a MWE. Can i ask you maybe one more thing. how can the "Table 1: " be in bold? – Abibo Jul 01 '23 at 14:13
  • With this post https://tex.stackexchange.com/questions/258098/how-do-i-change-the-style-of-a-longtable-caption? – pascal974 Jul 01 '23 at 14:23
  • didnt work i tried both \captionsetup[longtblr]{labelfont=bf} and \captionsetup[longtable]{labelfont=bf} – Abibo Jul 01 '23 at 14:31
  • with this post https://tex.stackexchange.com/questions/669041/bold-caption-tag-in-tabularray-table, I add it – pascal974 Jul 02 '23 at 13:15
0

I would write your table on the following way:

\documentclass{article}
\usepackage{geometry}

\usepackage{rotating} \usepackage{makecell} \renewcommand\theadfont{} \usepackage{tabularray} \UseTblrLibrary{siunitx} \SetTblrStyle{caption-tag}{font=\small\bfseries} \SetTblrStyle{caption-text}{font=\small}

\begin{document} \begin{talltblr}[ caption = {Ergebnisse der Gitterschnittprüfung der bei \qty{40}{\degreeCelsius} gehärteten Proben PUA 2403 X, -Y und -Z}, label = {tblr:GT 40 grad}, ]{hlines, vlines, colspec = {X[0.5, c,m] X[1.2, c,m] *{6}{X[c,m]} }, colsep = 3pt, cell{2,10}{1} = {r=4}{cmd=\settowidth\rotheadsize{2403 X}\rothead}, cell{6}{1} = {r=4}{cmd=\settowidth\rotheadsize{2403 X}\rothead, h}, row{1} = {font=\small\bfseries}, } PUA Nr. & Substrat & Blech Nr. & GT Nr. 1 & GT Nr. 2 & GT Nr. 3 & Mittelwert & Stabw. S \ 2403 X & Oxsilan & 4 & 0 & 0 & 0 & 0 & 0 \ & Fe Phosphatiert
& 5 & 0 & 0 & 0 & 0 & 0 \ & Zn Phosphatiert
& 1 & 0 & 0 & 0 & 0 & 0 \ & Gestrahltes Aluminium & 1 & 0 & 0 & 0 & 0 & 0 \ 2403 Y & Oxsilan & 3 & 0 & 0 & 0 & 0 & 0 \ & Fe Phosphatiert & 4 & 0 & 0 & 0 & 0 & 0 \ & Zn Phosphatiert & 2 & 0 & 0 & 0 & 0 & 0 \ & Gestrahltes Aluminium & 1 & 0 & 0 & 0 & 0 & 0 \ 2403 Z & Oxsilan & 1 & 0 & 0 & 0 & 0 & 0 \ & Fe Phosphatiert & 4 & 0 & 0 & 0 & 0 & 0 \ & Zn Phosphatiert & 2 & 0 & 0 & 0 & 0 & 0 \ & Gestrahltes Aluminium & 1 & 0 & 0 & 0 & 0 & 0 \ \end{talltblr} \end{document}

Main differences to your code snippet are:

  • for table is used talltblr table (since it is not evident that this table spans more pages)
  • last six columns have equal width, the first and second column width fare narrower and wider respectively
  • for rotate cell content are used rotating and makecell package

enter image description here

Unfortunately your page layout is unknown. In the case, that your table should be narrower, for example with width of default text block width of the article document class, that you should change MWE and \talltblr preamble to:

\documentclass{article}
%\usepackage{geometry}

\usepackage{rotating} \usepackage{makecell} \renewcommand\theadfont{} \usepackage{tabularray} \UseTblrLibrary{siunitx} \SetTblrStyle{caption-tag}{font=\small\bfseries} \SetTblrStyle{caption-text}{font=\small}

\begin{document} \begin{talltblr}[ caption = {Ergebnisse der Gitterschnittprüfung der bei \qty{40}{\degreeCelsius} gehärteten Proben PUA 2403 X, -Y und -Z}, label = {tblr:GT 40 grad}, ]{hlines, vlines, colspec = {X[0.7, c,m] X[1.7, c,m] *{6}{X[c,m, cmd=\hspace{0pt}]} }, colsep = 3pt, cell{2,10}{1} = {r=4}{cmd=\settowidth\rotheadsize{2403 X}\rothead}, cell{6}{1} = {r=4}{cmd=\settowidth\rotheadsize{2403 X}\rothead, h}, row{1} = {font=\small\bfseries}, }

and resulted table will be:

enter image description here

BTW, desired change of your table design make it (according to my opinion) ugly.

Zarko
  • 296,517