![tabularray rowspec では、Q[f] はセルをフッターに揃えません。キャプションを削除するにはどうすればよいでしょうか?](https://rvso.com/image/456055/tabularray%20rowspec%20%E3%81%A7%E3%81%AF%E3%80%81Q%5Bf%5D%20%E3%81%AF%E3%82%BB%E3%83%AB%E3%82%92%E3%83%95%E3%83%83%E3%82%BF%E3%83%BC%E3%81%AB%E6%8F%83%E3%81%88%E3%81%BE%E3%81%9B%E3%82%93%E3%80%82%E3%82%AD%E3%83%A3%E3%83%97%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%92%E5%89%8A%E9%99%A4%E3%81%99%E3%82%8B%E3%81%AB%E3%81%AF%E3%81%A9%E3%81%86%E3%81%99%E3%82%8C%E3%81%B0%E3%82%88%E3%81%84%E3%81%A7%E3%81%97%E3%82%87%E3%81%86%E3%81%8B%3F.png)
これが私のコードです:
latex
% **************************************************
% Document Class
% **************************************************
\documentclass[
paper=A4, %
11pt, % font size
]{scrreprt}
\usepackage{tabularray}
\usepackage[svgnames]{xcolor}
\usepackage{amssymb}
\begin{document}
\NewTblrEnviron{mytblr} % define a new environment
\SetTblrOuter[mytblr]{long}
\SetTblrInner[mytblr]{ % set the default styles
colspec = {|
X[4.0cm,l]|
X[0.7cm,r]|
X[l]|
X[0.7cm,r]|
X[1.2cm,r]|
X[1.0cm,l]|},
width = 1.00\linewidth,
column{2,3,6} = {mode=dmath},
column{5} = {fg=blue},
rowspec={|
Q[h]|
Q[h]|
Q[m]|
Q[f]|
Q[f]|
Q[f]|}
}
\def\s{454}
\def\k{0.00394}
\def\treq{1.7886}
\begin{mytblr}[
caption = {},
]{
% more specs
}
Factor
& t_{req}
& {= k \times s \\ = \k \times \s \\ = \treq}
& t_{req}
& 1.78876
& \mathrm{mm} \\
\end{mytblr}
\end{document}
答え1
tabularray
はテンプレートに依存しているため、デフォルトのテンプレートを変更するか、新しいテンプレートを宣言して設定し、それをテーブルに「バインド」する必要があります。デモ用に、 というテンプレートを作成しましたnocaptemplate
。これはカスタム テーマ に適用されmytheme
、カスタム テーマは に適用されますmytblr
。
下部の配置は複数の方法で実現できますが、f
最後の 3 つの列定義に追加するとうまくいきました。
コードにエラーがあります。たとえば、4 列目に数式モードを設定せず、数式 を使用しています\t_{...}
。複数行の内容については、\\
数式環境内で を使用しようとしました。行ごとにインライン数式モードを使用し、その列の数式モードをオフにするか、複数行環境 ( など) を使用する必要があります。aligned
これがおそらく最も便利な方法です。
\newcommand
の代わりに新しいマクロを作成するには、\def...
既存のマクロを再定義しようとすると警告が表示されます。
テーブルが複数のページにまたがる場合は、複数のページにまたがるときに最初の行と最後の行をコピーするrowhead = m
および または を追加することを検討してください。rowfoot = n
m
n
% **************************************************
% Document Class
% **************************************************
\documentclass[
paper=A4, %
11pt, % font size
]{scrreprt}
\usepackage[svgnames]{xcolor}
\usepackage{tabularray}
\usepackage{amsmath,amssymb}
% Removes captions
\DeclareTblrTemplate{caption}{nocaptemplate}{}
\DeclareTblrTemplate{capcont}{nocaptemplate}{}
\NewTblrTheme{mytabletheme}{
\SetTblrTemplate{caption}{nocaptemplate}{}
\SetTblrTemplate{capcont}{nocaptemplate}{}
}
\NewTblrEnviron{mytblr} % define a new environment
\SetTblrOuter[mytblr]{
theme=mytabletheme,
long,
}
\SetTblrInner[mytblr]{ % set the default styles
width = \linewidth,
colspec = {
X[5,l] %<--- X only makes sense when using with proportions
X[1,r] %<--- Otherwise, behaves as a regular Q[...]
X[5,l]
X[1,r,f]
X[2,r,f]
X[2,l,f]
},
column{2-6} = {mode=dmath},
column{5} = {fg=blue},
hlines, vlines,
% row{1,Z} = {font=\bfseries}, %<--- the first and the last row in bold
% rowhead = 1, rowfoot = 1, %<--- would copy the first/last column on subsequent pages
}
\begin{document}
\newcommand\vars{454}
\newcommand\vark{0.00394}
\newcommand\treq{1.7886}
\begin{mytblr}{}
Factor
& t_{req}
& \begin{aligned}[t]&= k \times s\\&= \vark \times \vars\\&= \treq\end{aligned}
& t_{req}
& 1.7887
& \mathrm{mm} \\
\end{mytblr}
\end{document}
答え2
- MWE に誤りがあります。table33 を使用する場合は
rowhead = {1}
少なくとも 2 行必要です。 - テーブルは本当に長いテーブルですか?そうでない場合は、
tblr
テーブル環境に固執する方が簡単です - 表の 2 列目と 3 列目は、実際にはセルに
aligned
数式が入った 1 つの列だと思います。ただし、他の表の行が何であるかに関する情報が提供されていないため、確信はありません。
次の解決策があなたに有効かどうか確認してくださいČ
\documentclass{article}
\usepackage{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{amsmath}
\DeclareMathOperator{\req}{req}
\begin{document}
\begingroup
\DefTblrTemplate{firsthead, middlehead,lasthead}{default}{} % <---
\def\s{454}
\def\k{0.00394}
\def\treq{1.7886}
\begin{longtblr}{
rowhead = {1},
colspec = {X[0.8, l] X[1.2, c]
Q[f] Q[c, f, fg=blue] Q[f]},
column{2,3} = {mode=dmath},
row{1} = {font=\bfseries, mode=text},
hline{1,2,Z} =1pt, hline{3-Y}=solid, vlines
}
& A & B & C & D \\
Factor & \begin{aligned}[t]
t_{\req} & = k \times s \\
& = \k \times \s \\
& = \treq
\end{aligned}
& t_{\req}
& 1.78876
& mm \\
text & p_{\req} = 2\cdot\treq
& p_{\req}
& 3.57752
& mm \\
\end{longtblr}
\endgroup
\end{document}
編集:
上記MWEで作成した画像が挿入されました!