我继续我之前的帖子(这里) 关于矩阵的各种添加。我有以下问题:如何将节点添加到矩阵中,并将整个矩阵合并到文档中?
我的任务是以下输出:
我的试验如下:
\documentclass{article}
\usepackage{easybmat}
\usepackage{ifthen}
\usepackage{tikz,amsmath}
\usetikzlibrary{matrix,fit,calc,decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}[baseline=(m.center)]
\node[minimum height=0cm,minimum width=0cm] (m) {};
\path[shade,draw] (0,2) -- (0,5) -- (3,5) -- (3,0);
\draw (0,0) --(0,5);
\draw (3,0) --(0,2);
\draw (3,0) --(3,5);
\draw[ultra thin, loosely dashed] (a) -- (m.west |- a) (b) -- (m.west |- b);
\end{tikzpicture}
*P
\end{document}
输出如下。我尝试添加基于(这个答案),但没有成功:
我的第二个问题是如何将其合并到文档中,因为紧随其后的矩阵 P 不像往常那样居中。如果我添加一些矩阵来代替 P,它也不会居中。
\[
\begin{bmatrix}
\begin{equation}
wn_{1} \\[0.3em]
wn_{2}
\end{bmatrix}
\]
答案1
我不知道我是否理解了你的问题。但是你的代码中有几个错误。缺少坐标,例如(a)
和(b)
。我在你的环境中注释了最后一段代码,tikzpicture
以使你的代码可编译。
\documentclass{article}
%\usepackage{easybmat}
%\usepackage{ifthen}
\usepackage{tikz,amsmath}
\usetikzlibrary{matrix,fit,calc,decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}[baseline=(m.center)]
\node[minimum height=0cm,minimum width=0cm] (m) {};
\path[shade,draw] (0,2) -- (0,5) -- (3,5) -- (3,0);
\draw (0,0) --(0,5);
\draw (3,0) --(0,2);
\draw (3,0) --(3,5) node [midway,right] {\color{red}*P}; % Place the node at right of the middle of the path. You can also use pos=0.5 in place of midway.
%\draw[ultra thin, loosely dashed] (a) -- (m.west |- a) (b) -- (m.west |- b);
\end{tikzpicture}
*P
\end{document}
easybmat
编译时包会抛出错误,但取消注释似乎有效。\begin{equation}
应该用和关闭,\end{equation}
并且\begin{bmatrix}..\end{bmatrix}
应该放在equation
环境内。但\[<code>\]
不应在这里使用。
这是修改后的代码。
\documentclass{article}
%\usepackage{easybmat}
\usepackage{ifthen}
\usepackage{tikz,amsmath}
\usetikzlibrary{matrix,fit,calc,decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}[baseline=(m.center)]
\node[minimum height=0cm,minimum width=0cm] (m) {};
\path[shade,draw] (0,2) -- (0,5) -- (3,5) -- (3,0);
\draw (0,0) --(0,5);
\draw (3,0) --(0,2);
\draw (3,0) --(3,5) node [midway,right] {
$\begin{bmatrix}
wn_{1} \\[0.3em]
wn_{2}
\end{bmatrix}$
}; % Place the node at right of the middle of the path
%\draw[ultra thin, loosely dashed] (a) -- (m.west |- a) (b) -- (m.west |- b);
\end{tikzpicture}
*P
\end{document}
查看给定的链接,如果你想将图形放在方程环境中,那也是可以的。但你必须根据(m)
percusse 在他的答案中所做的那样定义整个图形。否则,解决方案将不起作用。也许,你想要的是
\[
\begin{tikzpicture}[baseline={(3,2.5)}]
\node[minimum height=0cm,minimum width=0cm] (m) {};
\path[shade,draw] (0,2) -- (0,5) -- (3,5) -- (3,0);
\draw (0,0) --(0,5);
\draw (3,0) --(0,2);
\draw (3,0) --(3,5); % Place the node at right of the middle of the path
%\draw[ultra thin, loosely dashed] (a) -- (m.west |- a) (b) -- (m.west |- b);
\end{tikzpicture}
\begin{bmatrix}
wn_{1} \\[0.3em]
wn_{2}
\end{bmatrix}
\]
编辑
根据要求,这是大括号的代码。
\documentclass{article}
%\usepackage{easybmat}
\usepackage{ifthen}
\usepackage{tikz,amsmath}
\usetikzlibrary{matrix,fit,calc,decorations.pathreplacing}
\usepackage{amsmath}
\begin{document}
\[
\begin{tikzpicture}[baseline={(3,2.5)}]
\node[minimum height=0cm,minimum width=0cm] (m) {};
\path[shade,draw] (0,2) -- (0,5) -- (3,5) -- (3,0);
\draw (0,0) --(0,5);
\draw (3,0) --(0,2);
\draw (3,0) --(3,5); % Place the node at right of the middle of the path
%\draw [ultra thin, loosely dashed] (a) -- (m.west |- a) (b) -- (m.west |- b);
\draw [decorate,decoration=brace,xshift=-2pt] (0,0)
-- (0,2) node[midway,left] {$\scriptstyle n_s$};
\draw [dashed] (0,0) -- (3,0);
\end{tikzpicture}
\begin{bmatrix}
wn_{1} \\[0.3em]
wn_{2}
\end{bmatrix}
\]
\end{document}
答案2
也许下面的内容可能会有所帮助:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{patterns,decorations.pathreplacing}
\tikzset{
thingy/.style={draw,rectangle,minimum width=1.3em,minimum height=5ex}}
\begin{document}
\[
= \mathop{\vcenter{\hbox{\tikzpicture
\node[thingy] (a) {};
\fill[pattern=north east lines] (a.180) -- (a.north west)
-- (a.north east) -- (a.south east) -- cycle;
\filldraw ([xshift=.2pt]a.180) circle (.4pt) -- ([xshift=-.2pt,yshift=.2pt]%
% FIXME: need to back up half the width of the default line width.
a.south east);
\draw[decorate,decoration=brace] ([xshift=-2pt]a.south west)
-- ([xshift=-2pt]a.180) node[below left] {$\scriptstyle n_s$};
% FIXME: shifting makes me feel dirty
\endtikzpicture}}} \cdot P
\]
\end{document}