Ask Your Question
0

latex for Hasse diagram of poset not properly laid out

asked 2022-07-10 15:03:53 +0100

JTS gravatar image

updated 2022-07-10 21:37:58 +0100

The plot method on a poset displays the Hasse diagram in a satisfying way, with smaller elements below larger ones, as in this example:

B = Posets.BooleanLattice(4,use_subsets=False)
B.plot().save("B4.pdf")

On the other hand,

 latex(B)

produces

\begin{tikzpicture}
\definecolor{cv0}{rgb}{0.0,0.0,0.0}

 a bunch of omitted stuff


\Edge[lw=0.1cm,style={post, bend right,color=cv12v14,},](v12)(v14)  
\Edge[lw=0.1cm,style={post, bend right,color=cv13v15,},](v13)(v15)
\Edge[lw=0.1cm,style={post, bend right,color=cv14v15,},](v14)(v15)
%
\end{tikzpicture}

The resulting images are attached. The plot() version is above, the latex one is below. The latex version is certainly the correct digraph, but it is not laid out with larger elements above smaller ones. Why is that?C:\fakepath\B4Hasse.png

Edit: I tried the suggestion of FredericC and installed graphivz and dot2tex (in the OS); no change.

I also tried

 latex(B.plot())

which produces... some sort of latex

%% Creator: Matplotlib, PGF backend
%%
%% To include the figure in your LaTeX document, write
%%   \input{<filename>.pgf}
%%

when input as directed, the resulting diagram is identical to what plot() shows in a notebook, and what plot().save() produces. The only problem is that the output is extremely long. It is clear why the default method for latexing posets is to use tikz; shame that the layout is buggy.

The best option i found so far is to call Macaulay2 from sage; they produce correct tikz latex Hasse diagrams. One can do

 instr1 = 'needsPackage \"Posets\";'
 instr2 = 'texPoset( booleanLattice 4, SuppressLabels => false)'
 ut1=macaulay2.eval(instr1)
 ut2=macaulay2.eval(instr2)

This is a bit of a kludge, though.

edit retag flag offensive close merge delete

Comments

1

try after installing graphviz and dot2tex

FrédéricC gravatar imageFrédéricC ( 2022-07-10 18:27:05 +0100 )edit

and use then view(B)

FrédéricC gravatar imageFrédéricC ( 2022-07-11 09:02:57 +0100 )edit

to get the tikz code, one can use view(B, debug=True)

FrédéricC gravatar imageFrédéricC ( 2022-07-11 10:59:25 +0100 )edit
1

I believe that Sage will not detect a system version of dot2tex: you have to install it via Sage. (graphviz will come from the OS, as you have already done.) Running make dot2tex should work.

John Palmieri gravatar imageJohn Palmieri ( 2022-07-11 20:53:38 +0100 )edit

Or maybe faster: ./sage --pip install dot2tex.

John Palmieri gravatar imageJohn Palmieri ( 2022-07-11 20:54:32 +0100 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2022-07-16 16:39:16 +0100

JTS gravatar image

Adding dot2tex to the Sage installation, as suggested by FrédéricC and John Palmieri, did work for me and produces Hasse diagrams with correct layout, and non-verbose LaTeX.

One should

  1. Install graphviz to the OS (using the appropriate package manager)
  2. Install dot2tex to the Sage directory using ./sage --pip install dot2tex

This assumes that Sage is compiled from source; I don't know how one would add dot2tex to a distribution package of Sage.

Thank you FrédéricC and John Palmieri!

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2022-07-10 15:03:53 +0100

Seen: 505 times

Last updated: Jul 16 '22