### Navigation

- index
- modules |
- next |
- previous |
- Combinatorics »
- Developer Tools »

# Output functions

These are the output functions for latexing partitions and tableaux.

AUTHORS:

- Mike Hansen (?): initial version
- Andrew Mathas (2013-02-14): Added support for displaying conventions and lines, and tableaux of skew partition, composition, and skew/composition/partition/tableaux tuple shape.

`sage.combinat.output.``tex_from_array`(array, with_lines=True)

  Return a latex string for a two dimensional array of partition, composition or skew composition shape

  INPUT:

  - `array` – a list of list

  - `with_lines` – a boolean (default: `True`)

      Whether to draw a line to separate the entries in the array.

  Empty rows are allowed; however, such rows should be given as `[None]` rather than `[]`.

  The array is drawn using either the English or French convention following `Tableaux.global_options`()`.

  See also

  `tex_from_array_tuple()`

  EXAMPLES:

      sage: from sage.combinat.output import tex_from_array
      sage: print tex_from_array([[1,2,3],[4,5]])
      {\def\lr#1{\multicolumn{1}{|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}}
      \raisebox{-.6ex}{$\begin{array}[b]{*{3}c}\cline{1-3}
      \lr{1}&\lr{2}&\lr{3}\\\cline{1-3}
      \lr{4}&\lr{5}\\\cline{1-2}
      \end{array}$}
      }
      sage: print tex_from_array([[1,2,3],[4,5]], with_lines=False)
      {\def\lr#1{\multicolumn{1}{@{\hspace{.6ex}}c@{\hspace{.6ex}}}{\raisebox{-.3ex}{$#1$}}}
      \raisebox{-.6ex}{$\begin{array}[b]{*{3}c}\\
      \lr{1}&\lr{2}&\lr{3}\\
      \lr{4}&\lr{5}\\
      \end{array}$}
      }
      sage: print tex_from_array([[1,2,3],[4,5,6,7],[8]])
      {\def\lr#1{\multicolumn{1}{|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}}
      \raisebox{-.6ex}{$\begin{array}[b]{*{4}c}\cline{1-3}
      \lr{1}&\lr{2}&\lr{3}\\\cline{1-4}
      \lr{4}&\lr{5}&\lr{6}&\lr{7}\\\cline{1-4}
      \lr{8}\\\cline{1-1}
      \end{array}$}
      }
      sage: print tex_from_array([[1,2,3],[4,5,6,7],[8]], with_lines=False)
      {\def\lr#1{\multicolumn{1}{@{\hspace{.6ex}}c@{\hspace{.6ex}}}{\raisebox{-.3ex}{$#1$}}}
      \raisebox{-.6ex}{$\begin{array}[b]{*{4}c}\\
      \lr{1}&\lr{2}&\lr{3}\\
      \lr{4}&\lr{5}&\lr{6}&\lr{7}\\
      \lr{8}\\
      \end{array}$}
      }
      sage: print tex_from_array([[None,None,3],[None,5,6,7],[8]])
      {\def\lr#1{\multicolumn{1}{|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}}
      \raisebox{-.6ex}{$\begin{array}[b]{*{4}c}\cline{3-3}
      &&\lr{3}\\\cline{2-4}
      &\lr{5}&\lr{6}&\lr{7}\\\cline{1-4}
      \lr{8}\\\cline{1-1}
      \end{array}$}
      }
      sage: print tex_from_array([[None,None,3],[None,5,6,7],[None,8]])
      {\def\lr#1{\multicolumn{1}{|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}}
      \raisebox{-.6ex}{$\begin{array}[b]{*{4}c}\cline{3-3}
      &&\lr{3}\\\cline{2-4}
      &\lr{5}&\lr{6}&\lr{7}\\\cline{2-4}
      &\lr{8}\\\cline{2-2}
      \end{array}$}
      }
      sage: print tex_from_array([[None,None,3],[None,5,6,7],[8]], with_lines=False)
      {\def\lr#1{\multicolumn{1}{@{\hspace{.6ex}}c@{\hspace{.6ex}}}{\raisebox{-.3ex}{$#1$}}}
      \raisebox{-.6ex}{$\begin{array}[b]{*{4}c}\\
      &&\lr{3}\\
      &\lr{5}&\lr{6}&\lr{7}\\
      \lr{8}\\
      \end{array}$}
      }
      sage: print tex_from_array([[None,None,3],[None,5,6,7],[None,8]], with_lines=False)
      {\def\lr#1{\multicolumn{1}{@{\hspace{.6ex}}c@{\hspace{.6ex}}}{\raisebox{-.3ex}{$#1$}}}
      \raisebox{-.6ex}{$\begin{array}[b]{*{4}c}\\
      &&\lr{3}\\
      &\lr{5}&\lr{6}&\lr{7}\\
      &\lr{8}\\
      \end{array}$}
      }
      sage: Tableaux.global_options(convention="french")
      sage: print tex_from_array([[1,2,3],[4,5]])
      {\def\lr#1{\multicolumn{1}{|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}}
      \raisebox{-.6ex}{$\begin{array}[t]{*{3}c}\cline{1-2}
      \lr{4}&\lr{5}\\\cline{1-3}
      \lr{1}&\lr{2}&\lr{3}\\\cline{1-3}
      \end{array}$}
      }
      sage: print tex_from_array([[1,2,3],[4,5]], with_lines=False)
      {\def\lr#1{\multicolumn{1}{@{\hspace{.6ex}}c@{\hspace{.6ex}}}{\raisebox{-.3ex}{$#1$}}}
      \raisebox{-.6ex}{$\begin{array}[t]{*{3}c}\\
      \lr{4}&\lr{5}\\
      \lr{1}&\lr{2}&\lr{3}\\
      \end{array}$}
      }
      sage: print tex_from_array([[1,2,3],[4,5,6,7],[8]])
      {\def\lr#1{\multicolumn{1}{|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}}
      \raisebox{-.6ex}{$\begin{array}[t]{*{4}c}\cline{1-1}
      \lr{8}\\\cline{1-4}
      \lr{4}&\lr{5}&\lr{6}&\lr{7}\\\cline{1-4}
      \lr{1}&\lr{2}&\lr{3}\\\cline{1-3}
      \end{array}$}
      }
      sage: print tex_from_array([[1,2,3],[4,5,6,7],[8]], with_lines=False)
      {\def\lr#1{\multicolumn{1}{@{\hspace{.6ex}}c@{\hspace{.6ex}}}{\raisebox{-.3ex}{$#1$}}}
      \raisebox{-.6ex}{$\begin{array}[t]{*{4}c}\\
      \lr{8}\\
      \lr{4}&\lr{5}&\lr{6}&\lr{7}\\
      \lr{1}&\lr{2}&\lr{3}\\
      \end{array}$}
      }
      sage: print tex_from_array([[None,None,3],[None,5,6,7],[8]])
      {\def\lr#1{\multicolumn{1}{|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}}
      \raisebox{-.6ex}{$\begin{array}[t]{*{4}c}\cline{1-1}
      \lr{8}\\\cline{1-4}
      &\lr{5}&\lr{6}&\lr{7}\\\cline{2-4}
      &&\lr{3}\\\cline{3-3}
      \end{array}$}
      }
      sage: print tex_from_array([[None,None,3],[None,5,6,7],[None,8]])
      {\def\lr#1{\multicolumn{1}{|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}}
      \raisebox{-.6ex}{$\begin{array}[t]{*{4}c}\cline{2-2}
      &\lr{8}\\\cline{2-4}
      &\lr{5}&\lr{6}&\lr{7}\\\cline{2-4}
      &&\lr{3}\\\cline{3-3}
      \end{array}$}
      }
      sage: print tex_from_array([[None,None,3],[None,5,6,7],[8]], with_lines=False)
      {\def\lr#1{\multicolumn{1}{@{\hspace{.6ex}}c@{\hspace{.6ex}}}{\raisebox{-.3ex}{$#1$}}}
      \raisebox{-.6ex}{$\begin{array}[t]{*{4}c}\\
      \lr{8}\\
      &\lr{5}&\lr{6}&\lr{7}\\
      &&\lr{3}\\
      \end{array}$}
      }
      sage: print tex_from_array([[None,None,3],[None,5,6,7],[None,8]], with_lines=False)
      {\def\lr#1{\multicolumn{1}{@{\hspace{.6ex}}c@{\hspace{.6ex}}}{\raisebox{-.3ex}{$#1$}}}
      \raisebox{-.6ex}{$\begin{array}[t]{*{4}c}\\
      &\lr{8}\\
      &\lr{5}&\lr{6}&\lr{7}\\
      &&\lr{3}\\
      \end{array}$}
      }
      sage: Tableaux.global_options.reset()

`sage.combinat.output.``tex_from_array_tuple`(a_tuple, with_lines=True)

  Return a latex string for a tuple of two dimensional array of partition, composition or skew composition shape.

  INPUT:

  - `a_tuple` – a tuple of lists of lists
  - `with_lines` – a boolean (default: `True`) Whether to draw lines to separate the entries in the components of `a_tuple`.

  See also

  `tex_from_array()` for the description of each array

  EXAMPLES:

      sage: from sage.combinat.output import tex_from_array_tuple
      sage: print tex_from_array_tuple([[[1,2,3],[4,5]],[],[[None,6,7],[None,8],[9]]])
      {\def\lr#1{\multicolumn{1}{|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}}
      \raisebox{-.6ex}{$\begin{array}[b]{*{3}c}\cline{1-3}
      \lr{1}&\lr{2}&\lr{3}\\\cline{1-3}
      \lr{4}&\lr{5}\\\cline{1-2}
      \end{array}$},\emptyset,\raisebox{-.6ex}{$\begin{array}[b]{*{3}c}\cline{2-3}
      &\lr{6}&\lr{7}\\\cline{2-3}
      &\lr{8}\\\cline{1-2}
      \lr{9}\\\cline{1-1}
      \end{array}$}
      }
      sage: print tex_from_array_tuple([[[1,2,3],[4,5]],[],[[None,6,7],[None,8],[9]]], with_lines=False)
      {\def\lr#1{\multicolumn{1}{@{\hspace{.6ex}}c@{\hspace{.6ex}}}{\raisebox{-.3ex}{$#1$}}}
      \raisebox{-.6ex}{$\begin{array}[b]{*{3}c}\\
      \lr{1}&\lr{2}&\lr{3}\\
      \lr{4}&\lr{5}\\
      \end{array}$},\emptyset,\raisebox{-.6ex}{$\begin{array}[b]{*{3}c}\\
      &\lr{6}&\lr{7}\\
      &\lr{8}\\
      \lr{9}\\
      \end{array}$}
      }
      sage: Tableaux.global_options(convention="french")
      sage: print tex_from_array_tuple([[[1,2,3],[4,5]],[],[[None,6,7],[None,8],[9]]])
      {\def\lr#1{\multicolumn{1}{|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}}
      \raisebox{-.6ex}{$\begin{array}[t]{*{3}c}\cline{1-2}
      \lr{4}&\lr{5}\\\cline{1-3}
      \lr{1}&\lr{2}&\lr{3}\\\cline{1-3}
      \end{array}$},\emptyset,\raisebox{-.6ex}{$\begin{array}[t]{*{3}c}\cline{1-1}
      \lr{9}\\\cline{1-2}
      &\lr{8}\\\cline{2-3}
      &\lr{6}&\lr{7}\\\cline{2-3}
      \end{array}$}
      }
      sage: print tex_from_array_tuple([[[1,2,3],[4,5]],[],[[None,6,7],[None,8],[9]]], with_lines=False)
      {\def\lr#1{\multicolumn{1}{@{\hspace{.6ex}}c@{\hspace{.6ex}}}{\raisebox{-.3ex}{$#1$}}}
      \raisebox{-.6ex}{$\begin{array}[t]{*{3}c}\\
      \lr{4}&\lr{5}\\
      \lr{1}&\lr{2}&\lr{3}\\
      \end{array}$},\emptyset,\raisebox{-.6ex}{$\begin{array}[t]{*{3}c}\\
      \lr{9}\\
      &\lr{8}\\
      &\lr{6}&\lr{7}\\
      \end{array}$}
      }

`sage.combinat.output.``tex_from_skew_array`(array, with_lines=False, align='b')

  This function creates latex code for a “skew composition” `array`. That is, for a two dimensional array in which each row can begin with an arbitrary number `None`‘s and the remaining entries could, in principe, be anything but probably should be strings or integers of similar width. A row consisting completely of `None`‘s is allowed.

  INPUTS:

  - `array` – The array
  - `with_lines` – (Default: `False`) If `True` lines are drawn, if `False` they are not
  - `align` – (Default: `'b'`) Determines the alignment on the latex array environments

  EXAMPLES:

      sage: array=[[None, 2,3,4],[None,None],[5,6,7,8]]
      sage: print sage.combinat.output.tex_from_skew_array(array)
      \raisebox{-.6ex}{$\begin{array}[b]{*{4}c}\\
      &\lr{2}&\lr{3}&\lr{4}\\
      &\\
      \lr{5}&\lr{6}&\lr{7}&\lr{8}\\
      \end{array}$}

### Navigation

- index
- modules |
- next |
- previous |
- Combinatorics »
- Developer Tools »