如何创建表示逻辑证明的列表

如何创建表示逻辑证明的列表

我正在尝试在 latex 中创建一个如下所示的列表来表达逻辑证明。如您所见,编号很奇特,因为子编号比前一个要早一个。例如,如果在 3 之后创建一个子列表,则它以数字 4.x 而不是 3 开头。此外,当它是另一个更大的可枚举列表的一部分时,我需要这个列表能够工作(即这是针对问题 8 的,但我需要从 1 开始计数以进行证明本身。谢谢,如果您需要澄清,请告诉我

逻辑证明

答案1

您可以只使用嵌套计数器tabular和新计数器。为了简化操作,您可以为它们定义环境。它们可以自动插入计数器。

\documentclass{article}
\usepackage{array}
\newcounter{logpnumi}
\newcounter{logpnumii}
\newenvironment{LogProof}{\begingroup\sffamily
\setcounter{logpnumi}{0}%
\begin{tabular}{>{\stepcounter{logpnumi}\number\value{logpnumi}.}rll}}{\end{tabular}
\endgroup}
\newenvironment{SubTable}{\begin{tabular}[t]{@{}>{%
\ifnum\value{logpnumii}<1
\else
\the\numexpr\value{logpnumi}+1\relax.\number\value{logpnumii}
\fi
\stepcounter{logpnumii}
}lll}}
{\end{tabular}\setcounter{logpnumii}{0}}
\begin{document}
\begin{LogProof}
 & $\lnot s\to r$ & Given\\
 & $(r\lor p)\to q$ & Given\\
 & \begin{SubTable}
  $r\to q$ \\
 & $\lnot s$ & Assumption\\
 & $r$ & MP4.1
 \end{SubTable} & $\land$ Elim:2\\
 & \begin{SubTable}
  $\lnot s\to q$ \\
 & $s$ & Assumption\\
 & $s\to(p\land q)$ & Given
 \end{SubTable} & Direct proof rule\\ 
 & $s\to q$ & [Direct proof rule]\\ 
\end{LogProof}
\end{document}

在此处输入图片描述

答案2

您可以将enumii编号重新定义为一个表达式,该表达式采用前一个数字的增量enumi。请注意,的参数\numexpr应以 结尾\relax。这将被吞噬,\numexpr以确保它不会进一步扫描更多数字。

\documentclass{article}

\renewcommand{\labelenumii}{\theenumii}
\renewcommand*\theenumii{\the\numexpr(\value{enumi}+1)\relax.\arabic{enumii}}

\begin{document}
\begin{enumerate}
  \item First
  \begin{enumerate}
    \item Second
    \item Third
  \end{enumerate}
  \item Fourth
  \item Fifth
\end{enumerate}
\end{document}

提前编号

相关内容