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.

This question already has an answer here:

I want to draw :
enter image description here

I have tried to make this by the following command :

\documentclass[11pt,twoside,openright]{book}
\usepackage{geometry,tikz,amsmath}



\begin{document}

$$J_5=\left(\begin{array}{ccc} \lambda & 1 & 0\\ 0 & \lambda & 0\\ 0 & 0 & \frame{$\lambda$} \end{array}\right)
$$

\end{document}

But this gives :
enter image description here
How can I do so ?

share|improve this question
    
Since the "what you want" picture is not there, I can only guess. Do you want a \fbox instead of a \frame –  Steven B. Segletes Apr 26 '13 at 16:10
    
I want to make the matrix shown in the first picture.How can I use \fbox.Plese give an example with array. –  Md Kutubuddin Sardar Apr 26 '13 at 16:12
1  
Sorry to bother you, but I just noticed that even though you have up-voted answers, you still haven't accepted any of the answers to your questions (up-voting and accepting are two different actions). Please consider revisiting your questions and accepting, for each of them, the answer that you consider best solved your problem. In case of doubt, please see How do you accept an answer?. –  Gonzalo Medina Apr 26 '13 at 16:23
    
FYI: tex.stackexchange.com/questions/40028/… –  Papiro Apr 26 '13 at 16:31
    
I had in mind literally replacing the \frame with a \fbox. That will frame a single entry with a border that frame did not provide, but is not directly usable when multi-element blocks of the array are to be framed. –  Steven B. Segletes Apr 26 '13 at 16:33
show 1 more comment

marked as duplicate by Werner, diabonas, Claudio Fiandrino, mafp, Marco Daniel Apr 26 '13 at 18:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers

up vote 6 down vote accepted

Since you are loading tikz, I assume a tikz solution is fine.

It makes use of two tikz libraries: matrix for the matrix (the syntax is very close to the usual syntax for tabulars, arrays or matrices, with a lot of optional parameters to tweak the final output), and fit to draw rectangles around sets of nodes.

\documentclass[11pt,twoside,openright]{book}
\usepackage{geometry,tikz,amsmath}

\usetikzlibrary{fit,matrix}

\begin{document}

\begin{equation*}
  J_{5}=
  \tikz[baseline=(M.west)]{%
    \node[matrix of math nodes,matrix anchor=west,left delimiter=(,right delimiter=),ampersand replacement=\&] (M) {%
      \lambda \& 1 \& 0 \\
      0 \& \lambda \& 0 \\
      0 \& 0 \& \lambda \\
    };
    \node[draw,fit=(M-1-1)(M-2-2),inner sep=-1pt] {};
    \node[draw,fit=(M-3-3),inner sep=-1pt] {};
  }
\end{equation*}

\end{document}

enter image description here

share|improve this answer
add comment

A TikZ-free possibility:

\documentclass[11pt,twoside,openright]{book}
\usepackage{amsmath}

\begin{document}

\[
J_5=
\left(
\begin{array}{|cc|c@{}c|} 
\cline{1-2}
\lambda & 1 & & \multicolumn{1}{c}{0} \\
0 & \multicolumn{1}{c|}{\lambda} & & \multicolumn{1}{c}{0} \\
\cline{1-2}\cline{4-4}
\multicolumn{1}{c}{0} & \multicolumn{1}{c}{0} & & \multicolumn{1}{|c|}{\lambda} \\
\cline{4-4}
\end{array}
\right)
\]

\end{document}

enter image description here

share|improve this answer
    
+1 for a solution that doesn't require too many packages and that should work on any latex install. The drawbacks appear when you notice that you have accidentally swapped the big and small rectangles, though. ;) –  T. Verron Apr 26 '13 at 16:24
    
@T.Verron hehe! Fixed. –  Gonzalo Medina Apr 26 '13 at 16:31
add comment

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