我想定制 Tabularray“mytheme”以获得更多异常输入选项。
- 简化的评论多列输入和
- 对于长方程式,请填写第 3 列,以保持垂直对齐
默认情况下,我想要一条(1)垂直线,其右侧显示结果和评论。
这是我迄今为止的代码。
% **************************************************
% 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[2,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\vart{3}
\newcommand\vars{454}
\newcommand\varp{4.54}
\newcommand\vark{0.00394}
\newcommand\varw{7.04}
\newcommand\vara{1.5}
\newcommand\varf{1.7886}
\newcommand\treq{2.94}
\begin{mytblr}{}
Factor
& f
& \begin{aligned}[t]&= k \times s\\&= \vark \times \vars\\&= \treq\end{aligned}
& f=
& \varf
& \mathrm{mm} \\ [1em]
\SetCell[r=2]{l}
Required thickness
& \SetCell[r=2]{c} t_{req}
& \SetCell[r=2]{c}
\begin{aligned}[t]
&= k \times s \times \sqrt{\frac{p}{w}}+{a} \\
& = \vark \times \vars \times \sqrt{\frac{\varp}{\varw}}+{\vara} \\
&= \treq\end{aligned}
& \SetCell[c=3]{l}
{\begin{tabular}[t]{@{}l}
{[1]~{Chapter 11.1} \\
$t_{req}<t$; OK} \\
\end{tabular}} \\
&
&
& t_{req}=
& \treq
& \mathrm{mm} \\
\end{mytblr}
\end{document}
答案1
您的代码包含错误,无法编译 - 我会重新定义您的列规范(您的代码可能是大多数错误的来源)
在编写表格时,您应该考虑我对您上一个问题的回答(对我来说,它提供了更好的结果,但一切都取决于您)
无论如何,请遵循以下内容:
\documentclass[
paper=A4, %
11pt, % font size
]{scrreprt}
\usepackage[svgnames]{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{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[l,h]
Q[r,h, mode=math]
X[3,l, mode=math]
Q[r,f, mode=math]@{\;}
Q[l,f, fg=blue]
Q[l,f, mode=math]
},
vline{3}=1pt,
rowsep=7pt
}
\begin{document}
\newcommand\vart{3}
\newcommand\vars{454}
\newcommand\varp{4.54}
\newcommand\vark{0.00394}
\newcommand\varw{7.04}
\newcommand\vara{1.5}
\newcommand\varf{1.7886}
\newcommand\treq{2.94}
\begin{mytblr}{}
Factor
& f
& \begin{aligned}[t]
& = k \times s\\
& = \vark \times \vars\\
& = \treq
\end{aligned}
& f=
& \varf
& \mathrm{mm} \\
Required thickness
& \SetCell[r=2]{c} t_{req}
& \SetCell[r=2]{c}
\begin{aligned}[t]
& = k \times s \times \sqrt{\frac{p}{w}}+{a} \\
& = \vark \times \vars \times \sqrt{\frac{\varp}{\varw}}+{\vara} \\
& = \treq
\end{aligned}
& \SetCell[c=3]{l, mode=text} {[1] Chapter 11.1\\
$t_{req}<t$; OK}
&
& \\
%%
&
&
& t_{req}=
& \treq
& \mathrm{mm} \\
\end{mytblr}
\end{document}
附录:
- 根据我对您的回答上一个问题并更正
\NewTblrTheme{mytabletheme}
)。 - 编辑:表格是使用
multlined
环境的一个例子(带有它们的行有灰色背景)。
\documentclass[paper=A4, 11pt]{scrreprt}
\usepackage{lipsum}
\usepackage[svgnames]{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{amsmath,amssymb}
\usepackage{mathtools} % <--- added
\DeclareMathOperator{\req}{req} % <--- added
%---------------------------------------------------------------%
% Removes captions
\NewTblrTheme{mytabletheme}
{
\DefTblrTemplate{firsthead, middlehead,lasthead,
%firstfoot, middlefoot,lastfoot
}{default}{}%
}
% define a new environment
\NewTblrEnviron{mytblr}
\SetTblrOuter[mytblr]{theme=mytabletheme,long}
\SetTblrInner[mytblr]% set the default styles
{
width = \linewidth,
colspec = {
X[l,h]
X[3,l,h, mode=math]
Q[r,f, mode=math]@{\;}
Q[l,f, fg=blue]
Q[l,f, mode=math]
},
vline{3}=1pt,
rowsep=5pt
}
%---------------------------------------------------------------%
\begin{document}
\newcommand\vart{3}
\newcommand\vars{454}
\newcommand\varp{4.54}
\newcommand\vark{0.00394}
\newcommand\varw{7.04}
\newcommand\vara{1.5}
\newcommand\varf{1.7886}
\newcommand\treq{2.94}
\begin{mytblr}{}
Factor
& \begin{aligned}[t]
f & = k \times s\\
& = \vark \times \vars\\
&= \treq
\end{aligned}
& f=
& \varf
& \mathrm{mm} \\
Required thickness
& \SetCell[r=2]{l}
\begin{aligned}[t]
t_{req} & = k \times s \times \sqrt{\frac{p}{w}}+{a} \\
& = \vark \times \vars \times \sqrt{\frac{\varp}{\varw}}+{\vara} \\
& = \treq
\end{aligned}
& \SetCell[c=3]{l, mode=text} {[1] Chapter 11.1\\
$t_{req}<t$; OK}
&
& \\
%%
&
& t_{req}=
& \treq
& \mathrm{mm} \\
%%%%
Factor
& \begin{aligned}[t]
f & = k \times s\\
& = \vark \times \vars\\
&= \treq
\end{aligned}
& f=
& \varf
& \mathrm{mm} \\
Required thickness
& \SetCell[r=2]{l}
\begin{aligned}[t]
t_{req} & = k \times s \times \sqrt{\frac{p}{w}}+{a} \\
& = \vark \times \vars \times \sqrt{\frac{\varp}{\varw}}+{\vara} \\
& = \treq
\end{aligned}
& \SetCell[c=3]{l, mode=text} {[1] Chapter 11.1\\
$t_{req}<t$; OK}
&
& \\
%%
&
& t_{req}=
& \treq
& \mathrm{mm} \\
Factor
& \begin{aligned}[t]
f & = k \times s\\
& = \vark \times \vars\\
&= \treq
\end{aligned}
& f=
& \varf
& \mathrm{mm} \\
%%%
\SetRow{bg=gray!10}
use of multlined
& \begin{multlined}[t]
p(x) = 3x^6 + 14x^5y + 590x^4y^2 + 19x^3y^3\\
- 12x^2y^4 - 12xy^5 + 2y^6 - a^3b^3
\end{multlined}
& t_{req}=
& \treq
& \mathrm{mm} \\
%%%
Required thickness
& \SetCell[r=2]{l}
\begin{aligned}[t]
t_{\req} & = k \times s \times \sqrt{\frac{p}{w}}+{a} \\
& = \vark \times \vars \times \sqrt{\frac{\varp}{\varw}}+{\vara} \\
& = \treq
\end{aligned}
& \SetCell[c=3]{l, mode=text} {[1] Chapter 11.1\\
$t_{\req}<t$; OK}
&
& \\
%%
&
& t_{\req}=
& \treq
& \mathrm{mm} \\
\SetRow{bg=gray!10}
use of multlined
& \begin{multlined}[t]
p(x) = 3x^6 + 14x^5y + 590x^4y^2 + 19x^3y^3\\
- 12x^2y^4 - 12xy^5 + 2y^6 - a^3b^3
\end{multlined}
& t_{req}=
& \treq
& \mathrm{mm} \\
Factor
& \begin{aligned}[t]
f & = k \times s\\
& = \vark \times \vars\\
&= \treq
\end{aligned}
& f=
& \varf
& \mathrm{mm} \\
Required thickness
& \SetCell[r=2]{l}
\begin{aligned}[t]
t_{\req} & = k \times s \times \sqrt{\frac{p}{w}}+{a} \\
& = \vark \times \vars \times \sqrt{\frac{\varp}{\varw}}+{\vara} \\
& = \treq
\end{aligned}
& \SetCell[c=3]{l, mode=text} {[1] Chapter 11.1\\
$t_{\req}<t$; OK}
&
& \\
%%
&
& t_{\req}=
& \treq
& \mathrm{mm} \\
\end{mytblr}
\lipsum[1]
\end{document}
以上 MWE 生成了两页长的表格。第一页底部是注释下页继续(如所期望的那样?)