TransWikia.com

Two column listing separated by a vertical line, LaTeX

TeX - LaTeX Asked on July 30, 2021

I’d like to create something like this:

my notes

and I achieved similar results in LaTeX,

enter image description here

but nothing is alligned and there is too much white space over and under the text. Any solutions?

Here’s the code that I have used

begin{itemize}
    item[$impliedby$]
        begin{center} 
            begin{tabular}{p{5cm}|p{3.9cm}}
            $begin{array}{lr}
                    text{ipotesi: }            [x]_Rel ne [y]_Rel                   
                    text{tesi: ;;;;;}     [x]_Rel cap [y]_Rel = varnothing
            end{array}$
            &
            begin{lstlisting}
assunto che sia vera l'ipotesi,
supponiamo che la tesi non sia
vera. Dobbiamo arrivare ad una
contraddizione (dimostrazione
per assurdo)
            end{lstlisting}  
        end{tabular}
    end{center}
end{itemize}

One Answer

For a single shot you could do this

documentclass{article}

usepackage{amssymb,tabularx}

begin{document}

noindent
begin{tabularx}{linewidth}{@{}l|X@{}}
begin{tabular}[t]{@{}ll>{$}l<{$}@{}}
$Rightarrow$) & ipotesi: & [x]_{mathcal{R}} neq [y]_{mathcal{R}} 
               & tesi:    & [x]_{mathcal{R}} cap [y]_{mathcal{R}} = varnothing
end{tabular}
&
assunto che sia vera l'ipotesi,
supponiamo che la tesi non sia
vera. Dobbiamo arrivare ad una
contraddizione (dimostrazione
per assurdo)
end{tabularx}

end{document}

enter image description here

Alternative (using aligned instead of a nested tabular)

documentclass{article}

usepackage{amssymb,amsmath,tabularx}

begin{document}

noindent
begin{tabularx}{linewidth}{@{}l|X@{}}
$
begin{aligned}[t]
Rightarrow) quad & text{ipotesi:} && [x]_{mathcal{R}} neq [y]_{mathcal{R}} 
             & text{tesi:}    && [x]_{mathcal{R}} cap [y]_{mathcal{R}} = varnothing
end{aligned}
$
&
Assunto che sia vera l'ipotesi,
supponiamo che la tesi non sia
vera. Dobbiamo arrivare ad una
contraddizione (dimostrazione
per assurdo).
end{tabularx}

end{document}

(Basically the same output.)

Defining a macro/environment might be smart if you need this kind of construction more often.

Correct answer by campa on July 30, 2021

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