简体   繁体   中英

LaTeX table - extra alignment tab?

I'm new to LaTeX and trying to make a truth table, but it won't compile. When I try to run the code, it says "Extra alignment tab has been changed to \cr." Here is my code:

\item (Textbook 1.1/38, 4 points) $((p\rightarrow q)\rightarrow r)\rightarrow s$
\begin{center}
\begin{tabular}{c|c|c|c|c|c}
\hline
$p$ & $q$ & $r$ & $s$ & $p\rightarrow q$ & $(p\rightarrow q)\rightarrow$ r & $((p\rightarrow q)\rightarrow r)\rightarrow s$ \\ 
\hline
T & T & T & T & T & T & T \\
T & T & T & F & T & T & F \\
T & T & F & T & T & F & T \\
T & F & T & T & F & T & T \\
T & F & T & F & F & T & F \\
T & F & F & T & F & T & T \\
T & F & F & F & F & T & F \\
F & T & T & T & T & T & T \\
F & T & T & F & T & T & F \\
F & T & F & T & T & F & T \\
F & T & F & F & T & F & T \\
F & F & T & T & T & T & T \\
F & F & T & F & T & T & F \\
F & F & F & T & T & F & T \\
F & F & F & F & T & F & T \\
\hline
\end{tabular}
\end{center}

Very easily, you declared six columns: there are six c in the line

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

Then, every line of your table has seven cells instead:

...
T & T & T & T & T & T & T \\
...

So, you should solve by changing

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

to

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

or

\begin{tabular}{c*{6}{|c}}

All you have to do is remove the \\ at the end of the last line of the truth table. I would also suggest trying out Overleaf it allows you to see your code in real time and gives an easier debugging experience.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM