Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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 task is following output:

demanded output

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 output so far

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}
 \begin{equation}
   wn_{1}           \\[0.3em]
   wn_{2}    
 \end{bmatrix}
 \]
share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

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}

enter image description here

easybmat package throws error when I compile but uncommenting it seems to work. The \begin{equation} should be closed by and \end{equation} 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}

enter image description here

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

enter image description here

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}
share|improve this answer
    
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
add comment

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}

enter image description here

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.