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.\[a=b \text{,}\]– David Carlisle May 05 '15 at 14:28\[...\]) 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. – John Wickerson May 05 '15 at 14:32\text? – David Carlisle May 05 '15 at 14:38\text{,}. You're “solving” a problem creating many others: if you try your solution with\sumin the formula and compare it with a standarddisplaymathenvironment, you'll see what I mean. – egreg May 05 '15 at 18:00$...$, and just one "block centering" environment, say\<...\>, and that {displaymath} would then be derived from a combination of these two. But I realise that this is just not how LaTeX is designed -- e.g. because of the discrepancy between\textstyleand\displaystyle, and because of the different vertical spacing around {center} vs {displaymath} -- so I will abandon my quest to force it to be so! Thanks for your comments. – John Wickerson May 06 '15 at 10:27