Manter o recuo e o alinhamento à esquerda consistentes

Sep 27 2020

Eu precisaria reproduzir um gráfico semelhante ao da imagem. Preciso manter o alinhamento à esquerda e o recuo consistentes, também as linhas horizontais e verticais são importantes. Agradeceria qualquer conselho sobre isso, talvez um exemplo de brinquedo que mostra as principais idéias.

Muito obrigado antecipadamente.

Respostas

1 SimonDispa Sep 27 2020 at 20:53

Se você tentar o código a seguir, obterá um resultado bastante semelhante ao seu exemplo, embora eu provavelmente tenha entendido mal alguns símbolos, mas você entenderá a essência deles.

Agora, com base em sua pergunta, acho que você quer um procedimento padrão para abordar um grande projeto de maneira consistente.

Vou te contar a minha receita, porque o importante é como foi feita.

1 Isso é óbvio: use tabular

2 Construa a tabela no Excel. (Isso é importante, não trabalhe diretamente com o código LaTeX, você verá o porquê mais tarde).

3 Use o suplemento Excel2laTex. https://www.ctan.org/tex-archive/support/excel2latex

  1. Desmarque o pacote de favoritos e converta as opções $ ^ _ \

5 Copie para a área de transferência e cole em um documento LaTeX vazio com um conjunto de pacotes necessários.

  1. Compilar.

7 Corrija os erros ou faça alterações indo para o Excel e retornando para o LaTeX. Dessa forma, você obtém um feedback muito rápido, sem a necessidade de aprender os pequenos detalhes dos pacotes (bem, na maioria das vezes).

\documentclass{article}

\usepackage{multirow}   
\usepackage{bigstrut}       


\begin{document}
% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{table}[htbp]
    \centering
    \caption{Add caption}
    \begin{tabular}{lrlrrl}
        (1)   &       & $P\rightarrow   Q$ &       &       & $\mathbf{P}$ \\
        (2)   &       & $ \rightharpoondown T$ &       &       & $\mathbf{P}$ \\
        (3)   &       & $Q \rightarrow T$ &       &       & $\mathbf{P}$ \\
        (4)   &       & $S\vee W\rightarrow  Q$ &       &       & $\mathbf{P}$ \\
        (5)   &       & \multicolumn{1}{r|}{} & \multicolumn{1}{l}{$P\vee (R\wedge S)$} &       & $\mathbf{H}$ \bigstrut[b]\\
        \cline{4-5}    (6)   &       & \multicolumn{1}{r|}{} & \multicolumn{1}{r|}{} & \multicolumn{1}{l}{$P$} & $\mathbf{H}$ \bigstrut\\
        \cline{5-5}    (7)   &       & \multicolumn{1}{r|}{} & \multicolumn{1}{r|}{} & \multicolumn{1}{l}{$Q$} & $\mathbf{I}\rightarrow 1, 6$ \bigstrut[t]\\
        &       & \multicolumn{1}{r|}{} &       &       &  \\
        (8)   &       & \multicolumn{1}{r|}{} & \multicolumn{1}{r|}{} & \multicolumn{1}{l}{$R\wedge  S$} & $\mathbf{H}$ \bigstrut[b]\\
        \cline{5-5}    (9)   &       & \multicolumn{1}{r|}{} & \multicolumn{1}{r|}{} & \multicolumn{1}{l}{$S$} & $\mathbf{H} \wedge 8$ \bigstrut[t]\\
        (10)  &       & \multicolumn{1}{r|}{} & \multicolumn{1}{r|}{} & \multicolumn{1}{l}{$S\vee  W$} & $\mathbf{I} \vee 9$ \\
        (11)  &       & \multicolumn{1}{r|}{} & \multicolumn{1}{r|}{} & \multicolumn{1}{l}{$Q$} & $\mathbf{E} \rightarrow 4, 10$ \\
        (12)  &       & \multicolumn{1}{r|}{} & \multicolumn{1}{l}{$Q$} &       & $\mathbf{E} \vee 5,7,11$ \\
        (13)  &       & \multicolumn{1}{r|}{} & \multicolumn{1}{l}{$T$} &       & $\mathbf{E} \rightarrow 3. 12$ \\
        (14)  &       & \multicolumn{1}{r|}{} & \multicolumn{1}{l}{$ \rightharpoondown T$} &       & $\mathbf{it}\; 2$ \\
        (15)  &       & $ \rightharpoondown(P\vee (R \wedge S))$ &       &       & $\mathbf{I} \rightarrow 5,13,14$ \\
    \end{tabular}%
    \label{tab:addlabel}%
\end{table}%
    
\end{document}

Tempo total gasto: 30 min escrevendo a tabela, 5 min obtendo o resultado.

Deixei alguns erros, tente corrigi-los você mesmo usando o procedimento descrito, ao invés de editar o código LaTeX. Responda no UPDATE, abaixo.

UPDATE Código corrigido, gerado com o mesmo procedimento.

\documentclass{article}

\usepackage{multirow}   
\usepackage{bigstrut}   

\begin{document}
% Table generated by Excel2LaTeX from sheet 'correct'
\begin{table}[htbp]
\centering
\caption{Add caption}
\begin{tabular}{lrlrrl}
    (1)   &       & $P\rightarrow   Q$ &       &       & $\mathbf{P}$ \\
    (2)   &       & $ \neg T$ &       &       & $\mathbf{P}$ \\
    (3)   &       & $Q \rightarrow T$ &       &       & $\mathbf{P}$ \\
    (4)   &       & $S\vee W\rightarrow  Q$ &       &       & $\mathbf{P}$ \\
    (5)   &       & \multicolumn{1}{r|}{} & \multicolumn{1}{l}{$P\vee (R\wedge S)$} &       & $\mathbf{H}$ \bigstrut[b]\\
    \cline{4-5}    (6)   &       & \multicolumn{1}{r|}{} & \multicolumn{1}{r|}{} & \multicolumn{1}{l}{$P$} & $\mathbf{H}$ \bigstrut\\
    \cline{5-5}    (7)   &       & \multicolumn{1}{r|}{} & \multicolumn{1}{r|}{} & \multicolumn{1}{l}{$Q$} & $\mathbf{E}\rightarrow 1, 6$ \bigstrut[t]\\
    &       & \multicolumn{1}{r|}{} &       &       &  \\
    (8)   &       & \multicolumn{1}{r|}{} & \multicolumn{1}{r|}{} & \multicolumn{1}{l}{$R\wedge  S$} & $\mathbf{H}$ \bigstrut[b]\\
    \cline{5-5}    (9)   &       & \multicolumn{1}{r|}{} & \multicolumn{1}{r|}{} & \multicolumn{1}{l}{$S$} & $\mathbf{E} \wedge 8$ \bigstrut[t]\\
    (10)  &       & \multicolumn{1}{r|}{} & \multicolumn{1}{r|}{} & \multicolumn{1}{l}{$S\vee  W$} & $\mathbf{I} \vee 9$ \\
    (11)  &       & \multicolumn{1}{r|}{} & \multicolumn{1}{r|}{} & \multicolumn{1}{l}{$Q$} & $\mathbf{E} \rightarrow 4, 10$ \\
    (12)  &       & \multicolumn{1}{r|}{} & \multicolumn{1}{l}{$Q$} &       & $\mathbf{E} \vee 5,7,11$ \\
    (13)  &       & \multicolumn{1}{r|}{} & \multicolumn{1}{l}{$T$} &       & $\mathbf{E} \rightarrow 3, 12$ \\
    (14)  &       & \multicolumn{1}{r|}{} & \multicolumn{1}{l}{$ \neg T$} &       & $\mathbf{it} \; 2$ \\
    (15)  &       & $ \neg (P\vee (R \wedge S))$ &       &       & $\mathbf{I} \neg\; 5,13,14$ \\
\end{tabular}%
\label{tab:addlabel}%
\end{table}%        
\end{document}
egreg Sep 27 2020 at 23:01

A terceira e a quarta colunas parecem ter largura fixa.

O código a seguir define a tabela sem espaço entre colunas, que é adicionado manualmente onde necessário (entre a primeira e a segunda colunas, entre a segunda e a terceira colunas).

Uma macro auxiliar é definida para facilitar a entrada das células onde precisamos de uma linha vertical. Eu escolhi \blpor razões desconhecidas.

O espaço fino \,serve para afastar ligeiramente os termos da linha vertical.

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}


\begin{document}

\begin{flushleft}
\newcommand{\bl}[1]{\multicolumn{1}{|>{$}wl{6em}<{$}}{\,#1}} % ad hoc for the table
\renewcommand{\arraystretch}{1.2} % some more air to the table
\setlength{\tabcolsep}{0pt}

\begin{tabular}{
  r               % first column aligned on the right
  @{\hspace{3em}} % padding
  >{$}l<{$}       % left aligned math column
  @{\hspace{0.5em}}
  >{$}wl{6em}<{$} % left aligned math column (fixed width)
  >{$}wl{6em}<{$} % left aligned math column (fixed width)
  @{}
  l               % left aligned normal column
}
 (1) & P\to Q & & & \textbf{P} \\
 (2) & \lnot T & & & \textbf{P} \\
 (3) & Q\to T & & & \textbf{P} \\
 (4) & S\lor W \to Q & & & \textbf{P} \\
 (5) & & \bl{P\lor(R\land S)} & & \textbf{H} \\
\cline{3-4}
 (6) & & \bl{} & \bl{P} & \textbf{H} \\
\cline{4-4}
 (7) & & \bl{} & \bl{Q} & \textbf{E}$\to$ 1, 6 \\
     & & \bl{} \\
 (8) & & \bl{} & \bl{R\land S} & \textbf{H} \\
\cline{4-4}
 (9) & & \bl{} & \bl{S} & \textbf{E}$\land$ 8 \\
(10) & & \bl{} & \bl{S\lor W} & \textbf{I}$\lor$ 9 \\
(11) & & \bl{} & \bl{Q} & \textbf{E}$\to$ 4, 10 \\
(12) & & \bl{Q} & & \textbf{E}$\lor$ 5, 7, 11 \\
(13) & & \bl{T} & & \textbf{E}$\to$ 3, 12 \\
(14) & & \bl{\lnot T} & & \textbf{it} 12 \\
(15) & \lnot(P\lor(R\land S)) & & & \textbf{I}$\lnot$ 5, 13, 14
\end{tabular}
\end{flushleft}

\end{document}

Não é simples, mas também não é muito difícil.