我必须使用相同的表格设置来装箱。两个问题:
(1)灰度背景的宽度不同。
(2)无法通过 添加多行方程\begin{align*}
。(错误:
\begin{align}
仅允许在段落中使用。)
我需要两个不同的\SetTblrInner[mytblr]
and吗\SetTblrInner[mytblr2]
?下面是上述错误的示例:
\documentclass{scrartcl}
\usepackage[margin=1.0cm]{geometry}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{tikz}
\usetikzlibrary{angles,
positioning,
quotes,
shapes.geometric,
}
\tikzset{baseline=(current bounding box.center),
my angle/.style = {draw, font=\small,
angle eccentricity=1.55, angle radius=3mm},
base/.style = {draw, thick},
dashline/.style = {densely dashed, thick},
every edge quotes/.style = {auto=right, inner sep=1pt, font=\small},
Rect/.style args = {#1/#2}{base, minimum height=#1, minimum width=#2},
Trap/.style args = {#1/#2}{base, trapezium,
trapezium left angle=#1, trapezium right angle=#2,
minimum width=30mm}
}
\usepackage{tcolorbox}
\tcbset{fonttitle=\bfseries, coltitle=white, colback=white,
colframe=black,nobeforeafter,sharp corners,
sidebyside, sidebyside gap=3mm,
lower separated=false
}
\usepackage{sfmath}
\usepackage{tabularray}
\usepackage{amsmath}
\NewTblrEnviron{mytblr} % <--- added by @Jasper Habicht
\SetTblrInner[mytblr]{
hline{1,2,Z} = 1pt, vline{1,Z} = 1pt,
hline{even[3-X]} = {dashed, fg=gray, 0.5pt},
colspec = {Q[l, bg=gray!10, font=\small\bfseries]
X[c, bg=gray!10]
Q[c, wd=33mm]},
colsep = 3pt,
cell{1}{1} = {c=3}{l},
cell{odd[3]}{1} = {c=2}{c, fg=black, mode=math},
row{1} = {bg=gray!30, mode=text},
row{2-Z}= {belowsep=4pt},
row{odd[3-Z]} = {ht = 19mm}
}
\begin{document}
\noindent
\begin{tcolorbox}[title = Title]
\begin{mytblr}{}
Square & & \\
Area & & \\
\begin{align*}
A&=a\cdot a\\
& = a^{2}
\end{align*}&=a\cdot a a^2 & &
\tikz{\node (a) [Rect=14mm/14mm] {};
\path (a.south west) to["a"] (a.south east)
(a.south east) to["a"] (a.north east);
} \\
Circumference & & \\
u=4\cdot a & &
\tikz{\node (a) [Rect=14mm/14mm] {};
\path (a.south west) to["a"] (a.south east)
(a.south east) to["a"] (a.north east);
} \\
\end{mytblr}
\medskip
\begin{mytblr}{}
Pythagorean Theorem & & \\
\textnormal{In any right-angled\\
triangle it holds that} & & \\
a^{2}+b^{2}=c^{2} & &
\tikz{[very thick]
\draw (-1.5,0)coordinate[](A)
--(1.2,0)coordinate[](B)
--(-1.5,1.2)coordinate[](C)
--cycle;
% rechte Winkel
\pic[draw,fill=gray!10,fill opacity=0.5,angle radius=4mm,"$\pmb{\cdot}$" opacity=1]
{angle=B--A--C};
% Streckenbezeichnungen
\path (A) -- node [midway,below] {\scriptsize b} (B);
\path (A) -- node [midway,left] {\scriptsize a} (C);
\path (B) -- node [midway,above] {\scriptsize c} (C);} \\
\end{mytblr}
\end{tcolorbox}
\end{document}
答案1
像这样?
您的代码中有三个错误:
- 而不是
align*
你应该使用aligned
- 对于“勾股定理”中的两行文本,您应该删除
\textnormal
花括号前的命令(参见下面的 MWE) - 之后的虚假数学代码
align*
(删除它!)
无关:对于右上角的标记,我将使用:
- 对于形状边框的标记,你应该使用我在 ma 答案中绘制图像时使用的方法,然后你在“正方形”部分复制
- 我要添加的角度样式
tikzset
(您可以根据自己的意愿更改样式名称)
\documentclass{scrartcl}
\usepackage[margin=1.0cm]{geometry}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{tikz}
\usetikzlibrary{angles,
positioning,
quotes,
shapes.geometric,
}
\tikzset{baseline=(current bounding box.center),
my angle/.style = {draw, font=\small,
angle eccentricity=1.55, angle radius=3mm},
base/.style = {draw, thick},
dashline/.style = {densely dashed, thick},
every edge quotes/.style = {auto=right, inner sep=1pt, font=\small},
Rect/.style args = {#1/#2}{base, minimum height=#1, minimum width=#2},
Trap/.style args = {#1/#2}{base, trapezium,
trapezium left angle=#1, trapezium right angle=#2,
minimum width=30mm},
ANG/.style = {draw, fill=gray!10, angle radius=4mm,
angle eccentricity=#1},
}
\usepackage{tcolorbox}
\tcbset{fonttitle=\bfseries, coltitle=white, colback=white,
colframe=black,nobeforeafter,sharp corners,
sidebyside, sidebyside gap=3mm,
lower separated=false
}
\usepackage{sfmath}
\usepackage{tabularray}
\usepackage{amsmath}
\NewTblrEnviron{mytblr} % <--- added by @Jasper Habicht
\SetTblrInner[mytblr]{
hline{1,2,Z} = 1pt, vline{1,Z} = 1pt,
hline{even[3-X]} = {dashed, fg=gray, 0.5pt},
colspec = {Q[l, bg=gray!10, font=\small\bfseries]
X[c, bg=gray!10]
Q[c, wd=33mm]},
colsep = 3pt,
cell{1}{1} = {c=3}{l},
cell{odd[3]}{1} = {c=2}{c, fg=black, mode=math},
row{1} = {bg=gray!30, mode=text},
row{2-Z}= {belowsep=4pt},
row{odd[3-Z]} = {ht = 19mm}
}
\begin{document}
\noindent
\begin{tcolorbox}[title = Title]
\begin{mytblr}{}
Square & & \\
Area & & \\
\begin{aligned}
A&=a\cdot a\\
& = a^{2}
\end{aligned} & &
\tikz{\node (a) [Rect=14mm/14mm] {};
\path (a.south west) to["a"] (a.south east)
(a.south east) to["a"] (a.north east);
} \\
Circumference & & \\
u=4\cdot a & &
\tikz{\node (a) [Rect=14mm/14mm] {};
\path (a.south west) to["a"] (a.south east)
(a.south east) to["a"] (a.north east);
} \\
\end{mytblr}
\medskip
\begin{mytblr}{}
Pythagorean Theorem & & \\
{In any right-angled\\
triangle it holds that} & & \\
a^{2}+b^{2}=c^{2} & &
\tikz{[very thick]
\draw (0,0)coordinate[](A)
-- (3,0)coordinate[](B)
-- (0,1.5)coordinate[](C)
-- cycle;
% rechte Winkel
\pic[ANG=0.5, "$\pmb{\cdot}$"] {right angle=B--A--C};
% Streckenbezeichnungen
\path (A) edge ["$b$"] (B)
(B) edge ["$c$"] (C)
(C) edge ["$a$"] (A);
} \\
\end{mytblr}
\end{tcolorbox}
\end{document}