如何在下面的 tikzpicture 中为公式 y+z 的一部分添加下划线括号?我知道underbrace
在数学模式下,但我希望括号在 之外revblock
。
\begin{tikzpicture}
[revblock/.style={shape=rectangle,draw=blue!50,fill=blue!30,
minimum height=3mm, minimum width=100mm,
text width=99mm}]
\matrix [column sep=2mm,row sep=2mm,ampersand replacement=\&]
{
\node(rev3name){$\rho_3$:}; \& \node(rev3)[revblock]{$x = y + z$};\\
};
\end{tikzpicture}
答案1
可以通过该decorations
库实现:
代码
\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
[revblock/.style={shape=rectangle,draw=blue!50,fill=blue!30,
minimum height=3mm, minimum width=100mm,
text width=99mm}]
\matrix [column sep=2mm,row sep=2mm,ampersand replacement=\&]
{
\node(rev3name){$\rho_3$:}; \& \node(rev3)[revblock]{$x = y + z$};\\ };
\draw[decoration={brace,amplitude=2mm,mirror,raise=1mm},decorate] (rev3.south west) -- (rev3.south east);
\end{tikzpicture}
\end{document}
输出
编辑1:关于您的评论,您可以使用该positioning
库:
代码
\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,calc,positioning}
\begin{document}
\begin{tikzpicture}
[revblock/.style={shape=rectangle,draw=blue!50,fill=blue!30,
minimum height=3mm, minimum width=100mm,
text width=99mm}]
\matrix [column sep=2mm,row sep=2mm,ampersand replacement=\&]
{
\node(rev3name){$\rho_3$:}; \& \node(rev3)[revblock]{$x = y + z$};\\ };
\draw[decoration={brace,amplitude=2mm,mirror,raise=1mm},decorate] (rev3.south west) -- (rev3.south east);
\node[below=5mm of rev3,draw] (textnode) {Here's some text.};
\end{tikzpicture}
\end{document}
输出
答案2
如果您想在方程式的一部分中放置另一个括号,则可以使用更通用的方法。我认为您可以使用 tikzmark 库,但这很容易做到。
我对初始代码做了一些更改:没有最小宽度,但 align=left
\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
[remember picture,
revblock/.style={shape=rectangle,draw=blue!50,fill=blue!30,
minimum height=3mm, text width=100mm,align=left },
decoration={brace,amplitude=3mm,raise=10pt,mirror}]
\matrix [column sep=2mm,row sep=2mm,ampersand replacement=\&]
{\node(rev3name){$\rho_3$:}; \& \node(rev3)[revblock]{$x=
\tikz[remember picture] \coordinate (a);
y+z \tikz[remember picture] \coordinate (b);
$}; \\
};
\draw[decorate] (rev3.south west) -- node [draw,below=7mm] {TEXT}
(rev3.south east);
\begin{scope}[ decoration={brace,amplitude=1mm,raise=6pt,mirror}]
\draw[decorate,red] (a.south west) -- node[below=6pt] {right part}
(b.south east);
\end{scope}
\end{tikzpicture}
\end{document}
答案3
您必须使用decorations
。指定brace
装饰然后绘制线段将改为绘制“指向右侧”的括号。在这里,从框的右下角开始向左下角绘制该括号将产生所需的结果(据我理解的问题):
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
[revblock/.style={shape=rectangle,draw=blue!50,fill=blue!30,
minimum height=3mm, minimum width=100mm,
text width=99mm}]
\matrix [column sep=2mm,row sep=2mm,ampersand replacement=\&]
{
\node(rev3name){$\rho_3$:}; \& \node(rev3)[revblock]{$x = y + z$};\\
};
\draw[decorate,decoration={brace,raise=2pt}] (rev3.south east) -- (rev3.south west);
\end{tikzpicture}
\end{document}