6

Yesterday, I posted question concerning solid diagonal line within matrix. But my problem continues, since I am supposed to add into the matrix even the vertical line and labels. Is there a way how to add nodes for matrix built by pmatrix enviroment (all similar problems I have met so far contained some other way of building matrix)? Is there any way how to improve the vertical line (for example to touch the diagonal line)? And how to add second horizontal line?

\documentclass{article}
\usepackage{amsmath}
\usepackage{easybmat}
\usepackage{ifthen}
\usepackage{tikz}
\begin{document}
\newcommand\tikzmark[1]{%
\tikz[overlay,remember picture,baseline] \node [anchor=base] (#1) {};}

\newcommand\MyLine[3][]{%
\begin{tikzpicture}[overlay,remember picture]
\draw[#1] (#2.north west) -- (#3.south east);
\end{tikzpicture}}

\[
\begin{pmatrix}
\phantom{0}\tikzmark{a} & & & & &  & \phantom{0}\tikzmark{p} R_{12}\\
& & & R_{11} & & &\\
& & & & & &\\
& & & & & & \\ 
& & & & & &\tikzmark{q}\phantom{0} $R_{22}$ \\
& & & & & & \tikzmark{b}\phantom{0}\\\hline
\\
\\
\multicolumn{5}{c}{\text{\huge 0}} \\
\\
\end{pmatrix}\qquad
\MyLine[ultra thick]{a}{b}
\MyLine[ultra thick]{p}{q}
\]
\end{document}

matrix to be drawn
matrix i have so far

by running suggested code, i have obtained following errors: mistake from Texnic center mistake from Texnic center III

1 Answers1

8

Personal opinion: \...dots or similar graphical tips directional symbols were suggestive tools back in the day, to... ehm... suggest a pattern for the reader to understand better where nothing else was around with tabular, Excel-like structures. They work OK in rows and columns where the entries are relatively comparable in width and height (As far as I can see the diagonal dots usually look ugly but still depending on the context).

But if you decide to use TikZ or any other graphical tool for such cases, trying still to mimic the old style is quite a waste of resources and also pretty ugly. Because those \...dots are(were) actually trying hard to mimic the tools that you are using now in the absence of them. So once you switch to the dark side with math objects blended into graphics, you need to go all the way until you can justify those extra bits. Otherwise don't bother, just partition your matrix and you are done without TikZ.


Here is an example:

\documentclass{article}
\usepackage{tikz,amsmath}
\usetikzlibrary{matrix,fit,calc,decorations.pathreplacing}

\begin{document}
After obtaining the observable canonical form for state space system given by $\dot{x} = Ax, y=Cx$, suddenly we 
draw a completely irrelevant figure in an equation

\[
\begin{pmatrix}
C\\
CA\\
CA^2\\
\vdots\\
CA^{n-1}
\end{pmatrix} = \qquad 
\begin{tikzpicture}[baseline=(m.center)]
\node[minimum height=5cm,minimum width=3cm] (m) {};
\pgfmathsetmacro\mytempvar{3*sqrt(2)}
\draw[ultra thin,fill=gray!10] (m.north west) -- ++(-45:\mytempvar cm) coordinate (b) |- (m.north west) --cycle;
\draw[ultra thin] (m.north west) |- (m.south east) -- (b) |- ++(135:1cm) coordinate (a) -- (m.north -| a);
\node [fit=(m.north west) (m.south east),left delimiter=(,right delimiter=)] {};
\node (r11) at ([yshift=-0.7cm]m.north) {$R_{11}$};
\node[anchor=center] (r12) at ({$(a)!0.5!(b)$} |- r11) {$R_{12}$};
\draw[-latex] (a) ++ (1.5cm,1cm) node[anchor=south] {$R_{22}$}to[bend left] ++(-1cm,-1.2cm);
\draw[ultra thin, loosely dashed] (a) -- (m.west |- a) (b) -- (m.west |- b);
\draw[decorate,decoration={brace,raise=6mm}] (m.west |- b) -- (m.west |- a) node[midway,sloped,yshift=1cm] {$n$};
\draw[decorate,decoration={brace,raise=6mm}] (m.south west)-- (m.west |- b) node[midway,sloped,yshift=1cm] {$n_{obsv}$};
\node (bigzero) at ([yshift=1cm]m.south) {\Huge $0$};
\end{tikzpicture}
\]
\end{document}

enter image description here

percusse
  • 157,807
  • i am false newcomer to Latex, so it is hard for me to imagine all possible ways. Thank you for your help. I have trouble with the output from the code you've sent - i have added that to your answer or here link , is there download of some package or library needed ? – jiri jansa Oct 25 '12 at 16:10
  • @jirijansa What error do you get? – percusse Oct 25 '12 at 16:21
  • 2
    @percusse: +1 just for the text portion. :-) – Peter Grill Oct 25 '12 at 16:22
  • @percusse my error with visualization is on the second picture in your answer or to be seen here, there is this text in Texnic center: "Package pgf error. No shape b is known." – jiri jansa Oct 25 '12 at 17:42
  • @jirijansa Resulting document means nothing if the compilation resulted with errors. It should not lead to errors if you directly copied. Can you copy and paste my code into an empty document with the extra command \listfiles just before \begin{document}. In the resulting log file look for the version of tikz.sty it should be at least 2.10 You can also edit your question to provide more data. – percusse Oct 25 '12 at 18:21
  • @percusse tikz.sty is 2010/10/13 v2.10 (rcs-revision 1.76), i have added some of my errors to my question – jiri jansa Oct 25 '12 at 18:46