Other module members#

Some other useful functions and other module members.

exception latexexpr_efficalc.LaTeXExpressionError(msg)#

Module exception class

latexexpr_efficalc.save_vars(what, fileName='/tmp/latexexprglobals.out')#

Saves globally defined variables from current session into a file. This simplifies working within one LaTeX document, but several python sessions

Parameters:
  • what (dict) – dictionary object (like locals() or globals()) to be saved

  • fileName (string) – name of file to save the variables

latexexpr_efficalc.load_vars(what, fileName='/tmp/latexexprglobals.out')#

Loads saved variables form a file into global namespace

Parameters:
  • what (dict) – dictionary object (like locals() or globals()) that will be updated with laded values

  • fileName (string) – name of file with saved variables

latexexpr_efficalc.to_latex_variable(name, what, command='def')#

Returns latex expression converting receiver to LaTeX variable using def, newcommand, or renewcommand LaTeX command

Parameters:
  • name (str) – LaTeX name (without initial \ symbol)

  • what (str) – string of the variable body

  • command (str) – LaTeX command to use (without initial \ symbol) [‘def’,’newcommand’,’renewcommand’]

>>> n,s = 'varName','some string content of the variable'
>>> print to_latex_variable(n,s)
\def\varName{some string content of the variable}
>>> print to_latex_variable(n,s,'newcommand')
\newcommand{\varName}{some string content of the variable}
>>> print to_latex_variable(n,s,'renewcommand')
\renewcommand{\varName}{some string content of the variable}