Format - Maple Help

Magma

 Format
 format a magma as text for inclusion in a document

 Calling Sequence Format( m ) Format( m, options )

Parameters

 m - a magma to format options - zero or more options of the form format = fmt or labels = lbls.

Options

 • The format option is used to specify the output format desired. Its value may be chosen from among those shown in the following table.

 text plain text, the default latex formatted as a LaTeX table html formatted as an HTML table mathml formatted as a MathML table wiki formatted as a MediaWiki table

 • Use the labels option to specify names for the members of the magma other than small integers. The value of the labels option must be either a string, or a list of strings.  If a string is provided, then its length must be equal to the order of the magma, and the individual characters in the string will be used as element names, in the order given.  If a list of strings is provided, then the number of its members must be equal to the order of the magma, and each string in the list will be used as element names, in the order given. You can use markup within these strings consistent with the output format chosen.  For example, a list of labels of the form [ "$a$", "$b$", "$c$" ] may be given for LaTeX output.

Description

 • The Format command formats a magma (as an operation table) to a string in any one of several supported formats.  This is meant to be a tool for including small magmas in documents such as papers, email or webpages.
 • The formatted magma is returned as a string of text formatted using the selected format. You can use the printf command (with the %s conversion specifier) to print the string.  Alternatively, the returned text may be written to a file.

Examples

 > $\mathrm{with}\left(\mathrm{Magma}\right):$

Create a small magma  with five members to be formatted.

 > $N≔5:$
 > $m≔\mathrm{RandomMagma}\left(N\right)$
 ${m}{≔}\left[\begin{array}{ccccc}{4}& {2}& {1}& {2}& {5}\\ {4}& {5}& {2}& {2}& {3}\\ {2}& {2}& {1}& {3}& {1}\\ {4}& {1}& {1}& {2}& {4}\\ {5}& {3}& {2}& {3}& {5}\end{array}\right]$ (1)

The default is to format the magma as plain text.

 > $\mathrm{printf}\left("%s\n",\mathrm{Format}\left(m\right)\right)$
 4 2 1 2 5  4 5 2 2 3  2 2 1 3 1  4 1 1 2 4  5 3 2 3 5
 > $\mathrm{printf}\left("%s\n",\mathrm{Format}\left(m,'\mathrm{format}'="text"\right)\right)$
 4 2 1 2 5  4 5 2 2 3  2 2 1 3 1  4 1 1 2 4  5 3 2 3 5

Use LaTeX to include the formatted magma in a paper or book.

 > $\mathrm{printf}\left("%s\n",\mathrm{Format}\left(m,'\mathrm{format}'='\mathrm{latex}'\right)\right)$
 \begin{smallmatrix}4&2&1&2&5\\ 4&5&2&2&3\\ 2&2&1&3&1\\ 4&1&1&2&4\\ 5&3&2&3&5 \end{smallmatrix}

Use HTML, MathML or MediaWiki for inclusion in a webpage.

 > $\mathrm{printf}\left("%s\n",\mathrm{Format}\left(m,'\mathrm{format}'='\mathrm{html}'\right)\right)$

42125
45223
22131
41124
53235
 > $\mathrm{printf}\left("%s\n",\mathrm{Format}\left(m,'\mathrm{format}'='\mathrm{mathml}'\right)\right)$
 4212545223221314112453235
 > $\mathrm{printf}\left("%s\n",\mathrm{Format}\left(m,'\mathrm{format}'='\mathrm{wiki}'\right)\right)$
 {| border="1" |- |4 || 2 || 1 || 2 || 5 |- |4 || 5 || 2 || 2 || 3 |- |2 || 2 || 1 || 3 || 1 |- |4 || 1 || 1 || 2 || 4 |- |5 || 3 || 2 || 3 || 5 |}

Display the magma using letters instead of small integers for its elements.

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$
 > $\mathrm{printf}\left("%s\n",\mathrm{Format}\left(m,'\mathrm{labels}'=\mathrm{Ι}\left("a".."z"\right)\left[1..N\right]\right)\right)$
 d b a b e  d e b b c  b b a c a  d a a b d  e c b c e
 > $\mathrm{printf}\left("%s\n",\mathrm{Format}\left(m,'\mathrm{format}'="latex",'\mathrm{labels}'=\mathrm{map}\left(\mathrm{Fence},\mathrm{Explode}\left(\mathrm{Ι}\left("a".."z"\right)\left[1..N\right]\right),"",""\right)\right)\right)$
 \begin{smallmatrix}$d$&$b$&$a$&$b$&$e$\\$d$&$e$&$b$&$b$&$c$\\$b$&$b$&$a$&$c$&$a$\\$d$&$a$&$a$&$b$&$d$\\$e$&$c$&$b$&$c$&$e$ \end{smallmatrix}

Compatibility

 • The Magma[Format] command was introduced in Maple 15.