1

I have a little problem with nested arrays.

The following examples give the correct matrix after a Latex=>PDF run but generate LaTeX errors ! missing $ inserted. <inserted text>, that I would like to get rid of.

Any idea about the problem?

First Example:

\begin{equation}
g_{22}=\left[\begin{array}{ccc}\fbox{\begin{array}{ccc}\frac{1}{E-E_1^1} & & \\ & \ddots & \\ & & \frac{1}{E-E_1^N}\end{array}} & & \\ & \ddots & \\ & &  \fbox{\begin{array}{ccc} \frac{1}{E-E_n^1} & & \\ & \ddots & \\ & & \frac{1}{E-E_n^N}\end{array}}\end{array}\right]
\end{equation}

Second example:

\begin{equation}
    H=\left[\begin{array}{cc}H_{N-n}&\begin{array}{cl}B\qquad & 0 \end{array}\\ \begin{array}{c}B^{\dag}\\ 0 \end{array} & \fbox{\begin{array}{cc}H_{n}&\quad S\\S^{\dag}&\quad\hsub\end{array}}\end{array}\right]
\end{equation}
doncherry
  • 54,637

1 Answers1

2

The problem goes away if the contents of the \fbox is typeset in the mathmode.

\documentclass{article}
\begin{document}
\begin{equation}
g_{22}=\left[
\begin{array}{ccc}
\fbox{$
\begin{array}{ccc}
\frac{1}{E-E_1^1} & & \\ 
& \ddots & \\ 
& & \frac{1}{E-E_1^N}
\end{array}$} & & \\ 
& \ddots & \\ 
& &  \fbox{$
           \begin{array}{ccc} 
           \frac{1}{E-E_n^1} & & \\
            & \ddots & \\ 
            & & \frac{1}{E-E_n^N}
           \end{array}$}
\end{array}\right]
\end{equation}
\end{document}

enter image description here

One can also make use of the answers given in Highlight elements in the matrix

percusse
  • 157,807