2

I was wondering how to draw an arrow that encircle some text, so that the arrow would "box in" some statements and point to the start of the statement, which can also be nested. It is used in my logic course to encapsulate the scope of an undischarged premise after using 'AP' and before 'IP' or 'CP'.

I figured that it can probably be done by writing the text in aligned and drawing the arrow with TikZ, but then the arrows would not change dynamically with the line count.

Basically I want to do what is done below in a word processor, in LaTeX.

enter image description here

1 Answers1

3

Here is a possibility using nicematrix. Note that you must compile it twice.

enter image description here

Define a new command \surr that takes three arguments, one optional:

\surr[<nest level>]{<from row>}{<to row>}

The nest level is 1 by default. The \surr commands should be used in the \CodeAfter. Additional vertical space for the arrows is created by adding [1ex] to the relevant lines. Omit or change if you wish.

To make spacing adjustments in sthe \surr command:

  • -3pt is the distance below the current row that the line is drawn.
  • 2mm is the space between nested vertical lines.
  • 3mm is the additional space for the first nest level.

If you want to automate the row numbering, there are several solutions on TeX.SX, for example here.

\documentclass{article}

\usepackage{nicematrix, tikz}

\newcommand{\surr}[3][1]{\tikz{ \draw[->]([shift={(0,-3pt)}]#2-2.south east)--([shift={({#1*-2mm-3mm},-3pt)}]#2-1.south west)|-(#3-1.west); }}

\begin{document}

\begin{NiceTabular}{ll}

  1. $A\lor B$ & AP\
  2. $(A\supset B)\bullet(B\supset C)$ & AP\
  3. $(A\supset C)$ & 2 Simp\
  4. $(B\supset C)$ & 2 Simp\
  5. $C\lor C$ & 1, 3, 4 CD\
  6. $C$ & 5 Taut\[1ex]
  7. $[(A\supset B)\bullet(B\supset C)]\supset C$ & 2--6 CP\[1ex]
  8. $(A\lor B)\supset{[(A\supset B)\bullet(B\supset C)]\supset C}$ & 1--7 CP

\CodeAfter \surr{6}{2} \surr[2]{7}{1} \end{NiceTabular}

\end{document}

Sandy G
  • 42,558