如何使此表格中的第一列居中

如何使此表格中的第一列居中
\documentclass[12pt]{article}
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathrsfs}
\usepackage{amsthm}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage[french]{babel}
\usepackage[utf8]{inputenc}
\usepackage[top=3cm, bottom=3cm, left=3cm, right=3cm]{geometry}
\usepackage[x11names]{xcolor}
\usepackage{framed, etoolbox}
\colorlet{framecolor}{VioletRed4}
\colorlet{shadecolor}{LavenderBlush2!60}
\usepackage{thmtools} %
\usepackage{titlesec}%%%%%% <---------addendum
\titleformat{\section}%%%%%% <---------addendum
{\color{magenta}\normalfont\Large\bfseries}%%%%%% <---------addendum
{\color{magenta}\thesection}{1.5em}{}%%%%%% <---------addendum
\makeatletter
\define@key{thmdef}{frame}[{}]{%
 \thmt@trytwice{}{%
 \RequirePackage{framed}%
 \RequirePackage{thm-patch}%
    \def\FrameCommand{\fcolorbox{framecolor}{shadecolor}}
 \addtotheorempreheadhook[\thmt@envname]{%
 \begin{framed}}%
 \addtotheorempostfoothook[\thmt@envname]{\end{framed}}%
 }%
}
\makeatother

\declaretheoremstyle[
bodyfont=\mdseries,
]{mystyle}


\declaretheorem[numberwithin=section, frame]{definition}
\declaretheorem[frame, sharenumber=definition,style=mystyle]{proposition}
\AtBeginEnvironment{proposition}{\colorlet{framecolor}{DarkSeaGreen4}
    \colorlet{shadecolor}{Yellow1!15}}

\newcommand{\myarrow}[1][1cm]{\mathrel{%
   \hbox{\rule[\dimexpr\fontdimen22\textfont2-.2pt\relax]{#1}{.4pt}}%
   \mkern-4mu\hbox{\usefont{U}{lasy}{m}{n}\symbol{41}}}}

\makeatletter

\setbox0\hbox{$\xdef\scriptratio{\strip@pt\dimexpr
    \numexpr(\sf@size*65536)/\f@size sp}$}

\newcommand{\myscriptarrow}[1][1cm]{{%
    \hbox{\rule[\scriptratio\dimexpr\fontdimen22\textfont2-.2pt\relax]
               {\scriptratio\dimexpr#1\relax}{\scriptratio\dimexpr.4pt\relax}}%
   \mkern-4mu\hbox{\let\f@size\sf@size\usefont{U}{lasy}{m}{n}\symbol{41}}}}

\makeatother


\begin{document}
 \begin{center}
  \begin{tabular}{ | c | c | c }
    \hline
    \rule{0pt}{0.9\normalbaselineskip}
    $P$& $\bar{P}$  \\ \hline
    $V$ & $F$  \\ \hline
    $F$ & $V$  \\
    \hline
  \end{tabular}
\end{center}

\end{document}

答案1

您需要\rule{0pt}{..}通过插入来删除后面的空格%,请记住,return在 LaTeX 中按下该键意味着输入一个空格。

\documentclass[12pt]{article}

\begin{document}
 \begin{center}
  \begin{tabular}{ | c | c | c }
    \hline
    \rule{0pt}{0.9\normalbaselineskip}% <===
    $P$& $\bar{P}$  \\ \hline
    $V$ & $F$  \\ \hline
    $F$ & $V$  \\
    \hline
  \end{tabular}
\end{center}

\end{document}

更好的是,摆脱它\rule{}{}并使用\renewcommand{\arraystretch}{1.5}它来增加表格内的行距。

在此处输入图片描述

如果表格仅包含数学元素,为什么不使用array?如下所示:

\[
\renewcommand{\arraystretch}{1.5}
\begin{array}{|c|c|c|}
    \hline
    P & \bar{P} \\ \hline
    V & F       \\ \hline
    F & V       \\
    \hline
\end{array}
\]

相关内容