pygacity.pythontex.monkeypatches.reaction module

Monkeypatches for the Reaction class to add LaTeX output functionality.

pygacity.pythontex.monkeypatches.reaction.as_tex(self)[source]

Returns a LaTeX-formatted string of the reaction using the mhchem package’s ce{} command.

Returns:

LaTeX-formatted reaction string

Return type:

str

pygacity.pythontex.monkeypatches.reaction.stoichiometric_product_as_tex(self, base_string: str = 'a', parens: bool = False) str[source]

Formats a stoichiometric expression as a LaTeX string.

Parameters:
  • base_string (str) – base string to which empirical-formula subscripts are added

  • parens (bool, optional) – whether to enclose species in parentheses, default is False

Returns:

LaTeX formatted stoichiometric expression

Return type:

str

pygacity.pythontex.monkeypatches.reaction.sum_nu(self) Fraction[source]

Computes the sum of stoichiometric coefficients as a Fraction.

Returns:

sum of stoichiometric coefficients

Return type:

fr.Fraction