3

I got the

! Missing $ inserted

mistake message when I try to use superscript inside a matrix environment in beamer. The following is my code

\begin{frame}
    \begin{pmatrix}
        \hat{\beta} \\ \hat{\beta}^{\dagger}
    \end{pmatrix}
    =
    \begin{pmatrix}
        U^\dagger & V^\dagger \\ U^\intercal & V^\intercal
    \end{pmatrix}
\end{frame}

I tried using \begin{frame}[fragile] but it didn't work.

1
  • 3
    You can't enter the pmatrix environment outside of math mode, You either need $ on each end of the pmatrix or \[...\].delimiters. Commented Apr 12, 2016 at 17:43

1 Answer 1

4

Converting my comment to an answer, LaTeX has a both text and math modes. A number of commands intended for math mode use can only be invoked inside math mode. Attempts to invoke them in text mode will receive a "missing $ inserted" error.

To enter math mode in LaTeX, one can enter inline math with dollar delimiters $...$. Many argue a preferable way to do this is with the following delimiters: \(...\). For displaystyle math, which prints its content, centered, on its own line, use the delimiters \[...\].

There are also several additional environments that will place one inside display math mode. The equation environment does this. Using the amsmath package, there is the equation* variant (that does not number the equation), and also a series of environments in the align family.

The pmatrix environment of amsmath is just such an envioronment that expects to already be in math mode, upon invocation.

\documentclass{beamer}
\usepackage{amsmath}
\begin{document}
\begin{frame}
\[
    \begin{pmatrix}
        \hat{\beta} \\ \hat{\beta}^{\dagger}
    \end{pmatrix}
    =
    \begin{pmatrix}
        U^\dagger & V^\dagger \\ U^\intercal & V^\intercal
    \end{pmatrix}
    \]
\end{frame}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .