Tabularray und SetCell Thema ist als GELÖST markiert

Tabellen und Grafiken erstellen und anordnen


AaronK
Forum-Fortgeschrittener
Forum-Fortgeschrittener
Beiträge: 90
Registriert: So 2. Mai 2021, 09:29

Tabularray und SetCell

Beitrag von AaronK »

Die Überschrift in Zeile 1 wird nicht richtig dargestellt. Der Fehler scheint von SetCell zu kommen.
\documentclass{article}
\usepackage{tabularray} 
\UseTblrLibrary{booktabs}

\usepackage{siunitx}
\sisetup{detect-all}

\begin{document}

\begin{longtblr}[
    caption = {Pegeltabelle Leistung -- Spannung -- S-Meter Anzeige an 50 Ohm},
    label = {tab:pegeltabelle-leistung-spannung-s-meter-anzeige-an-50-ohm}
]{
    colspec = {rrrrrcc},
    rowhead = 2
}
\toprule
\SetCell[c=2]{c}{Leistung} & \SetCell[c=3]{c}{Spannung an \qty{50}{\ohm}} & \SetCell[c=2]{c}{S-Meter Anzeige} \\
\unit{\dB} & \unit{\watt} & $U_\mathrm{eff}$ & $U_\mathrm{ss}$ & $U_\mathrm{eff}$ & $\qty{30}{\mega\hertz}$ & $\qty{30}{\mega\hertz}$ \\
\midrule
\qty{-174}{\dB\m} & \qty{0.004e-18}{\watt} &
\qty{447}{\pico\volt} & \qty{1.26}{\nano\volt} & \qty{-67}{\volt} & & \\
\qty{-173}{\dB\m} & \qty{0.005e-18}{\watt} &
\qty{500}{\pico\volt} & \qty{1.41}{\nano\volt} & \qty{-66}{\volt} & & \\
\qty{-171}{\dB\m} & \qty{0.008e-18}{\watt} &
\qty{632}{\pico\volt} & \qty{1.79}{\nano\volt} & \qty{-64}{\volt} & & \\
\bottomrule
\end{longtblr}

\end{document}

Bartman
Forum-Meister
Forum-Meister
Beiträge: 2472
Registriert: Do 16. Jul 2009, 21:41
Wohnort: Hessische Provinz

Re: Tabularray und SetCell

Beitrag von Bartman »

Die Et-Zeichen (&) zum Trennen der Zellen müssen hier in der ersten Zeile genauso oft gesetzt werden, wie in der übrigen Tabelle.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[ngerman]{babel}
\usepackage{tabularray} 

\UseTblrLibrary{booktabs,siunitx}

\sisetup{locale=DE, detect-all}

\DeclareSIUnit{\dBm}{dBm}

\begin{document}
\begin{longtblr}[
    caption = {Pegeltabelle Leistung -- Spannung -- S-Meter Anzeige an 50 Ohm},
    label = {tab:pegeltabelle-leistung-spannung-s-meter-anzeige-an-50-ohm}
]{
    colspec = {rrrrrcc},
    rowhead = 2
}
\toprule
\SetCell[c=2]{c}{Leistung} && \SetCell[c=3]{c}{Spannung an \qty{50}{\ohm}} 
&&& \SetCell[c=2]{c}{S-Meter Anzeige} \\
\unit{\dB} & \unit{\watt} & $U_\mathrm{eff}$ & $U_\mathrm{ss}$ 
& $U_\mathrm{eff}$ & $\qty{30}{\mega\hertz}$ & $\qty{30}{\mega\hertz}$ \\
\midrule
\qty{-174}{\dBm} & \qty{0.004e-18}{\watt} &
\qty{447}{\pico\volt} & \qty{1.26}{\nano\volt} & \qty{-67}{\volt} & & \\
\qty{-173}{\dBm} & \qty{0.005e-18}{\watt} &
\qty{500}{\pico\volt} & \qty{1.41}{\nano\volt} & \qty{-66}{\volt} & & \\
\qty{-171}{\dBm} & \qty{0.008e-18}{\watt} &
\qty{632}{\pico\volt} & \qty{1.79}{\nano\volt} & \qty{-64}{\volt} & & \\
\bottomrule
\end{longtblr}
\end{document}

Jenen, denen es gestattet ist, die Tabellen gemäß den Empfehlungen von tabsatz zu gestalten, dürfte folgender Entwurf eher zusagen:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[ngerman]{babel}
\usepackage{tabularray}

\UseTblrLibrary{booktabs,siunitx}

\sisetup{locale=DE, mode=match}

\DeclareSIUnit{\dBm}{dBm}

\begin{document}
\begin{longtblr}[
    caption = {Pegeltabelle Leistung -- Spannung -- S-Meter Anzeige an \qty{50}{\ohm}},
    label = {tab:pegeltabelle-leistung-spannung-s-meter-anzeige-an-50-ohm}
]{
    colspec = {
        S[table-format=+3]
        S[table-format=1.3e2]
        S[table-format=3]
        S[table-format=1.2]
        S[table-format=+2]
        cc
    },
    rowhead = 3,
    cell{1}{1} = {c=2}{c},
    cell{1}{3} = {c=3}{c},
    cell{1}{6} = {c=2}{c},
}
\toprule
{Leistung} && {Spannung an \qty{50}{\ohm}} &&& S-Meter Anzeige &\\
\cmidrule[lr]{1-2}
\cmidrule[lr]{3-5}
\cmidrule[lr]{6-7}
&& $U_\mathrm{eff}$ & $U_\mathrm{ss}$ 
& $U_\mathrm{eff}$ & $\qty{30}{\MHz}$ & $\qty{30}{\MHz}$ \\
\unit{\dBm} & \unit{\W} & \unit{\pV} & \unit{\nV} & \unit{\V} &&\\
\midrule
-174 & 0.004e-18 & 447 & 1.26 & -67 & & \\
-173 & 0.005e-18 & 500 & 1.41 & -66 & & \\
-171 & 0.008e-18 & 632 & 1.79 & -64 & & \\
\bottomrule
\end{longtblr}
\end{document}

AaronK
Forum-Fortgeschrittener
Forum-Fortgeschrittener
Beiträge: 90
Registriert: So 2. Mai 2021, 09:29

Re: Tabularray und SetCell

Beitrag von AaronK »

Vielen Dank. Auch Lösung 2 finde ich sehr gut.

Antworten