# Matrix with only $a_{i1} \neq 0$ in first column

Assume that A is square. I would like to display this as follows (for i > 1):

1. a_{i1} in its position,

2. 0 ... 0 (transposed) on top and below this element, and

3. a rectangle to the right of the first column, indicating "any element" (displaying just the rectangle; this is what it stands for), spanning most or the free apace to the right inside the matrix brackets, ideally centered vertically and horizontally.

How do I do this and make it look nice? Thanks!

Edit per comment below: I don't actually Tex. I use this within MathJax, which - in my experience - renders most Latex packages i've seen, certainly matrices. So I just need the actual display of the matrix, not whatever comes around it - or ideally an answer by someone familiar with MathJax - see http://meta.math.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference for a quick intro (but this is only a fraction of what it renders; also http://www.mathjax.org/. How do I do this and make it look nice?

• It is indeed a site for such questions but it would be great if you can include a simple minimal working example that has the initial state of the code starting from \documentclass{...} and upto \end{document}. Have a look at other questions for what exactly we mean by MWEs. This is especially needed because creating examples from scracth is really no fun. Also it avoids the comments saying thanks for the answer but I'm using babel package and your solution doesn't work with it – percusse Jan 31 '13 at 3:27
• – Peter Grill Jan 31 '13 at 3:37
• @percuße: Oh, I see. My problem is I don't tripe Latex, so am actually unfamiliar with these commands. I need this for a post on your sister site Mathematics Exchange, which uses MathJax to render Latex commands (as you probably know). So I'm a little at a loss to be helpful here. If someone replies, I will keep that model for future such questions. – gnometorule Jan 31 '13 at 3:50
• ...maybe I can copy this from another question here... – gnometorule Jan 31 '13 at 3:55
• I doubt that a TeX/LaTeX solution would work with MathJax. Sorry, but MathJax isn't LaTeX: it just interprets a subset of its syntax. – egreg Jan 31 '13 at 7:49

Ok, I tested this on the math overflow site (note the backticks):

$\begin{bmatrix}\begin{matrix} 0\\ \vdots\\ 0 \\ a_{i1} \\ 0 \\ \vdots \\ 0\end{matrix} & \bbox[84px, border: 2px solid black]{}\end{bmatrix}$


Here is the output: I have found this site to test mathjax input. Here is the output of the same code (in the meantime I have learned about the \enclose command in mathJax which could be useful (as \phantom works)): Sorry for the superfluous backticks in the image above. I could not get the \enclose to work as this is a mathjax extension which is not automatically loaded. But the following code works (sorry there is one extra row of zeros):

\begin{bmatrix}\begin{matrix} 0\\ \vdots\\ 0 \\ a_{i1} \\ 0 \\ \vdots \\ 0\end{matrix} & \bbox[border:1px solid black]{\phantom{\begin{matrix}
0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0\\\end{matrix}}}\end{bmatrix}


Output: Actually I just see on this official mathjax site that \fbox works with MathJax v2.1. I tried it works, and in fact even the amsmath \boxed is available:

\begin{bmatrix}\begin{matrix} 0\\ \vdots\\ 0 \\ a_{i1} \\ 0 \\ \vdots \\ 0\end{matrix} & \boxed{\phantom{\begin{matrix}
0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0\\\end{matrix}}}\end{bmatrix} Oh, I left some \mathstrut inside. Anyway, I think this is enough.

Here's a way, but I doubt it can work with MathJax.

\documentclass{article}
\usepackage{amsmath}

\newsavebox{\firstcolbox}

\begin{document}
$\sbox\firstcolbox{\displaystyle \begin{matrix}0\\\vdots\\0\\a_{i1}\\0\\\vdots\\0\end{matrix}} \begin{bmatrix} \usebox\firstcolbox & \!\!\! \fbox{\rule[-.9\dp\firstcolbox]{0pt}{.9\dimexpr\ht\firstcolbox+\dp\firstcolbox}% \hspace{6\wd\firstcolbox}} \,\,\, \end{bmatrix}$
\end{document} • That is almost exactly what I meant. Nice job. From doing more research I agree I doubt there is a MathJax solution. – gnometorule Jan 31 '13 at 16:27