this is kind of a follow up of this question, where someone asked how to create a box around a few items in an itemize environment. I'm facing a similar issue, but my case is a little bit more complex, as I want to be able to generate things like in the image below.
I tried to adapt the solution in the aforementioned link, but it doesn't work since the left markings are overwritten when I add more of them.
Does anyone have a solution to this?
--- EDIT ---
This is what I have so far, which works well without nested boxes
\documentclass{article}
\usepackage[a4paper,top=3cm,left=2.5cm,right=2.5cm,bottom=3cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{xparse}
\usepackage{calc}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\newcommand{\bitem}[3]{\makebox[#1]{#2\hfill} \quad #3}
\newcommand{\bitemL}[3]{\tikzmark{left}\makebox[#1]{#2\hfill} \quad #3}
\newcommand{\bitemR}[3]{\makebox[#1]{#2\hfill}\tikzmark{right} \quad #3}
\makeatletter
\NewDocumentCommand{\DrawBox}{s O{}}{%
\tikz[overlay,remember picture]{
\IfBooleanTF{#1}{%
\coordinate (RightPoint) at ($(left |- right)+(\linewidth-\labelsep-\labelwidth,0.0)$);
}{%
\coordinate (RightPoint) at (right.east);
}%
\draw[black]
($(left)+(-0.2em,0.9em)$) rectangle
($(RightPoint)+(0.2em,-0.3em)$);}
}
\makeatother
\begin{document}
\medskip\par\noindent
\begin{minipage}{0.4\linewidth}
\begin{enumerate}
\item [1.]{\bitem{2cm}{$\neg Q \rightarrow \neg P$}{$(premissa)$}}
\item [2.]{\bitemL{2cm}{$P$}{$(hipótese)$}}
\item [3.]{\bitem{2cm}{$\neg \neg P $}{$(\neg \neg i ~ 2)$}}
\item [4.]{\bitemR{2cm}{$\neg \neg Q $}{$(MT ~ 1, 3)$}}
\item [5.]{\bitem{2cm}{$P \rightarrow \neg \neg Q$}{$(\rightarrow i ~ 2,4)$}}
\end{enumerate}
\DrawBox[thick]
\end{minipage}
\end{document}
tikzmark
library (or even without) provided you go ahead and bake an MWE in which the text without these boxes is produced. Typing this up is not something many like to do.