# how to use fbox in align mode

I'm trying to highlight the diagonal elements of a matrix by using fbox but I failed. I've searched for the problem, some ppl suggest using tikz. I don't want to use it, so I decided to use fbox{}. Every time I do the following

\documentclass[a4paper, 12pt]{article}
\usepackage{amsmath}
\usepackage{graphicx}
\begin{document}
\begin{align}
\begin{bmatrix}
\sigma_{xx} & \sigma_{yx}        \\
\sigma_{xy} & \fbox{\sigma_{yy}} \\
\end{bmatrix}
\end{align}
\end{document}


it throws an error !Argument of \align has an extra} if I remove \sigma_{}, it works. Any suggestions?

• Use \boxed and not \fbox – egreg Dec 8 '14 at 9:44

\fbox sets its argument in text mode, and \sigma as well as the subscript requires math mode. So, use \fbox{$\sigma_{yy}$} or the \boxed version supplied by amsmath:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$\begin{bmatrix} \boxed{\sigma_{xx}} & \sigma_{yx} \\ \sigma_{xy} & \fbox{\sigma_{yy}} \end{bmatrix}$
\end{document}


Also, there's no need for align here, and I'd rather use an equation (if you want it numbered) or $...$ if not.

• Which is exactly the same as using \boxed from amsmath, \boxed{...} = \fbox{$...$} (almost) – daleif Dec 8 '14 at 8:47
• @daleif \boxed also issues \displaystyle while \fbox{$...$} would be in \textstyle. – Skillmon Apr 16 '19 at 13:26