Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to specify additional latex packages #44

Merged
merged 3 commits into from
May 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions pyxdsm/XDSM.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand All @@ -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,
Expand Down Expand Up @@ -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")

Expand Down