Table - Extra alignment tab has been changed to \cr

In addition to inserting the missing \\ line break instruction, you should contemplate undertaking the following steps:

  • Implement fully the suggestions @egreg made with regard to your earlier posting, inluding the use of array instead of tabular and the use of macros rather than hard-coded letters for "True" and "False". (Do also think hard why you're using the letter F both as a variable and as the token for "false". Is it so difficult to come up with a better variable name than "F"?)

  • Get rid of all vertical bars, and use the line-drawing macros of the booktabs package to insert a few but well-spaced horizontal lines.

  • Add a bit of extra vertical whitespace after every fourth row in the body of the table, since four rows at a time provide a natural grouping for the table at hand.

enter image description here

\documentclass{article}
\usepackage{booktabs}
\newcommand\T{\textrm{T}}  % "true"
\newcommand\F{\textrm{F}}  % "false"
\begin{document}
\begin{table}[h]
\centering
$\begin{array}{ *{8}{c} }
\toprule
B & F & P & C & B \lor F & P \lor C & \neg(F \land C) & \neg(B \land P)\\
\midrule
\T & \T & \T & \T & \T & \T & \F & \F \\ 
\T & \T & \T & \F & \T & \T & \T & \F \\
\T & \T & \F & \T & \T & \T & \F & \T \\
\T & \T & \F & \F & \T & \F & \T & \T \\[1ex]
\T & \F & \T & \T & \T & \T & \T & \F \\
\T & \F & \T & \F & \T & \T & \T & \F \\
\T & \F & \F & \T & \T & \T & \T & \T \\
\T & \F & \F & \F & \T & \F & \T & \T \\[1ex]
\F & \T & \T & \T & \T & \T & \F & \T \\
\F & \T & \T & \F & \T & \T & \T & \T \\
\F & \T & \F & \T & \T & \T & \F & \T \\
\F & \T & \F & \F & \T & \F & \T & \T \\[1ex]
\F & \F & \T & \T & \F & \T & \T & \T \\
\F & \F & \T & \F & \F & \T & \T & \T \\
\F & \F & \F & \T & \F & \T & \T & \T \\
\F & \F & \F & \T & \F & \T & \T & \T \\
\bottomrule
\end{array}$
\end{table}
\end{document}

In my case it happened because I didn't declare the right number of columns

example:

\begin{tabular}{|c|c|c|}


2017 update

Since xintexpr 1.1 (2014/10/28) it is preferred to use || and &&, the single | and & may change meaning from their current ones as Boolean or resp. and. One can also use the keywords 'or' resp. 'and' (quotes mandatory). Answer updated to anticipate possible future change of meaning of single | and & infix operators.


Perhaps you wish the table to be automatically filled in?

Update adds code for 1ex vertical skip every four rows thing.

\documentclass{article}
\usepackage{booktabs}
\usepackage{xintexpr}

\newcommand\T{\textrm{T}}  % "true"
\newcommand\F{\textrm{F}}  % "false"

\newcommand\TF[1]{\if1#1\T\else\F\fi}

\begin{document}
\begin{table}[h]
\centering

$\begin{array}{ *{8}{c} }
\toprule
B & F & P & C & B \lor F & P \lor C & \neg(F \land C) & \neg(B \land P)\\
\midrule
\xintFor #1 in {1,0}\do {%
  \xintFor #2 in {1,0}\do {%
    \xintFor #3 in {1,0}\do {%
      \xintFor #4 in {1,0}\do {%
 \TF#1 & \TF#2 & \TF#3 & \TF#4 &
 \xintifboolexpr {#1 || #2}{\T}{\F}& 
 \xintifboolexpr {#3 || #4}{\T}{\F} &
 \xintifboolexpr {not(#2 && #4)}{\T}{\F} & 
 \xintifboolexpr {not(#1 && #3)}{\T}{\F} \\ 
 }}}}
\bottomrule
\end{array}$

\end{table}
\end{document}

truth table

With extra skips:

\documentclass{article}
\usepackage{booktabs}
\usepackage{xintexpr}

\newcommand\T{\textrm{T}}  % "true"
\newcommand\F{\textrm{F}}  % "false"

\newcommand\TF[1]{\if1#1\T\else\F\fi}

\begin{document}
\begin{table}[h]
\centering
$\begin{array}{ *{8}{c} }
\toprule
B & F & P & C & B \lor F & P \lor C & \neg(F \land C) & \neg(B \land P)\\
\midrule
\xintFor #1 in {1,0}\do {%
  \xintFor #2 in {1,0}\do {%
    \xintFor #3 in {1,0}\do {%
      \xintFor #4 in {1,0}\do {%
 \TF#1 & \TF#2 & \TF#3 & \TF#4 &
 \xintifboolexpr {#1 || #2}{\T}{\F}& 
 \xintifboolexpr {#3 || #4}{\T}{\F} &
 \xintifboolexpr {not(#2 && #4)}{\T}{\F} & 
 \xintifboolexpr {#3 || #4}% every four, add 1ex space
     {\xintifboolexpr {not(#1 && #3)}{\T}{\F}\\}
     {\xintifboolexpr {not(#1 && #3)}{\T}{\F}\\[1ex]}
 }}}}
\noalign{\addvspace{-1ex}}% compensate the last 1ex vskip
\bottomrule
\end{array}$
\end{table}
\end{document}

truth table with extra vertical spaces

Tags:

Errors