# Displaying and typesetting partitions

A partition can be viewed as a list or pretty-printed using ascii art. This works fine for me.

A partition can also be LaTeX-ed:

latex(Partition([2,2]))


produces

{\def\lr#1{\multicolumn{1}{|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}}
\raisebox{-.6ex}{$\begin{array}[b]{*{2}c}\cline{1-2} \lr{\phantom{x}}&\lr{\phantom{x}}\\\cline{1-2} \lr{\phantom{x}}&\lr{\phantom{x}}\\\cline{1-2} \end{array}$}
}


which typesets fine when inserted into a LaTeX document.

However:

1. When sagetex uses this, and produce the exakt same LaTex snippet, there are TeX errors (which does not stop the document from being typeset, but which are annoying):

(./part.sagetex.sout ./part.sagetex.sout:9: Illegal parameter number in definition of \r@@sageinline0.

2. The LaTex form of the partition does not render well with MathJax, so it is not displayed properly in a Jupyter notebook. I belive that the \cline is the culprit.

I hacked the LaTex output and got something which works well with sagetex, but since it uses the external package ytableu.sty, it does not work with MathJax.

if Partitions.options.convention == "English":
Partitions.options(latex=lambda mu: '\\ydiagram{%s}' % ','.join('%s'%m for m in mu._list))


Here is a kludge for skewpartitions:

def LatexSkew(S):
L = S._list[0]._list
M = S._list[1]._list
ut = '\\ydiagram{'
ut += ','.join([str(b) + '+' + str(a-b) for a,b in zip(L,M)] )
if len(L) > len(M):
ut += ',' + ','.join([str(a) for a in L[len(M):]] )
ut += '}'
return ut

if Partitions.options.convention == "English":
SkewPartitions.options(latex=LatexSkew)


So, at long last the question: how do you professionals typeset and display partitions?

edit retag close merge delete