TransWikia.com

Keeping indentation and left alignment consistent

TeX - LaTeX Asked by Miguel Garcia on December 24, 2020

I would need to reproduce a chart similar to the one in the image. I need to keep left alignment and indentation consistent, also the horizontal and vertical lines are important. Would appreciate any advice on this, maybe a toy example that shows the main ideas.

Thank you very much in advance.

le

2 Answers

If you try the following code, you will get a result quite similar to your example, although I probably misunderstood some symbols, but you will understand the essence of it.

Now from your question, I think you want to have a standard procedure for approaching a large project in a consistent manner.

I will tell you my recipe, because the important thing is how it was done.

1 This is obvious: use tabular

2 Built the table in Excel. (This is important, do not work directly with LaTeX code, you will see why later).

3 Use the Excel2laTex add-in. https://www.ctan.org/tex-archive/support/excel2latex

  1. Uncheck the bookmark package and Convert $ ^ _ options

5 Copy to the Clipboard and paste it into a bare LaTeX document with a set of required packages.

  1. Compile.

7 Correct the errors or make changes going to Excel and returning to LaTeX. This way gives you a very fast feedback, without the need to learn the little details of the packages (well, most of the time).

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)   &       & $Prightarrow   Q$ &       &       & $mathbf{P}$ 
        (2)   &       & $ rightharpoondown T$ &       &       & $mathbf{P}$ 
        (3)   &       & $Q rightarrow T$ &       &       & $mathbf{P}$ 
        (4)   &       & $Svee Wrightarrow  Q$ &       &       & $mathbf{P}$ 
        (5)   &       & multicolumn{1}{r|}{} & multicolumn{1}{l}{$Pvee (Rwedge 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}{$Rwedge  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}{$Svee  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(Pvee (R wedge S))$ &       &       & $mathbf{I} rightarrow 5,13,14$ 
    end{tabular}%
    label{tab:addlabel}%
end{table}%
    
end{document}

Total time spend: 30 min writing the table, 5 min getting the result.

I left some errors, try to correct them yourself using the described procedure, instead of editing the LaTeX code. Answer in the UPDATE, below.

excel enter image description here

UPDATE Corrected code, generated with the same procedure.

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)   &       & $Prightarrow   Q$ &       &       & $mathbf{P}$ 
    (2)   &       & $ neg T$ &       &       & $mathbf{P}$ 
    (3)   &       & $Q rightarrow T$ &       &       & $mathbf{P}$ 
    (4)   &       & $Svee Wrightarrow  Q$ &       &       & $mathbf{P}$ 
    (5)   &       & multicolumn{1}{r|}{} & multicolumn{1}{l}{$Pvee (Rwedge 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}{$Rwedge  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}{$Svee  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 (Pvee (R wedge S))$ &       &       & $mathbf{I} neg; 5,13,14$ 
end{tabular}%
label{tab:addlabel}%
end{table}%        
end{document}

Answered by Simon Dispa on December 24, 2020

The third and fourth columns seem to be set at fixed width.

The code below sets the table without intercolumn space, which is manually added where needed (between first and second columns, between second and third columns).

A helper macro is defined to ease inputting the cells where we need a vertical line. I chose bl for unknown reasons.

The thin space , is to slightly move the terms away from the vertical line.

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) & Pto Q & & & textbf{P} 
 (2) & lnot T & & & textbf{P} 
 (3) & Qto T & & & textbf{P} 
 (4) & Slor W to Q & & & textbf{P} 
 (5) & & bl{Plor(Rland 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{Rland S} & textbf{H} 
cline{4-4}
 (9) & & bl{} & bl{S} & textbf{E}$land$ 8 
(10) & & bl{} & bl{Slor 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(Plor(Rland S)) & & & textbf{I}$lnot$ 5, 13, 14
end{tabular}
end{flushleft}

end{document}

Not straightforward, but not too difficult either.

enter image description here

Answered by egreg on December 24, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP