我欢迎使用带有破折号或点号的括号的bmatrix
和pmatrix
环境版本。下面是 MWE。我发现另一个问题这解释了如何绘制虚线花括号,但我想要一个除了虚线图案之外bmatrix
,其他所有方面都表现得像pmatrix
虚线图案的环境。我该如何实现呢?我猜 bmatrix 比 pmatrix 容易得多。
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\begin{bmatrix}
0 & 1 \\ 2& 3
\end{bmatrix}
\end{equation}
I want the brackets of this matrix dashed or densely dotted.
\end{document}
答案1
请参阅下面的详细答案。
这是dBmatrix
和dpmatrix
环境,使用来自所引用问题和environ
包的代码。我的tikz
是原始的,所以我仍在尝试弄清楚如何获得括号装饰。
\documentclass{article}
\usepackage{tikz,amsmath,environ}
\usetikzlibrary{decorations.pathreplacing,calligraphy}
\NewEnviron{dBmatrix}{\setbox0=\hbox{$\,\begin{matrix}\BODY\end{matrix}\,$}%
\setbox2=\hbox{\begin{tikzpicture}
\draw [dashed, thick, decorate, decoration={brace, amplitude=5pt}] (0,\botdim)--(0,\topdim);
\copy0
\draw [dashed, thick, decorate, decoration={brace, amplitude=5pt}] (0,\topdim)--(0,\botdim);
\end{tikzpicture}}
\vcenter{\hbox{\copy2}}}
\NewEnviron{dpmatrix}{\setbox0=\hbox{$\,\begin{matrix}\BODY\end{matrix}\,$}%
\setbox2=\hbox{\begin{tikzpicture}
\draw [dashed, thick, decorate, decoration={calligraphic straight parenthesis, amplitude=1pt}] (0,\botdim)--(0,\topdim);
\copy0
\draw [dashed, thick, decorate, decoration={calligraphic straight parenthesis, amplitude=1pt}] (0,\topdim)--(0,\botdim);
\end{tikzpicture}}
\vcenter{\hbox{\copy2}}}
\def\topdim{\dimexpr+\ht0+.5\ht\strutbox-.5\dp\strutbox-3pt\relax}
\def\botdim{\dimexpr-\ht0+.5\ht\strutbox-.5\dp\strutbox+3pt\relax}
\begin{document}
\[
\begin{Bmatrix}
0 & 1 \\ 2& 3
\end{Bmatrix}%
\quad
\begin{dBmatrix}
0 & 1 \\ 2& 3
\end{dBmatrix}
\]
\[
\begin{pmatrix}
0 & 1 \\ 2& 3\\4 & 5
\end{pmatrix}%
\quad
\begin{dpmatrix}
0 & 1 \\ 2& 3\\4& 5
\end{dpmatrix}
\]
\end{document}
运用 Peter Grill 的回答在 tikz 中绘制圆形/矩形括号环绕节点允许定义圆括号以及方括号修饰。因此,这里的外观与上面的略有不同。所以这里dpmatrix
是从上面的重新定义并dbmatrix
引入的。
\documentclass{article}
\usepackage{tikz,amsmath,environ}
\usetikzlibrary{decorations.pathreplacing,calligraphy,calc}
\tikzset{
ncbar angle/.initial=90,
ncbar/.style={
to path=(\tikztostart)
-- ($(\tikztostart)!#1!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztotarget)$)
-- ($(\tikztotarget)!($(\tikztostart)!#1!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztotarget)$)!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztostart)$)
-- (\tikztotarget)
},
ncbar/.default=0.5cm,
}
\tikzset{square left brace/.style={ncbar=0.5ex}}
\tikzset{square right brace/.style={ncbar=-0.5ex}}
\tikzset{round left paren/.style={ncbar=0.3cm,out=115,in=-115}}
\tikzset{round right paren/.style={ncbar=0.3cm,out=65,in=-65}}
%
\NewEnviron{dBmatrix}{\setbox0=\hbox{$\,\begin{matrix}\BODY\end{matrix}\,$}%
\setbox2=\hbox{\begin{tikzpicture}
\draw [dashed, thick, decorate, decoration={brace, amplitude=5pt}] (0,\botdim)--(0,\topdim);
\copy0
\draw [dashed, thick, decorate, decoration={brace, amplitude=5pt}] (0,\topdim)--(0,\botdim);
\end{tikzpicture}}
\vcenter{\hbox{\copy2}}%
}
\NewEnviron{dpmatrix}{\setbox0=\hbox{$\,\begin{matrix}\BODY\end{matrix}\,$}%
\setbox2=\hbox{\begin{tikzpicture}
\draw [dashed, thick] (0,\botdim) to [round left paren] (0,\topdim);
\copy0
\draw [dashed, thick] (0,\botdim) to [round right paren] (0,\topdim);
\end{tikzpicture}}
\vcenter{\hbox{\copy2}}%
}
\NewEnviron{dbmatrix}{\setbox0=\hbox{$\,\begin{matrix}\BODY\end{matrix}\,$}%
\setbox2=\hbox{\begin{tikzpicture}
\draw [dashed, thick] (0,\botdim) to [square left brace] (0,\topdim);
\copy0
\draw [dashed, thick] (0,\botdim) to [square right brace] (0,\topdim);
\end{tikzpicture}}
\vcenter{\hbox{\copy2}}%
}
\def\topdim{\the\dimexpr+\ht0+.5\ht\strutbox-.5\dp\strutbox-3pt\relax}
\def\botdim{\the\dimexpr-\ht0+.5\ht\strutbox-.5\dp\strutbox+3pt\relax}
\begin{document}
\[
\begin{Bmatrix}
0 & 1 \\ 2& 3
\end{Bmatrix}%
\quad
\begin{dBmatrix}
0 & 1 \\ 2& 3
\end{dBmatrix}
\]
\[
\begin{pmatrix}
0 & 1 \\ 2& 3\\4 & 5
\end{pmatrix}%
\quad
\begin{dpmatrix}
0 & 1 \\ 2& 3\\4& 5
\end{dpmatrix}
\]
\[
\begin{bmatrix}
0 & 1 \\ 2& 3
\end{bmatrix}%
\quad
\begin{dbmatrix}
0 & 1 \\ 2& 3
\end{dbmatrix}
\]
\end{document}