Goto Chapter: Top 1 2 3 4 Ind
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 

2 LaTeX Generation
 2.1 LaTeX Generation Functions for GAP Objects
 2.2 Rendering LaTeX Strings
 2.3 Digraphs Integration

2 LaTeX Generation

2.1 LaTeX Generation Functions for GAP Objects

The introduction in 1.1 describes a powerful framework created in this package allowing for a standardised methodology to generate typesetting strings via the semantic features of objects.

This section describes the implementation of the framework for LaTeX, providing both the invaluable functionality to typeset a subset of GAP objects as LaTeX strings whilst also serving as an example of how the framework can be used for other typesetting languages.

It also provides some insight into the kinds of functions that would be expected from an implementation for a different language. A bare-boned example implementation for MathML is provided in 4.

Currently, the following types have explicit methods installed for LaTeX generation:

It should also be noted that Typeset (1.1-2) does fallback to the core library function ViewString (Reference: ViewString), which can be used for any types which do not require LaTeX-specific formatting to be renderable in math mode (e.g. floats).

2.1-1 GenLatexTmpl
‣ GenLatexTmpl( obj )( operation )

Returns: An Unpopulated LaTeX Format String

Generates a format string that represents the structural definition of the given GAP object obj in LaTeX. It contains no parameter values, and will need to be populated with the arguments representing the semantic values of the object, generated via GenArgs (1.2-1), before it can be rendered in a LaTeX environment.

2.1-2 CtblEntryLatex
‣ CtblEntryLatex( s )( function )

Returns: A String

Formats a string representation of an entry s returned by the undocumented function CharacterTableDisplayStringEntryDefault to include the LaTeX-specific bar environment for complex conjugates.

2.1-3 CtblLegendLatex
‣ CtblLegendLatex( data )( function )

Returns: A String

Generates a string representation of the mathematical substitutions data, generated by the undocumented function CharacterTableDisplayStringEntryDataDefault for entries within a character table.

2.1-4 GenNameAssocLetterLatex
‣ GenNameAssocLetterLatex( s )( function )

Returns: A String

Generates a string representation of the provided letter string s correctly subscripted with a LaTeX math-mode subscript environment.

2.1-5 FactoriseAssocWordLatex
‣ FactoriseAssocWordLatex( l, names, tseed )( function )

Returns: A Factorised String

Factorises the string representation of an assoc word in letter representation l, based on the return value from the undocumented function FindSubstringPowers, using the passed list of letters names, and a list of reserved numbers tseed (typically empty for initial calls).

This method is essentially a LaTeX-specific implementation of the the undocumented function NiceStringAssocWord.

2.2 Rendering LaTeX Strings

To aid users using Typeset (1.1-2), being able to view the results quickly in a variety of widely-used formats would help streamline the usage of the package. As such, a number of functions described below have been written to enable users to render the output LaTeX-renderable snippets in different fashions.

2.2-1 RenderLatex
‣ RenderLatex( str[, options] )( function )

Renders a given LaTeX string str in a LaTeX environment, providing a visual example of what the string would look like in a paper. By default, this involved creating a HTML file that includes the MathJax script, but the GAP option output can be passed to change the rendering method.

Currently implemented rendering methods are:

These functions can be called independently of RenderLatex, which serves only to be a more centralised rendering method for users.

2.2-2 PDFLatex
‣ PDFLatex( str )( function )

Renders a given LaTeX string str in a new PDF file, specifically via the pdflatex bash tool.

2.2-3 MathJax
‣ MathJax( str )( function )

Renders a given LaTeX string str in a HTML file, making use of the MathJax and TikzJax scripts.

2.2-4 Overleaf
‣ Overleaf( str )( function )

Renders a given LaTeX string str in a new Overleaf project, specifically via a URL-encoded snippet.

2.2-5 URIEncodeComponent
‣ URIEncodeComponent( raw )( function )

Returns: A Percent-Encoded String

Replaces reserved characters within a URI component raw as per RFC-3986.

2.2-6 NeedsLatexMathMode
‣ NeedsLatexMathMode( raw )( function )

Returns: A Boolean

Determines if the LaTeX snippet raw requires LaTeX's math mode to be rendered correctly.

‣ DEFAULT_LATEX_PREAMBLE( global variable )

Default LaTeX preamble string used for creating compilable .tex files from LaTeX snippets.

‣ DEFAULT_MATHJAX_TAGS( global variable )

Default HTML document and head tags used to create HTML files using MathJax to render LaTeX snippets.

‣ ALWAYS_UNESCAPED_CHARS( global variable )

String containing all of the characters that do not need to be percent-encoded within URI components, as per RFC-3986.

2.3 Digraphs Integration

digraphs is a powerful, widely-used packages, implementing helpful functionality to work with directed graphs amongst other objects. Due to it's popularity, and as a way to demonstrate how typeset can be integrated with external packages, the following functions have been implemented to allow directed graphs to be converted into LaTeX representations.

It should be noted that the conversion implemented here does use the output from DotDigraph (Digraphs: DotDigraph), which generates the DOT string representing a digraph. This is then used to either convert it to a tikz representation via the command-line tool dot2tex (using the GAP option digraphOut := "dot2tex"), or simply wrapping it up in a dot2tex environment provided by the LaTeX package dot2texi which will compile the wrapped DOT input into tikz during compilation of the LaTeX file itself.

While another method could be written to convert the internal representation of a directed graph directly into a tikzpicture, this would likely be incredibly convoluted and difficult, and may present numerous problems with edge positioning. Therefore, relying on dot2tex was chosen as the best approach.

‣ DEFAULT_DOT2TEX_OPTIONS( global variable )

Default command-line options passed to the dot2tex executable to convert dot strings.

2.3-2 Dot2Tex
‣ Dot2Tex( obj )( function )

Returns: A Tikz String

Executes dot2tex on the dot string representing a given digraph object obj.

 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 
Goto Chapter: Top 1 2 3 4 Ind

generated by GAPDoc2HTML