我如何排版 Copi 风格的校样?

我如何排版 Copi 风格的校样?

我该如何以这种风格排版证明?也就是说,我该如何编写三列证明,第一列对前提或断言进行编号,第二列包含前提或断言本身,第三列包含断言的依据(如果该行的第二列包含断言)?

在此处输入图片描述

答案1

以下代码极大地得益于 gernot 对问题的回答逻辑条件证明 (cp) 箭头

\suppose、、\consequenceofsupposition\arrow(如下所定义)用于由 CP(条件证明)证实的推论。

在此处输入图片描述

\documentclass{article}

\usepackage{calc}
\usepackage{amssymb} % defines \therefore
\usepackage{tikz}

\let\impl\supset

\newcounter{lineno} % as in ``line number''

\newcommand{\copiproof}[1]{\begin{center}\begin{tabular}{rll}\setcounter{lineno}{0}#1\end{tabular}\end{center}} % after Irving Copi

\newcommand{\premise}[1]{\addtocounter{lineno}{1}\thelineno. & $#1$\\}

\newcommand{\premiseandclaim}[2]{%
\addtocounter{lineno}{1}\thelineno. & $#1$ \rlap{\quad$/\therefore #2$}\\}

\newcommand{\assert}[2]{\addtocounter{lineno}{1}\thelineno. & $#1$ & #2\\}

\newcommand\tikznode[3][]{%
  \tikz[remember picture,baseline=(#2.base)]
      \node[minimum size=0pt,inner sep=0pt,#1](#2){#3};%
}

\newcommand{\suppose}[1]{\addtocounter{lineno}{1}\tikznode{A}{\thelineno.} & $#1$\\}

\newcommand{\consequenceofsupposition}[4]{\addtocounter{lineno}{1}\thelineno. & \tikznode{B}{$#1\impl(#2)$\strut} & $#3$--$#4$, C.P.\\} % The first argument: the supposition. The second argument: the consequence of the supposition. The third argument: The line number of the supposition. The fourth argument: The line number of the consequence of the supposition.

\newcommand{\arrow}{%
\begin{tikzpicture}[remember picture,overlay]
  \draw[stealth-,shorten <=2pt] (A) -- ++(-1.5em,0) |- (B.north east);
\end{tikzpicture}
}

\begin{document}

%%% Example skeleton:

\copiproof{
\premise{first premise}
\premise{second premise}
\premiseandclaim{third premise}{claim}
\assert{first assertion}{justification}
\assert{second assertion}{justification}
\assert{third assertion}{justification}
}

%%% gernot's code:

\begin{center}
  \begin{tabular}{rll}
              1.  & $A\impl B$ \rlap{\quad$/\therefore A\impl (A\cdot B)$}\\
 \tikznode{A}{2.} & $A$                & supuesto \\
              3.  & $B$                & $1$, $2$, M.P.\\
              4.  & $A\cdot B$                        & $2$, $3$, Conj.\\
              5.  & \tikznode{B}{$A\impl(A\cdot B)$\strut} & $2$--$4$, C.P.
   \end{tabular}
\end{center}
\begin{tikzpicture}[remember picture,overlay]
  \draw[stealth-,shorten <=2pt] (A) -- ++(-1.5em,0) |- (B.north east);
\end{tikzpicture}

%%% Mechanized version of gernot's code:

\copiproof{
\premiseandclaim{A\impl B}{A\impl (A\cdot B)}
\suppose{A}
\assert{B}{1, 2, M.P.}
\assert{A\cdot B}{2, 3, Conj.}
\consequenceofsupposition{A}{A\cdot B}{2}{4}
\arrow
}

\end{document}

答案2

{NiceTabular}这是使用和 TikZ 的解决方案,nicematrix使用创建的 TikZ 节点绘制箭头nicematrix

\documentclass{article}
\usepackage{amssymb} % for \therefore
\usepackage{nicematrix,tikz}
\usetikzlibrary{arrows.meta,ext.paths.ortho} % for "r-lr"

\begin{document}

\begin{NiceTabular}{rll}
  1.  & $A\supset B$ \rlap{\quad$/\therefore A\supset (A\cdot B)$}\\
  2.  & $A$                  & supuesto \\
  3.  & $B$                  & $1$, $2$, M.P.\\
  4.  & $A\cdot B$               & $2$, $3$, Conj.\\
  5.  & $A\supset(A\cdot B)$     & $2$--$4$, C.P.
\CodeAfter \tikz \draw [<-,shorten < = 2pt] (2-1) r-lr ([yshift=1pt]5-|3);
\end{NiceTabular}

\end{document}

上述代码的输出

相关内容