2

I'm trying to export sagemath graphs of crystals (see the following command).

sage: crystals.Tableaux("A3", shape=[2,1]).latex_file("/tmp/a3-21.tex") 

I get the output as follows:

\documentclass{article}
        \usepackage[x11names, rgb]{xcolor}
        \usepackage[utf8]{inputenc}
        \usepackage{tikz}
        \usetikzlibrary{snakes,arrows,shapes}
        \usepackage{amsmath}
        \usepackage[active,tightpage]{preview}
        \newenvironment{bla}{}{}
        \PreviewEnvironment{bla}
        \usepackage{tkz-graph}

        \begin{document}
        \begin{bla}\begin{tikzpicture}
        \useasboundingbox (0,0) rectangle (5.0cm,5.0cm); 
        \definecolor{cv0}{rgb}{0.0,0.0,0.0}
        \definecolor{cfv0}{rgb}{1.0,1.0,1.0}
        \definecolor{clv0}{rgb}{0.0,0.0,0.0}
        \definecolor{cv1}{rgb}{0.0,0.0,0.0}
        \definecolor{cfv1}{rgb}{1.0,1.0,1.0}
        \definecolor{clv1}{rgb}{0.0,0.0,0.0}
        \definecolor{cv2}{rgb}{0.0,0.0,0.0}
        \definecolor{cfv2}{rgb}{1.0,1.0,1.0}
        \definecolor{clv2}{rgb}{0.0,0.0,0.0}
        \definecolor{cv3}{rgb}{0.0,0.0,0.0}
        \definecolor{cfv3}{rgb}{1.0,1.0,1.0}
        \definecolor{clv3}{rgb}{0.0,0.0,0.0}
        \definecolor{cv4}{rgb}{0.0,0.0,0.0}
        \definecolor{cfv4}{rgb}{1.0,1.0,1.0}
        \definecolor{clv4}{rgb}{0.0,0.0,0.0}
        \definecolor{cv5}{rgb}{0.0,0.0,0.0}
        \definecolor{cfv5}{rgb}{1.0,1.0,1.0}
        \definecolor{clv5}{rgb}{0.0,0.0,0.0}
        \definecolor{cv6}{rgb}{0.0,0.0,0.0}
        \definecolor{cfv6}{rgb}{1.0,1.0,1.0}
        \definecolor{clv6}{rgb}{0.0,0.0,0.0}
        \definecolor{cv7}{rgb}{0.0,0.0,0.0}
        \definecolor{cfv7}{rgb}{1.0,1.0,1.0}
        \definecolor{clv7}{rgb}{0.0,0.0,0.0}
        \definecolor{cv0v1}{rgb}{0.0,0.0,0.0}
        \definecolor{cv0v3}{rgb}{0.0,0.0,0.0}
        \definecolor{cv1v2}{rgb}{0.0,0.0,0.0}
        \definecolor{cv2v5}{rgb}{0.0,0.0,0.0}
        \definecolor{cv3v4}{rgb}{0.0,0.0,0.0}
        \definecolor{cv4v6}{rgb}{0.0,0.0,0.0} 
        \definecolor{cv5v7}{rgb}{0.0,0.0,0.0}
        \definecolor{cv6v7}{rgb}{0.0,0.0,0.0}
        \Vertex[style=    
       {minimumsize=1.0cm,draw=cv0,fill=cfv0,text=clv0,shape=circle},
       LabelOut=false,L=\hbox{${\def\lr#1{\multicolumn{1}
       {|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}} 
       \raisebox{-.6ex}{$\begin{array}[b]{*{2}c}\cline{1-2}
       \lr{1}&\lr{1}\\\cline{1-2}\lr{2}\\\cline{1-1}\end{array}$}}$},
       x=1.792cm,y=0.0cm]{v0}
       \Vertex[style={minimum
       size=1.0cm,draw=cv1,fill=cfv1,text=clv1,shape=circle},
       LabelOut=false,L=\hbox{${\def\lr#1{\multicolumn{1}
       {|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}}
       \raisebox{-.6ex}{$\begin{array}[b]{*{2}c}\cline{1-2}
       \lr{1}&\lr{2}\\\cline{1-2}\lr{2}\\\cline{1-1}\end{array}$}}$},
       x=0.1894cm,y=1.2054cm]{v1}
       \Vertex[style={minimum size=1.0cm,draw=cv2,fill=cfv2,text=clv2,shape=circle},
       LabelOut=false,L=\hbox{${\def\lr#1{\multicolumn{1}
       {|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}}
       \raisebox{-.6ex}{$\begin{array}[b]{*{2}c}\cline{1-2}
       \lr{1}&\lr{3}\\\cline{1-2}\lr{2}\\\cline{1-1}\end{array}$}}$},
       x=0.0cm,y=3.1607cm]{v2}
       \Vertex[style={minimum size=1.0cm,draw=cv3,fill=cfv3,text=clv3,shape=circle},
       LabelOut=false, 
       L=\hbox{${\def\lr#1{\multicolumn{1}{|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}}
       \raisebox{-.6ex}{$\begin{array}[b]{*{2}c}\cline{1-2}
       \lr{1}&\lr{1}\\\cline{1-2}\lr{3}\\\cline{1-1}
       \end{array}$}}$},
       x=3.7751cm,y=0.2859cm]{v3}
       \Vertex[style={minimum size=1.0cm,draw=cv4,fill=cfv4,text=clv4,shape=circle},
       LabelOut=false,L=\hbox{${\def\lr#1{\multicolumn{1}
       {|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}} 
       \raisebox{-.6ex}{$\begin{array}[b]{*{2}c}\cline{1-2}
       \lr{1}&\lr{2}\\\cline{1-2}\lr{3}\\\cline{1-1}
       \end{array}$}}$},
       x=5.0cm,y=1.8124cm]{v4}
       \Vertex[style={minimum size=1.0cm,draw=cv5,fill=cfv5,text=clv5,shape=circle},
       LabelOut=false,L=\hbox{${\def\lr#1{\multicolumn{1}
       {|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}}
       \raisebox{-.6ex}{$\begin{array}[b]{*{2}c}\cline{1-2}
       \lr{1}&\lr{3}\\\cline{1-2}\lr{3}\\\cline{1-1}
       \end{array}$}}$},x=1.1305cm,y=4.7124cm]{v5}
       \Vertex[style={minimum size=1.0cm,draw=cv6,fill=cfv6,text=clv6,shape=circle},
       LabelOut=false,L=\hbox{${\def\lr#1{\multicolumn{1}
       {|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}}
       \raisebox{-.6ex}{$\begin{array}[b]{*{2}c}\cline{1-2}
       \lr{2}&\lr{2}\\\cline{1-2}\lr{3}\\\cline{1-1}
       \end{array}$}}$},
       x=4.6653cm,y=3.7847cm]{v6}
       \Vertex[style={minimum size=1.0cm,draw=cv7,fill=cfv7,text=clv7,shape=circle},
       LabelOut=false,L=\hbox{${\def\lr#1{\multicolumn{1}
       {|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}}
       \raisebox{-.6ex}{$\begin{array}[b]{*{2}c}\cline{1-2}
       \lr{2}&\lr{3}\\\cline{1-2}\lr{3}\\\cline{1-1}
       \end{array}$}}$},
       x=3.114cm,y=5.0cm]{v7}
       %
       \Edge[lw=0.1cm,style={post, bend right,color=cv0v1,},](v0)(v1)
       \Edge[lw=0.1cm,style={post, bend right,color=cv0v3,},](v0)(v3)
       \Edge[lw=0.1cm,style={post, bend right,color=cv1v2,},](v1)(v2)
       \Edge[lw=0.1cm,style={post, bend right,color=cv2v5,},](v2)(v5)
       \Edge[lw=0.1cm,style={post, bend right,color=cv3v4,},](v3)(v4)
       \Edge[lw=0.1cm,style={post, bend right,color=cv4v6,},](v4)(v6)
       \Edge[lw=0.1cm,style={post, bend right,color=cv5v7,},](v5)(v7)
       \Edge[lw=0.1cm,style={post, bend right,color=cv6v7,},](v6)(v7)
       %
       \end{tikzpicture}\end{bla}
       \end{document} 

But there is an error as like

ABD: EveryShipout initializing macros
Preview: Fontsize 10pt
! Illegal parameter number in definition of \cmdGR@vertex@L.
<to be read again>
                    1
1.55 }$},x=1.792cm,y-0.0cm}{v0} 
?

In fact, when I was trying to compile at the first time, the console showed:

Undefined control sequence 
1.50 \Vertex

So after searching this comment, I added the code

\usepackage{tkz-graph}.

But it doesn't still work. How can I get the crystal graph?

  • The output that Sage generates is obviously wrong. In particular the L= parameter of vertex has a problem with the array inside of it. I think this is because array is fragile (as it has an optional parameter). Is there any way you can influence this output? – Pieter van Oostrum Dec 8 '16 at 11:35
  • I used Sagemath Cloud to create a sage worksheet and then ran the command crystals.Tableaux("A3", shape=[2,1]).latex_file("MyFile.tex") . When I checked the output, it runs without any problems. Perhaps your versions of Sage and\or LaTeX aren't up to date? – DJP Dec 8 '16 at 15:52
  • That is probably because it generates a tikzpicture with nodes in it. However, the OP probably used the format=tkz_graph option, which produces a tkz-graph, where the node names cannot contain complicated math expressions. The output would then be nicer (if it would work). I think this is a bug that probably is an unintended consequence of the way crystals.Tableaux formats its nodes, and how tkz-graph uses these. I can give a recipe how to transform the output in something that works, if the OP is interested. This requires some editing on the output. – Pieter van Oostrum Dec 8 '16 at 16:22
  • @DJP I found how to export from Sagemath Cloud. In fact, this file is generated from Sage7.2 on Ubuntu14.04. But I want to use this on Windows system. Thank you. – Micheal C Dec 9 '16 at 5:02
  • 4
    I'm voting to close this question as off-topic because the issue was due to wrong export from Sage – egreg Jul 1 '17 at 11:06
2

One possibility is to install an optional Sagemath package dot2tex, something that one would do at the shell prompt as follows: sage -i dot2tex This package is installed on SageMathCloud (recently re-branded as CoCalc). See also a recent discussion here - in short, it is a Sagemath bug.

Not the answer you're looking for? Browse other questions tagged or ask your own question.