Missing dollar inserted

What is the problem with this stupid table?

\begin{table}[h]
\centering{
\begin{tabular} {l l l l l l l l}
\hline
B & F & C & P & B \lor F & P \lor C & \lnot (F \land C) & \lnot (P \land B) \\ % ERROR= missing $inserted T & T & T & T \\ \hline \end{tabular} } \end{table}  • Being math expressions, \lor etc. all need to be enclosed between $ delimiters. e.g., B & F & C & P & B $\lor$ F & P $\lor$ C & $\lnot$ (F $\land$ C) & $\lnot$ (P $\land$ B) – Steven B. Segletes Sep 24 '14 at 20:05
• @StevenB.Segletes Ahk, ok, let me try ;) – nbro Sep 24 '14 at 20:05
• You'll get further on this site by embracing, rather than disparaging the syntax. There are different fonts and different rules that apply in text vs. math mode (very importantly here, how spaces are handled). Some macros will work in either mode, but many do not. – Steven B. Segletes Sep 24 '14 at 20:09
• As you get more experience, you will find there are, almost always, good reasons why things are done the way they are done. It is rewarding when the light bulb turns on and you say, "I now see why it is done that way." – Steven B. Segletes Sep 24 '14 at 20:14
• note the whole expression is math, it should be $B \lor F$  not B $\lor$ F also \centering does not take an argument so remove the {} around the table. – David Carlisle Sep 24 '14 at 20:36

LaTeX is good at typesetting math, but it's not clairvoyant: it doesn't know you want to typeset some math formula unless you tell it so.

Several commands can be used only in math mode and raising an error upon finding them outside that mode is the best way to tell the user something's amiss.

Indeed, the first error that is raised when typesetting your code is

! Missing $inserted. <inserted text>$
l.5         B & F & C & P & B \lor
F & P \lor C & \lnot (F \land C) & \lnot ...


which exactly means that TeX found a math command in an improper place. TeX's author could have programmed it so that it uses math mode for an out of place symbol, but this would easily lead to poor typesetting.

There's a big difference between

B $\lor$ F


and

$B\lor F$


as shown in the following picture:

The main difference is the shape of the letters. Letters denoting mathematical variables have been typeset in italics for centuries and using math mode around the whole formula ensures this. Certain typographical traditions use upright type for uppercase variables, notably the French, and it's possible to set up TeX so that it follows this different style. In any case, you're guaranteed that the letters will be typeset as wished independently of the context, when found in a math formula.

Any good guide to LaTeX will tell you what are the commands that bring it in math mode; there are several, particularly if you do

\usepackage{amsmath}


so as to load a package specialized for math typesetting, which provides tens of environments and commands that solve many problems with complicated math formulas: multiline alignments, split equations, matrices, dots, whatever.

This said, what's the best way to typeset your table in which all cells should be in math mode? Easy, use math mode for the whole of it:

\begin{table}[htp] % <---- don't forget t and p
\centering
$% start math mode \begin{array} {l l l l l l l l} \hline B & F & C & P & B \lor F & P \lor C & \lnot (F \land C) & \lnot (P \land B) \\ T & T & T & T \\ \hline \end{array}$

\end{table}


Note that \centering is a declaration that doesn't take an argument: it means “for the duration of the current environment, typeset in centered fashion”.

The array environment is the math analog to tabular: it must be issued in math mode, so it's surrounded by \$ signs, and all cells will implicitly use math mode.

You might want to typeset “T” (for “true”, if I understand right your aim) in upright type, to mean it's not a variable. You can define

\newcommand{\True}{\mathrm{T}}


in the preamble and type the second line as

\True & \True & \True & \True \\


and your table would result in

Why using a long command instead of a single letter? Because it adds meaning to your input. That particular “T” is used with a very specific meaning (logical truth) that's different from any other uses of it. Better yet, if you change the definition in the preamble to

\newcommand{\True}{\top}


a single run of LaTeX will change all those T's (and only those that mean “true”) to a different symbol (that's frequently used by logicians, by the way, together with \bottom for “false”).

Defining macros for specific tasks is one of the most useful features of (La)TeX: this way your document will be as independent from a particular style as it can be; you don't hardcode a particular convention, so you remain free to change uniformly your convention if circumstances (read a picky referee or copy editor, for instance) so impose.