diff --git a/pyxdsm/XDSM.py b/pyxdsm/XDSM.py index 392cd66..9fa63d0 100644 --- a/pyxdsm/XDSM.py +++ b/pyxdsm/XDSM.py @@ -117,7 +117,16 @@ def _label_to_spec(label, spec): class XDSM(object): - def __init__(self, use_sfmath=True): + def __init__(self, use_sfmath=True, optional_latex_packages=None): + """Initialize XDSM object + + Parameters + ---------- + use_sfmath : bool, optional + Whether to use the sfmath latex package, by default True + optional_latex_packages : string or list of strings, optional + Additional latex packages to use when creating the pdf and tex versions of the diagram, by default None + """ self.systems = [] self.connections = [] self.left_outs = {} @@ -127,6 +136,15 @@ def __init__(self, use_sfmath=True): self.process_arrows = [] self.use_sfmath = use_sfmath + if optional_latex_packages is None: + self.optional_packages = [] + else: + if isinstance(optional_latex_packages, str): + self.optional_packages = [optional_latex_packages] + elif isinstance(optional_latex_packages, list): + self.optional_packages = optional_latex_packages + else: + raise ValueError("optional_latex_packages must be a string or a list of strings") def add_system( self, @@ -502,7 +520,7 @@ def _build_process_chain(self): def _compose_optional_package_list(self): # Check for optional LaTeX packages - optional_packages_list = [] + optional_packages_list = self.optional_packages if self.use_sfmath: optional_packages_list.append("sfmath")