我尝试制作这个表格,但是缺少右边框。这是我为此编写的代码:
\begin{center}
\begin{tabular}{||c c|c c c c c c c ||}
\hline
p & q & p & $\vee$ & [$\neg$ & (p & $\wedge$ & q)]\\ [0.5ex]
\hline\hline
T & T & T & T & F & T & T & T\\
\hline
T & F & T & T & T & T & F & F\\
\hline
F & T & F & T & T & F & F & T\\
\hline
F & F & F & T & T & F & F & F\\
\hline
\end{tabular}
\end{center}
答案1
表格美化--标题行灰色
\rowcolor{gray!30}
T
突出显示的条目--
\makeatletter
\newcommand*{\minuscellcolor}{}
\def\minuscellcolor\ignorespaces{%
% \ignorespaces not really needed, because \@ifnextchar gobbles spaces
\@ifnextchar{T}{\cellcolor{green!40}}{}%
}
\newcolumntype{C}{>{\minuscellcolor}c}
\makeatother
额外的排空间——
\renewcommand{\arraystretch}{2}
数学家协会
\documentclass{article}
\usepackage[svgnames,table]{xcolor}% note the table option
\usepackage{booktabs}
\renewcommand{\arraystretch}{2}
\makeatletter
\newcommand*{\minuscellcolor}{}
\def\minuscellcolor\ignorespaces{%
% \ignorespaces not really needed, because \@ifnextchar gobbles spaces
\@ifnextchar{T}{\cellcolor{green!40}}{}%
}
\newcolumntype{C}{>{\minuscellcolor}c}
\makeatother
\begin{document}
\begin{center}
\begin{tabular}{*{8}C} \toprule\rowcolor{gray!30}
p & q & p & $\vee$ & [$\neg$ & (p & $\wedge$ & q)] \\
T & T & T & T & F & T & T & T \\
T & F & T & T & T & T & F & F \\
F & T & F & T & T & F & F & T \\
F & F & F & T & T & F & F & F \\ \bottomrule
\end{tabular}
\end{center}
\end{document}
或者
普通表
\documentclass{article}
\usepackage[svgnames,table]{xcolor}% note the table option
\usepackage{booktabs}
\begin{center}
\begin{tabular}{*{8}c} \toprule
p & q & p & $\vee$ & [$\neg$ & (p & $\wedge$ & q)] \\ \hline \hline
T & T & T & T & F & T & T & T \\ \hline
T & F & T & T & T & T & F & F \\ \hline
F & T & F & T & T & F & F & T \\ \hline
F & F & F & T & T & F & F & F \\ \bottomrule
\end{tabular}
\end{center}
\end{document}
答案2
c 太多了,表格需要 9 列,但您只填充了 8 列。您要么填充第 9 列,要么删除一个 c。
\documentclass{article}
\usepackage{tabu}
\begin{document}
\begin{center}
\begin{tabular}{||c c|c c c c c c c ||}
\hline
p & q & p & $\vee$ & [$\neg$ & (p & $\wedge$ & q)]\\ [0.5ex]
\hline\hline
T & T & T & T & F & T & T & T\\
\hline
T & F & T & T & T & T & F & F\\
\hline
F & T & F & T & T & F & F & T\\
\hline
F & F & F & T & T & F & F & F\\
\hline
\end{tabular}
\end{center}