### Install Ziamath Source: https://ziamath.readthedocs.io/en/latest/usage.html Install Ziamath using pip. It has dependencies on Ziafont and latex2mathml. ```bash pip install ziamath ``` -------------------------------- ### Load MathML Example 27 Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Loads and displays MathML content from ex27.xml. ```python loadmath('mml/ex27.xml') ``` ```xml x ``` -------------------------------- ### Fraction Example Source: https://ziamath.readthedocs.io/en/latest/examples.html Demonstrates creating fractions using the tag in MathML. ```MathML x + 1 y ``` -------------------------------- ### Load MathML Example 20 Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Loads and displays MathML content from ex20.xml. ```python loadmath('mml/ex20.xml') ``` ```xml x + y ``` -------------------------------- ### Load MathML Example 24 Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Loads and displays MathML content from ex24.xml. ```python loadmath('mml/ex24.xml') ``` ```xml f ( x ) = x 2 ``` -------------------------------- ### Load MathML Example 26 Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Loads and displays MathML content from ex26.xml. ```python loadmath('mml/ex26.xml') ``` ```xml ``` -------------------------------- ### Example 17 MathML Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Displays the MathML content for example 17. This is a direct inclusion of the XML file. ```xml a = c ``` -------------------------------- ### Example 19 MathML Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Displays the MathML content for example 19. This is a direct inclusion of the XML file. ```xml a = x ``` -------------------------------- ### Load MathML Example 29 Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Loads and displays MathML content from ex29.xml. ```python loadmath('mml/ex29.xml') ``` ```xml ``` -------------------------------- ### Load MathML Example 23 Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Loads and displays MathML content from ex23.xml. ```python loadmath('mml/ex23.xml') ``` ```xml 2 ``` -------------------------------- ### Load MathML Example 22 Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Loads and displays MathML content from ex22.xml. ```python loadmath('mml/ex22.xml') ``` ```xml a + b = c ``` -------------------------------- ### Load MathML Example 28 Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Loads and displays MathML content from ex28.xml. ```python loadmath('mml/ex28.xml') ``` ```xml x d x ``` -------------------------------- ### Example 7 MathML Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Displays the MathML content for example 7. This is a direct inclusion of the XML file. ```xml a + b = d ``` -------------------------------- ### Example 16 MathML Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Displays the MathML content for example 16. This is a direct inclusion of the XML file. ```xml a = b ``` -------------------------------- ### Example 1 MathML Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Displays the MathML content for example 1. This is a direct inclusion of the XML file. ```xml 1 ``` -------------------------------- ### Example 15 MathML Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Displays the MathML content for example 15. This is a direct inclusion of the XML file. ```xml a = 4 ``` -------------------------------- ### Example 11 MathML Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Displays the MathML content for example 11. This is a direct inclusion of the XML file. ```xml x = 4 ``` -------------------------------- ### Load MathML Example 21 Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Loads and displays MathML content from ex21.xml. ```python loadmath('mml/ex21.xml') ``` ```xml π × r 2 ``` -------------------------------- ### Example 2 MathML Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Displays the MathML content for example 2. This is a direct inclusion of the XML file. ```xml 1 + 2 ``` -------------------------------- ### Example 18 MathML Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Displays the MathML content for example 18. This is a direct inclusion of the XML file. ```xml a = d ``` -------------------------------- ### Example 5 MathML Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Displays the MathML content for example 5. This is a direct inclusion of the XML file. ```xml a + b ``` -------------------------------- ### Load MathML Example 25 Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Loads and displays MathML content from ex25.xml. ```python loadmath('mml/ex25.xml') ``` ```xml Σ i = 1 n x i ``` -------------------------------- ### Table Example Source: https://ziamath.readthedocs.io/en/latest/examples.html Demonstrates creating a simple table structure using and / tags in MathML. ```MathML x y z ``` -------------------------------- ### Example 10 MathML Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Displays the MathML content for example 10. This is a direct inclusion of the XML file. ```xml x = 3 ``` -------------------------------- ### Superscript Example Source: https://ziamath.readthedocs.io/en/latest/examples.html Demonstrates the use of the tag for superscripts in MathML. ```MathML x 2 ``` -------------------------------- ### Example 13 MathML Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Displays the MathML content for example 13. This is a direct inclusion of the XML file. ```xml a = 2 ``` -------------------------------- ### Example 6 MathML Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Displays the MathML content for example 6. This is a direct inclusion of the XML file. ```xml a + b = c ``` -------------------------------- ### Example 14 MathML Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Displays the MathML content for example 14. This is a direct inclusion of the XML file. ```xml a = 3 ``` -------------------------------- ### Example 12 MathML Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Displays the MathML content for example 12. This is a direct inclusion of the XML file. ```xml a = 1 ``` -------------------------------- ### Example 8 MathML Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Displays the MathML content for example 8. This is a direct inclusion of the XML file. ```xml x = 1 ``` -------------------------------- ### Example 9 MathML Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Displays the MathML content for example 9. This is a direct inclusion of the XML file. ```xml x = 2 ``` -------------------------------- ### MathML Matrix Example Source: https://ziamath.readthedocs.io/en/latest/test.html This MathML example demonstrates the creation of nested matrices using the 'mtable' and 'mtr' elements. It's useful for testing the rendering of tabular mathematical structures. ```mathml ( ( a b c d ) ( e f g h ) 0 ( i j k l ) ) ``` -------------------------------- ### Example 3 MathML Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Displays the MathML content for example 3. This is a direct inclusion of the XML file. ```xml 1 + 2 = 3 ``` -------------------------------- ### Example 4 MathML Source: https://ziamath.readthedocs.io/en/latest/_sources/test.rst.txt Displays the MathML content for example 4. This is a direct inclusion of the XML file. ```xml 1 + 2 = 4 ``` -------------------------------- ### Render Schrödinger Equation with Latex Source: https://ziamath.readthedocs.io/en/latest/examples.html Example of rendering the time-dependent Schrödinger equation using the zm.Latex function. ```Python zm.Latex(r'i \hbar \frac{\partial}{\partial t}\Psi(\mathbf{r},t) = \hat H \Psi(\mathbf{r},t)') ``` -------------------------------- ### Render Quadratic Formula with Latex Source: https://ziamath.readthedocs.io/en/latest/examples.html Example of rendering the quadratic formula using the zm.Latex function. ```Python zm.Latex(r'x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}') ``` -------------------------------- ### Boxed Enclosure Example Source: https://ziamath.readthedocs.io/en/latest/examples.html Shows how to enclose an expression in a box using in MathML. ```MathML a2 + b2 ``` -------------------------------- ### Math Background Example Source: https://ziamath.readthedocs.io/en/latest/examples.html Shows how to set the background color of a MathML element using the mathbackground attribute. ```MathML a + b c ``` -------------------------------- ### Render Tsiolkovsky Rocket Equation with Latex Source: https://ziamath.readthedocs.io/en/latest/examples.html Example of rendering the Tsiolkovsky rocket equation using the zm.Latex function. ```Python zm.Latex(r'\Delta v = v_e \, \ln \frac{m_0}{m_f} = I_{sp} \, g_0 \, \ln \frac{m_0}{m_f}') ``` -------------------------------- ### Strikeout Enclosure Example Source: https://ziamath.readthedocs.io/en/latest/examples.html Demonstrates using strikeout notation with in MathML. ```MathML 1 a2 + b2 ``` -------------------------------- ### N-root Example Source: https://ziamath.readthedocs.io/en/latest/examples.html Illustrates the usage of the tag for n-th roots in MathML. ```MathML x n ``` -------------------------------- ### Square Root Example Source: https://ziamath.readthedocs.io/en/latest/examples.html Shows how to represent a square root using the tag in MathML. ```MathML x ``` -------------------------------- ### Overline Example Source: https://ziamath.readthedocs.io/en/latest/examples.html Shows how to add an overline to an expression using the tag in MathML. ```MathML x + y + z ``` -------------------------------- ### Fenced Expression Example Source: https://ziamath.readthedocs.io/en/latest/examples.html Illustrates creating a fenced expression using the tag in MathML. ```MathML a b c ``` -------------------------------- ### Text Color Example Source: https://ziamath.readthedocs.io/en/latest/examples.html Illustrates setting the color of text within a MathML expression using the mathcolor attribute. ```MathML e 2 x + 1 ``` -------------------------------- ### MathML with Underbrace and Overbrace Source: https://ziamath.readthedocs.io/en/latest/test.html This MathML example showcases the use of underbrace and overbrace to denote groupings and counts of elements. It's useful for testing complex mathematical notation rendering. ```mathml { ( a , ... , a k a 's , ( b , ... , b b 's k + elements } ``` -------------------------------- ### Render LaTeX in display mode Source: https://ziamath.readthedocs.io/en/latest/_sources/usage.rst.txt LaTeX math is drawn in display (block) mode by default. This example explicitly shows display mode. ```python zm.Latex(r'\sum_a^b', inline=False) # Default display mode ``` -------------------------------- ### Configure Math Style Options Source: https://ziamath.readthedocs.io/en/latest/options.html Shows how to set global configuration options for math style, including font path, variant, font size, color, and background. These can be overridden by arguments to `zm.Math` or `zm.Latex`. ```python zm.config.math.mathfont # Path to math font file zm.config.math.variant # 'serif', 'sans', 'bold', 'script', etc. zm.config.math.fontsize # size in points zm.config.math.color = 'black' # css-supported color zm.config.math.background = 'none' # css-supported color ``` -------------------------------- ### Configure Text Style Options Source: https://ziamath.readthedocs.io/en/latest/options.html Demonstrates setting global configuration parameters for the default style of plain text in `zm.Text` instances, including font, variant, font size, color, and line spacing. ```python zm.config.text.textfont # Path to font file zm.config.text.variant # 'serif', 'sans', 'bold', 'script', etc. zm.config.text.fontsize # size in points zm.config.text.color # css-supported color zm.config.text.linespacing # Line spacing multiplier ``` -------------------------------- ### Reset Equation Numbering Source: https://ziamath.readthedocs.io/en/latest/usage.html Reset the equation numbering sequence to a specific starting number using ziamath.reset_numbering(). ```python zm.reset_numbering(10) zm.Latex('c = a + b') ``` -------------------------------- ### Run Ziamath from Command Line with Input File Source: https://ziamath.readthedocs.io/en/latest/options.html Executes Ziamath from the command line, specifying an input file containing math expressions (MathML or Latex). ```bash python -m ziamath inputfile.txt ``` -------------------------------- ### Process MathML with ziamath.zmath.Math Source: https://ziamath.readthedocs.io/en/latest/_sources/usage.rst.txt Create a Math object by providing a MathML string. In Jupyter notebooks, the Math instance renders directly in the output. ```python import ziamath as zm eqn = zm.Math(''' x 2 ''') eqn ``` -------------------------------- ### Get SVG XML ElementTree Source: https://ziamath.readthedocs.io/en/latest/usage.html Retrieve the SVG representation of a Math object as an XML ElementTree object using the svgxml() method. ```python eqn.svgxml() ``` -------------------------------- ### MathML Limit with Stirling's Approximation Source: https://ziamath.readthedocs.io/en/latest/test.html Shows a MathML representation of a limit, specifically demonstrating Stirling's approximation for factorials. This tests the rendering of limits, fractions, square roots, and powers. ```MathML lim n+ 2πn n! (ne) n = 1 ``` -------------------------------- ### Get SVG from Math Object Source: https://ziamath.readthedocs.io/en/latest/usage.html Obtain the raw SVG string representation of a Math object. This is useful for displaying equations in web contexts or for further processing. ```python eqn.svg()[:80] # Only show first 80 characters... ``` -------------------------------- ### Config Class Source: https://ziamath.readthedocs.io/en/latest/api.html Represents global configuration options for Ziamath. ```APIDOC ## ziamath.config.Config ### Description Global configuration options for Ziamath. ### Parameters - **math** (~ziamath.config.MathStyle) - Math style configuration. Defaults to factory. - **text** (~ziamath.config.TextStyle) - Text style configuration. Defaults to factory. - **minsizefraction** (float) - Base size for text such as subscripts and superscripts. Defaults to 0.3. - **debug** (~ziamath.config.DebugConfig) - Debug mode configuration. Defaults to factory. - **numbering** (~ziamath.config.NumberingStyle) - Equation numbering style configuration. Defaults to factory. - **svg2** (bool) - Use SVG2.0. Disable for better browser compatibility, at the expense of SVG size. - **precision** (int) - SVG decimal precision for coordinates. - **decimal_separator** (str) - Use '.' or ',' as decimal separator (only affects Latex math). Affects Latex math. ``` -------------------------------- ### Display MathML with Box Notation Source: https://ziamath.readthedocs.io/en/latest/_sources/examples.rst.txt Renders MathML with enclosure using box notation (). ```xml 1 ``` -------------------------------- ### Load MathML from XML Source: https://ziamath.readthedocs.io/en/latest/_sources/examples.rst.txt Loads MathML content from an XML file using the ziamath library. Ensure the XML file path is correct. ```python import ziamath as zm def loadmath(fname): with open(fname, 'r') as f: xml = f.read() return zm.Math(xml) ``` -------------------------------- ### Display MathML with Fractions Source: https://ziamath.readthedocs.io/en/latest/_sources/examples.rst.txt Renders MathML containing fractions (). ```xml 1 2 ``` -------------------------------- ### Run Ziamath from Command Line Reading Stdin Source: https://ziamath.readthedocs.io/en/latest/options.html Pipes math expressions (e.g., Latex) to the Ziamath command-line interface via standard input. ```bash echo "x^2 + y^2" | python -m ziamath ``` -------------------------------- ### Render next equation with automatic numbering Source: https://ziamath.readthedocs.io/en/latest/_sources/usage.rst.txt Demonstrates sequential automatic numbering. The second equation 'b = 2' will be numbered sequentially after 'a = 1'. ```python zm.Latex('b = 2') ``` -------------------------------- ### ziamath.config.Config Class Source: https://ziamath.readthedocs.io/en/latest/_sources/api.rst.txt Manages configuration settings for Ziamath. The `:members:` directive includes all public methods and attributes of this class. ```APIDOC ## Class: ziamath.config.Config ### Description This class provides functionality for managing and accessing the configuration parameters of the Ziamath library. ### Members All public members (methods and attributes) of the `ziamath.config.Config` class are documented here. ``` -------------------------------- ### Render Expression with Fractional Exponent Source: https://ziamath.readthedocs.io/en/latest/test.html Displays a MathML expression with a fractional exponent. ```MathML x + y 2 k + 1 ``` -------------------------------- ### Enable automatic equation numbering Source: https://ziamath.readthedocs.io/en/latest/_sources/usage.rst.txt Enable automatic sequential numbering of equations by setting 'autonumber' to True in the configuration. Subsequent equations will be numbered sequentially. ```python zm.config.numbering.autonumber = True zm.Latex('a = 1') ``` -------------------------------- ### Display MathML with Tables Source: https://ziamath.readthedocs.io/en/latest/_sources/examples.rst.txt Renders MathML containing tables (). ```xml 1 2 3 4 ``` -------------------------------- ### Display MathML with Superscripts and Subscripts Source: https://ziamath.readthedocs.io/en/latest/_sources/examples.rst.txt Renders MathML containing superscripts and subscripts (, , ). ```xml x 2 ``` -------------------------------- ### Render Complex Expression with Binomial and Fractions Source: https://ziamath.readthedocs.io/en/latest/test.html Displays a complex MathML expression involving binomial coefficients and fractions. ```MathML ( p 2 ) x 2 y p - 2 - 1 1 - x 1 1 - x 2 ``` -------------------------------- ### Display MathML with Diagonal Strike Notation Source: https://ziamath.readthedocs.io/en/latest/_sources/examples.rst.txt Renders MathML with enclosure using up and down diagonal strike notation (). ```xml 1 ``` -------------------------------- ### Display MathML with Background Attribute Source: https://ziamath.readthedocs.io/en/latest/_sources/examples.rst.txt Renders MathML with background color specified using the 'mathbackground' attribute. ```xml x ``` -------------------------------- ### Render Fraction with Division Source: https://ziamath.readthedocs.io/en/latest/test.html Displays a MathML fraction involving division in the denominator. ```MathML a b / 2 ``` -------------------------------- ### Draw MathML Equation Source: https://ziamath.readthedocs.io/en/latest/usage.html Process and draw a MathML element using the ziamath.zmath.Math class. Instantiate by providing a MathML string. ```python import ziamath as zm eqn = zm.Math(''' x 2 ''') eqn ``` -------------------------------- ### Render MathML to SVG Source: https://ziamath.readthedocs.io/en/latest/index.html Use the `Math` class to render MathML expressions. Ensure the MathML is correctly formatted. ```python import ziamath as zm zm.Math( ''' y = f ( x ) ''') ``` -------------------------------- ### Enable Automatic Equation Numbering Source: https://ziamath.readthedocs.io/en/latest/usage.html Enable sequential automatic numbering of equations by setting ziamath.config.numbering.autonumber to True. ```python zm.config.numbering.autonumber = True ``` ```python zm.Latex('a = 1') ``` ```python zm.Latex('b = 2') ``` -------------------------------- ### Render Binomial Coefficient with Division Source: https://ziamath.readthedocs.io/en/latest/test.html Displays a MathML binomial coefficient with a division in the lower part. ```MathML ( n k / 2 ) ``` -------------------------------- ### Render mixed math and text with ziamath.zmath.Text Source: https://ziamath.readthedocs.io/en/latest/_sources/usage.rst.txt Render a string containing both plain text and math expressions (inline $..$ and display $$..$$) into a single SVG. Different fonts can be specified for text and math. ```python zm.Text( r'''The volume of a sphere is $V = \frac{4}{3}\pi r^3$ or in terms of diameter, $ V = \frac{\pi d^3}{6}$. ''', halign='center') ``` -------------------------------- ### Render Continued Fraction Source: https://ziamath.readthedocs.io/en/latest/test.html Displays a MathML representation of a continued fraction. ```MathML a 0 + 1 a 1 + 1 a 2 + 1 a 3 + 1 a 4 ``` -------------------------------- ### Power Tower Notation in MathML Source: https://ziamath.readthedocs.io/en/latest/test.html Illustrates a power tower (tetration) using MathML. This notation is used for repeated exponentiation. ```mathml 2 2 2 x ``` -------------------------------- ### Definite Integral in MathML Source: https://ziamath.readthedocs.io/en/latest/test.html Represents a definite integral from 1 to x of dt/t using MathML. This demonstrates integral notation with limits. ```mathml 1 x dt t ``` -------------------------------- ### Display MathML with Over/Under elements Source: https://ziamath.readthedocs.io/en/latest/_sources/examples.rst.txt Renders MathML containing over () and under () elements. ```xml x ``` -------------------------------- ### Partial Differential Equation in MathML Source: https://ziamath.readthedocs.io/en/latest/test.html Represents a partial differential equation using MathML. This snippet demonstrates the use of fractions, superscripts, and Greek letters. ```mathml ( 2 x 2 + 2 y 2 ) | φ ( x + i y ) | 2 = 0 ``` -------------------------------- ### Display MathML with N-root Source: https://ziamath.readthedocs.io/en/latest/_sources/examples.rst.txt Renders MathML containing an N-root (). ```xml 3 27 ``` -------------------------------- ### Render Mixed Math and Text Source: https://ziamath.readthedocs.io/en/latest/usage.html Use ziamath.zmath.Text to render a combination of plain text and mathematical expressions within a single SVG element. Inline math uses $..$ and display math uses $$..$$ ```python zm.Text( r'''The volume of a sphere is $V = \frac{4}{3}\pi r^3$ or in terms of diameter, $ V = \frac{\pi d^3}{6}$. ''', halign='center') ``` -------------------------------- ### Summation over Primes in MathML Source: https://ziamath.readthedocs.io/en/latest/test.html Represents a sum over prime numbers 'p' of f(p) using MathML. This demonstrates summation with a condition on the index. ```mathml p prime f ( p ) = t > 1 f ( t ) d π ( t ) ``` -------------------------------- ### Display Latex Expression with Default Decimal Separator Source: https://ziamath.readthedocs.io/en/latest/options.html Demonstrates the default rendering of a comma in a Latex expression when the decimal separator is not explicitly configured. ```python zm.Latex('1,2') ``` -------------------------------- ### Display MathML with Fenced expressions Source: https://ziamath.readthedocs.io/en/latest/_sources/examples.rst.txt Renders MathML containing fenced expressions (). ```xml 1 ``` -------------------------------- ### Draw LaTeX Equation Source: https://ziamath.readthedocs.io/en/latest/usage.html Render a math expression in LaTeX format by creating a Math object using ziamath.zmath.Latex(). Use raw strings for LaTeX commands. ```python zm.Latex(r'c = \pm \sqrt{a^2 + b^2}') ``` -------------------------------- ### Display MathML with Square Root Source: https://ziamath.readthedocs.io/en/latest/_sources/examples.rst.txt Renders MathML containing a square root (). ```xml 2 ``` -------------------------------- ### Render x^2 y^2 Source: https://ziamath.readthedocs.io/en/latest/test.html Displays a basic MathML expression for x squared times y squared. ```MathML x 2 y 2 ``` -------------------------------- ### Configure Column Width for Numbering Source: https://ziamath.readthedocs.io/en/latest/usage.html Set the column width for equation numbering using ziamath.config.numbering.columnwidth. Supports standard LaTeX units. ```python zm.config.numbering.columnwidth = '6.5in' ``` -------------------------------- ### Display MathML with Color Attribute Source: https://ziamath.readthedocs.io/en/latest/_sources/examples.rst.txt Renders MathML with text color specified using the 'mathcolor' attribute. ```xml x ``` -------------------------------- ### MathML Nested Superscripts Source: https://ziamath.readthedocs.io/en/latest/test.html Illustrates MathML with nested superscripts, where both the base and exponent have their own superscripts and subscripts. This tests advanced rendering of exponents. ```MathML x y b a z c d ```