Why am I getting a "$ inserted" error message?

The standalone class, without the varwidth or preview option, just typesets the contents of the document environment in a single horizontal box.

If you try

\mbox{\[a_1\]}

you incur in exactly the same error, because \[ issues $$ which, in restricted horizontal mode, just typesets an empty math formula and so _ is found outside of math mode.

If you want to use standalone to get a printout of a single math formula in display style do

\documentclass[border=2pt]{standalone}

\begin{document}

$\displaystyle
  B'(1)_n = B'(0)_{n+1}
$

\end{document}

Note that the preview option will consider the formula to occupy a whole line. Compare the result with the suggested method

enter image description here

and the output of

\documentclass[border=2pt,preview]{standalone}

\begin{document}

\[
  B'(1)_n = B'(0)_{n+1}
\]

\end{document}

enter image description here


Use the preview option. For displayed math one should use the preview package. It makes no sense to crop a displayed math expression. This is the reason why standalone doesn't support display math environments with the default crop option

\documentclass[border=2pt,preview]{standalone}