I often find myself doing things like
\[
\begin{tabular}{cc}
foo & bar \\
baz & qux
\end{tabular}
\]
or
\[
\begin{verbatim}
code snippet
\end{verbatim}
\]
to put a table or code snippet into my document without making it float. I'm using \[...\]
because I like the way it centres its contents and leaves a little vspace above and below it. But of course \[...\]
also puts me in math-mode, which is not what I want.
What's the equivalent of \[...\]
that doesn't put me into math-mode?
In fact (if I may delve into 'opinion-based' territory for a moment), I am of the opinion that \[...\]
should not enter into math-mode at all. Consider something like:
Finally, our equation becomes
\[
x^2 = y^2 - z^2,
\]
which is easily proved.
I often want to include a comma (or a full-stop, or whatever) with the equation, in order to make it flow with the rest of the surrounding text. But the comma should not be typeset in math-mode, because it is not a mathematical comma, it is a textual comma. So what I really want to type is:
Finally, our equation becomes
\begin{some-suitable-environment}
$x^2 = y^2 - z^2$,
\end{some-suitable-environment}
which is easily proved.
so that I can delimit the piece of the centred text that is actually math. Is this a sensible suggestion? Does some-suitable-environment
exist?
\[\begin{verbatim}
produces! Missing $ inserted. <inserted text> $ l.5 \begin{verbatim}
\[a=b \text{,}\]
\[...\]
) and back to text-mode (with\text{...}
). In other words, I would prefer the document markup to emphasise that the comma is not part of the equation.\text
?\text{,}
. You're “solving” a problem creating many others: if you try your solution with\sum
in the formula and compare it with a standarddisplaymath
environment, you'll see what I mean.