Ask Your Question
1

Display the Young lattice using Sage and Latex

asked 2016-12-07 19:13:58 +0100

Gonneman gravatar image

updated 2017-01-05 22:22:21 +0100

FrédéricC gravatar image

Hi everyone,

I'm trying to follow http://doc.sagemath.org/html/en/thema... to generate pictures of Young's lattice. Unfortunately I seem to be getting LaTeX code which won't compile.

I'm using Sage 7.4 (run locally not on the cloud), pdfTeX, Version 3.1415926-2.5-1.40.14 and I have the TKZ packages installed. Running sage locally or on the cloud seems to generate the same LaTeX output. I get the same errors on 2 different computers, both running OpenSUSE 42.1. I've tried generating the LaTeX code using the sagecloud, but as far as I can tell it generates the same source code and I can't compile it.

The code I input is:

level = 6
elements = [b for n in range(level) for b in Partitions(n)]
ord = lambda x,y: y.contains(x)
Y = Poset((elements,ord), facade=True)
H = Y.hasse_diagram()
view(H)  # optional - dot2tex graphviz

I'd like to attach error logs and the latex source code generated by "latex(H)", but apparently I do not have enough karma to do so. The error messages are basically many repetitions of the following snippet.

! Illegal parameter number in definition of \cmdGR@vertex@L.
<to be read again> 
                   1
l.136 }$},x=1.0389cm,y=1.8082cm]{v1}

You meant to type ## instead of #, right?
Or maybe a } was forgotten somewhere earlier, and things
are all screwed up? I'm going to assume that you meant ##.

Edit: fidbc had the excellent idea of uploading my error log and latex source to pastebin, so here they are.

I am trying to compile the LaTeX code with the following packages: "tikz", "tkz-graph", "tkz-berge", "tkz-arith" and for tikz I am also loading the "arrows" and "shapes" libraries. Am I missing any necessary libraries?

edit retag flag offensive close merge delete

Comments

1

Generated TikZ code works for me. Have you tried including the TikZ package in the LaTeX document preamble (\usepackage{tikz})? Maybe posting a link to the code uploaded to some other site would be useful? Eg pastebin.

fidbc gravatar imagefidbc ( 2016-12-08 05:16:34 +0100 )edit

Excellent advice regarding pastebin! I've edited the question accordingly.

Gonneman gravatar imageGonneman ( 2016-12-08 12:14:12 +0100 )edit

It seems like the error arises from the labels of the nodes in the diagram, not entirely sure what is going on. Also, it should be noted that the LaTeX string returned by latex(H) when executed in cloud.sagemath is different, please see here. That output seems to compile without issues.

fidbc gravatar imagefidbc ( 2016-12-08 19:13:33 +0100 )edit

The latex code you linked to compiles for me too. How odd, I was certain cloud.sagemath did not produce code that worked for me, yet now it does (both your code and what cloud.sagemath produce for me, work).

I wonder why my local installation of sage produces different LaTeX code.

Gonneman gravatar imageGonneman ( 2016-12-08 21:29:29 +0100 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2016-12-09 10:20:01 +0100

Sébastien gravatar image

updated 2016-12-09 21:49:42 +0100

In my optional package see also #20343, I wrote a module to deal with tikzpictures:

sage: from slabbe import TikzPicture
sage: path_to_file = TikzPicture.from_poset(Y).pdf()     # requires dot2tex + graphviz
sage: path_to_file = TikzPicture.from_graph(H).pdf()     # requires dot2tex + graphviz

which open automatically the pdf in a viewer like view does. You may also create a TikzPicture object from any tikzpicture string without using dot2tex. For example:

sage: g = graphs.PetersenGraph()
sage: s = latex(g)
sage: t = TikzPicture(s, usepackage=['tkz-graph'])
sage: t.pdf()

I intend to polish it a little bit more during the next year, maybe make it more general, before proposing its inclusion into Sage.

edit flag offensive delete link more

Comments

Looks like this is the package that generates the TikZ code at cloud.sagemath, nice! Just as a side comment, this seems to require the dot2tex package installed. The command sage -pip slabbe did not work for me to install the package. To install:

sage -sh
pip install dot2tex slabbe

Then the code above works.

fidbc gravatar imagefidbc ( 2016-12-09 18:17:48 +0100 )edit

You are right, from_poset and from_graph both require dot2tex and graphviz installed. I edited my answer accordingly.

Sébastien gravatar imageSébastien ( 2016-12-09 21:48:56 +0100 )edit

Hi Sébastien. Thank you for the suggestion and sorry for my long silence. I'm currently travelling. I'll try out your suggestion once I'm back later this week!

Gonneman gravatar imageGonneman ( 2016-12-11 21:15:48 +0100 )edit

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: 2016-12-07 19:13:58 +0100

Seen: 941 times

Last updated: Dec 09 '16