将文本定位在两行之间并在 \array 环境中添加一个花括号

将文本定位在两行之间并在 \array 环境中添加一个花括号

我正在尝试为逻辑中的一些基本规则制作一个表格,其中我在最后一列中添加了每个规则的名称。我在环境中完成了所有这些工作array

$$\begin{array}{lcccl}
\mathrm{(a)} & \mathrm{P}                  & \mathrm{and} & \lnot(\lnot \mathrm{P})           & (\textit{Double Negation Law}) \\
\mathrm{(b)} & \mathrm{P} \lor \mathrm{Q}           & \mathrm{and} & \mathrm{Q}\lor \mathrm{P}                  & \\
\mathrm{(c)} & \mathrm{P} \land \mathrm{Q}          & \mathrm{and} & \mathrm{Q}\land \mathrm{P}                 & \\
\mathrm{(d)} & \mathrm{P}\lor (\mathrm{Q}\lor R)    & \mathrm{and} & (\mathrm{P}\lor \mathrm{Q})\lor R          & \\
\mathrm{(e)} & \mathrm{P}\land (\mathrm{Q}\land R)  & \mathrm{and} & (\mathrm{P}\land \mathrm{Q})\land R        &\\
\mathrm{(f)} & \mathrm{P}\land(\mathrm{Q}\lor R)    & \mathrm{and} & (\mathrm{P}\land \mathrm{Q})\lor(\mathrm{P}\land R) &\\
\mathrm{(g)} & \mathrm{P}\lor(\mathrm{Q}\land R)    & \mathrm{and} & (\mathrm{P}\lor \mathrm{Q})\land(\mathrm{P}\lor R)  & \\
\mathrm{(h)} & \lnot(\mathrm{P}\land \mathrm{Q})    & \mathrm{and} & \lnot \mathrm{P}\lor\lnot \mathrm{Q}       & \\
\mathrm{(i)} & \lnot(\mathrm{P}\lor \mathrm{Q})     & \mathrm{and} & \lnot \mathrm{P}\land\lnot \mathrm{Q}      & \\
\end{array}
$$

我希望得到这样的最终结果:在此处输入图片描述

答案1

我不认为array环境是这里的最佳选择,但无论如何,这是一个使用包的选项。我只是像下面的代码一样multirow添加了一个两行单元格。环境通常太密集,因此,为了使其更具可读性,您可以在数组之前本地添加。\multirow{2}{*}{$\left.\hbox{\rule{0cm}{.45cm}}\right\}$ De Morgan's Laws}array\renewcommand{\arraystretch}{1.2}

\documentclass{article}
\usepackage{amsmath}
\usepackage{multirow}
\begin{document}

\begin{equation*}
\renewcommand{\arraystretch}{1.2}
\begin{array}{lcccl}
\mathrm{(a)} & \mathrm{P}                  & \mathrm{and} & \lnot(\lnot \mathrm{P})           & (\textit{Double Negation Law}) \\
\mathrm{(b)} & \mathrm{P} \lor \mathrm{Q}           & \mathrm{and} & \mathrm{Q}\lor \mathrm{P}                  & \\
\mathrm{(c)} & \mathrm{P} \land \mathrm{Q}          & \mathrm{and} & \mathrm{Q}\land \mathrm{P}                 & \\
\mathrm{(d)} & \mathrm{P}\lor (\mathrm{Q}\lor R)    & \mathrm{and} & (\mathrm{P}\lor \mathrm{Q})\lor R          & \\
\mathrm{(e)} & \mathrm{P}\land (\mathrm{Q}\land R)  & \mathrm{and} & (\mathrm{P}\land \mathrm{Q})\land R        &\\
\mathrm{(f)} & \mathrm{P}\land(\mathrm{Q}\lor R)    & \mathrm{and} & (\mathrm{P}\land \mathrm{Q})\lor(\mathrm{P}\land R) &\\
\mathrm{(g)} & \mathrm{P}\lor(\mathrm{Q}\land R)    & \mathrm{and} & (\mathrm{P}\lor \mathrm{Q})\land(\mathrm{P}\lor R)  & \\
\mathrm{(h)} & \lnot(\mathrm{P}\land \mathrm{Q})    & \mathrm{and} & \lnot \mathrm{P}\lor\lnot \mathrm{Q}       &\multirow{2}{*}{$\left.\hbox{\rule{0cm}{.45cm}}\right\}$ De Morgan's Laws} \\
\mathrm{(i)} & \lnot(\mathrm{P}\lor \mathrm{Q})     & \mathrm{and} & \lnot \mathrm{P}\land\lnot \mathrm{Q}      & \\
\end{array}
\end{equation*}

\end{document}

在此处输入图片描述

答案2

\documentclass[10pt]{article}
\usepackage{amsmath}
\begin{document}

\[
\begin{array}{lcccl}
\mathrm{(a)} & \mathrm{P} & \mathrm{and} & \lnot(\lnot 
\mathrm{P})           & (\textit{Double Negation Law}) \\
\mathrm{(b)} & \mathrm{P} \lor \mathrm{Q}           & \mathrm{and} & \mathrm{Q}\lor 
\mathrm{P}                  & \\
\mathrm{(c)} & \mathrm{P} \land \mathrm{Q}          & \mathrm{and} & \mathrm{Q}\land 
\mathrm{P}                 & \\
\mathrm{(d)} & \mathrm{P}\lor (\mathrm{Q}\lor R)    & \mathrm{and} & (\mathrm{P}\lor 
\mathrm{Q})\lor R          & \\
\mathrm{(e)} & \mathrm{P}\land (\mathrm{Q}\land R)  & \mathrm{and} & (\mathrm{P}\land 
\mathrm{Q})\land R        &\\
\mathrm{(f)} & \mathrm{P}\land(\mathrm{Q}\lor R)    & \mathrm{and} & (\mathrm{P}\land 
\mathrm{Q})\lor(\mathrm{P}\land R) &\\
\mathrm{(g)} & \mathrm{P}\lor(\mathrm{Q}\land R)    & \mathrm{and} & (\mathrm{P}\lor 
\mathrm{Q})\land(\mathrm{P}\lor R)  & \\
\mathrm{(h)} & \lnot(\mathrm{P}\land \mathrm{Q})    & \mathrm{and} & \lnot 
\mathrm{P}\lor\lnot \mathrm{Q}       &  
\makebox(0,0){\put(0,-20){%
  \left.\rule{0pt}{1.06\normalbaselineskip}\right\}\text{De Morgan's laws}}}\\  
\mathrm{(i)} & \lnot(\mathrm{P}\lor \mathrm{Q})     & \mathrm{and} & \lnot 
\mathrm{P}\land\lnot \mathrm{Q}      & 
\end{array}
\]

\end{document}

在此处输入图片描述

答案3

这是一个提供实际列表(而不是牢不可破的块/ array)的选项:

在此处输入图片描述

\documentclass{article}

\usepackage{enumitem}

\newlength{\leftboxlen}
\newcommand{\setleftbox}[1]{\settowidth{\leftboxlen}{#1}}
\newcommand{\leftbox}[2][c]{\makebox[\leftboxlen][#1]{#2}}
\newlength{\rightboxlen}
\newcommand{\setrightbox}[1]{\settowidth{\rightboxlen}{#1}}
\newcommand{\rightbox}[2][c]{\makebox[\rightboxlen][#1]{#2}}

\begin{document}

\noindent\textbf{Theorem 1.6.}
\setleftbox{$\mathrm{P} \land (\mathrm{Q} \land R)$}%
\setrightbox{$(\mathrm{P} \land \mathrm{Q}) \lor (\mathrm{P} \land R)$}%
\begin{enumerate}[label=(\alph*),nosep]
  \item \leftbox{$\mathrm{P}$} and \rightbox{$\lnot(\lnot \mathrm{P})$} \qquad (\textit{Double Negation Law})
  \item \leftbox{$\mathrm{P} \lor \mathrm{Q}$} and \rightbox{$\mathrm{Q} \lor \mathrm{P}$}
  \item \leftbox{$\mathrm{P} \land \mathrm{Q}$} and \rightbox{$\mathrm{Q} \land \mathrm{P}$}
  \item \leftbox{$\mathrm{P} \lor (\mathrm{Q} \lor R)$} and \rightbox{$(\mathrm{P} \lor \mathrm{Q}) \lor R$}
  \item \leftbox{$\mathrm{P} \land (\mathrm{Q} \land R)$} and \rightbox{$(\mathrm{P} \land \mathrm{Q}) \land R$}
  \item \leftbox{$\mathrm{P} \land(\mathrm{Q} \lor R)$} and \rightbox{$(\mathrm{P} \land \mathrm{Q}) \lor (\mathrm{P} \land R)$}
  \item \leftbox{$\mathrm{P} \lor (\mathrm{Q} \land R)$} and \rightbox{$(\mathrm{P} \lor \mathrm{Q}) \land (\mathrm{P} \lor R)$}
  \item \leftbox{$\lnot (\mathrm{P} \land \mathrm{Q})$} and \rightbox{$\lnot \mathrm{P} \lor \lnot \mathrm{Q}$} \qquad
    \raisebox{-.45\height}[0pt][0pt]{$\left.\kern-\nulldelimiterspace\begin{array}{@{}c@{}} \mathstrut \\ \mathstrut \end{array}\right\} \mbox{(\textit{De Morgan's Law})}$}
  \item \leftbox{$\lnot(\mathrm{P} \lor \mathrm{Q})$} and \rightbox{$\lnot \mathrm{P} \land \lnot \mathrm{Q}$}
\end{enumerate}

\end{document}

结构的水平对齐是使用框来实现的。左侧部分设置在 内\leftbox(其宽度设置为\setleftbox),而右侧部分设置在 内\rightbox(并且 也以 命名\setrightbox)。

De Morgan's Law符号是一个降低的堆栈(2 行array),高度/深度为零。

相关内容