# nodes in matrix and its incorporation into document

i continue with my previous post (here) concerning various additions to matrix. I have following problem: how to add nodes into matrix and this whole matrix incorporate into the document ?

my trial follows here:

\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}


with following output. I've tried to add nodes based on (this answer), but without success:

My second question is how to incorporate it into the document, since matrix P, which follows after that, is not centered as usual. And if i add some matrix instead of P, it is not centered as well.

 $\begin{bmatrix} wn_{1} \\[0.3em] wn_{2} \end{bmatrix}$

-

I don't know if I understand your question right. But there are several errors in your code. There are missing coordinates such as (a) and (b). I commented the last code in your tikzpicture environment to make your code compilable.

\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 package throws error when I compile but uncommenting it seems to work. The should be closed by and and \begin{bmatrix}..\end{bmatrix} should be placed inside the equation environment. But $<code>$ should not be used here.

Here is the modified 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}  Looking at the given link, if you want to put the figure in an equation environment, then that's okay too. But you have to define the whole figure with respect to the (m) as done by percusse in his answer. Otherwise, the solution will not work. Perhaps, what you are after is \[ \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}$


Edit

As requested, here is the code for the braces.

\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}

-
thank you. do you know please how to add there that node n_s ? it might help me with the answer even for this question - link –  jiri jansa Oct 26 '12 at 15:10

Maybe something along the following could be of help:

\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}


-
thank you for help, i will use it if i dont find solution in the enviroment i have used –  jiri jansa Oct 26 '12 at 15:21
@jiri: What do you mean by "environment"? –  morbusg Oct 27 '12 at 3:08