pyexlatex.models package¶
Subpackages¶
- pyexlatex.models.boxes package
- pyexlatex.models.commands package
- pyexlatex.models.control package
- Subpackages
- pyexlatex.models.control.documentclass package
- Subpackages
- Submodules
- pyexlatex.models.control.documentclass.documentclass module
- pyexlatex.models.control.documentclass package
- Submodules
- pyexlatex.models.control.and_ module
- pyexlatex.models.control.extrafloats module
- pyexlatex.models.control.filecontents module
- pyexlatex.models.control.group module
- pyexlatex.models.control.maxdeadcycles module
- pyexlatex.models.control.mode module
- pyexlatex.models.control.newcounter module
- pyexlatex.models.control.newpage module
- pyexlatex.models.control.setcounter module
- pyexlatex.models.control.setlength module
- pyexlatex.models.control.value module
- Subpackages
- pyexlatex.models.credits package
- pyexlatex.models.format package
- Subpackages
- pyexlatex.models.format.code package
- pyexlatex.models.format.paragraph package
- pyexlatex.models.format.text package
- Subpackages
- Submodules
- pyexlatex.models.format.text.bold module
- pyexlatex.models.format.text.italics module
- pyexlatex.models.format.text.linespacing module
- pyexlatex.models.format.text.monospace module
- pyexlatex.models.format.text.nohyphens module
- pyexlatex.models.format.text.smallcaps module
- pyexlatex.models.format.text.text module
- pyexlatex.models.format.text.underline module
- Submodules
- pyexlatex.models.format.adjustbox module
- pyexlatex.models.format.breaks module
- pyexlatex.models.format.captionsetup module
- pyexlatex.models.format.centering module
- pyexlatex.models.format.fills module
- pyexlatex.models.format.hangindent module
- pyexlatex.models.format.hline module
- pyexlatex.models.format.hspace module
- pyexlatex.models.format.join module
- pyexlatex.models.format.noindent module
- pyexlatex.models.format.nolinebreak module
- pyexlatex.models.format.nopagebreak module
- pyexlatex.models.format.paragraphindent module
- pyexlatex.models.format.raw module
- pyexlatex.models.format.rule module
- pyexlatex.models.format.sectionnum module
- pyexlatex.models.format.vspace module
- Subpackages
- pyexlatex.models.lists package
- pyexlatex.models.page package
- pyexlatex.models.references package
- Subpackages
- pyexlatex.models.references.bibtex package
- Subpackages
- Submodules
- pyexlatex.models.references.bibtex.addresource module
- pyexlatex.models.references.bibtex.article module
- pyexlatex.models.references.bibtex.base module
- pyexlatex.models.references.bibtex.generic module
- pyexlatex.models.references.bibtex.manual module
- pyexlatex.models.references.bibtex.misc module
- pyexlatex.models.references.bibtex.printbib module
- pyexlatex.models.references.bibtex package
- Submodules
- pyexlatex.models.references.bibliography module
- pyexlatex.models.references.citations module
- Subpackages
- pyexlatex.models.section package
- pyexlatex.models.sizes package
- pyexlatex.models.title package
Submodules¶
pyexlatex.models.blindtext module¶
pyexlatex.models.containeritem module¶
- class pyexlatex.models.containeritem.ContainerItem(name, content, *args, **kwargs)[source]¶
Bases:
pyexlatex.models.documentitem.DocumentItem
Inherit to be able to include LaTeX objects inside LaTeX objects
pyexlatex.models.datastore module¶
- class pyexlatex.models.datastore.DataStore(content=None)[source]¶
Bases:
pyexlatex.models.containeritem.ContainerItem
,pyexlatex.models.documentitem.DocumentItem
Holds LaTeX item data and can be included directly in documents. Mainly for internal use.
pyexlatex.models.date module¶
pyexlatex.models.document module¶
- class pyexlatex.models.document.Document(content, packages=None, landscape=False, title=None, authors=None, date=None, abstract=None, skip_title_page=False, page_modifier_str='margin=0.8in, bottom=1.2in', page_header=False, page_numbers=True, appendix_modifier_str='page', section_numbering_styles=None, floats_at_end=False, floats_at_end_options='nolists', document_type='article', font_size=None, num_columns=None, line_spacing=None, tables_relative_font_size=0, figures_relative_font_size=0, page_style='fancy', custom_headers=None, custom_footers=None, remove_section_numbering=False, separate_abstract_page=False, extra_title_page_lines=None, empty_title_page_style=False, pre_output_func=None, apply_page_style_to_section_starts=False, extra_pre_env_contents=None)[source]¶
Bases:
pyexlatex.models.document.DocumentBase
Main class used for creating latex documents.
- __init__(content, packages=None, landscape=False, title=None, authors=None, date=None, abstract=None, skip_title_page=False, page_modifier_str='margin=0.8in, bottom=1.2in', page_header=False, page_numbers=True, appendix_modifier_str='page', section_numbering_styles=None, floats_at_end=False, floats_at_end_options='nolists', document_type='article', font_size=None, num_columns=None, line_spacing=None, tables_relative_font_size=0, figures_relative_font_size=0, page_style='fancy', custom_headers=None, custom_footers=None, remove_section_numbering=False, separate_abstract_page=False, extra_title_page_lines=None, empty_title_page_style=False, pre_output_func=None, apply_page_style_to_section_starts=False, extra_pre_env_contents=None)[source]¶
- Parameters
content¶ (
Union
[IsLatexItemMixin
,str
,Sequence
[Union
[IsLatexItemMixin
,str
]]]) –pre_env_contents¶ –
data_cleanup_func¶ – should accept DocumentSetupData and modify it in place. This is called just before using the data.
pre_output_func¶ (
Optional
[Callable
]) – function which modifies the latex string before outputting it. The function should accepts a single argument which is a string of the entire latex contents, and it should return a string which will be used as the latex contents for output.
- construct_packages(packages=None, page_modifier_str='margin=0.8in, bottom=1.2in', appendix_modifier_str='page', floats_at_end=False, floats_at_end_options='nolists', line_spacing=None, tables_relative_font_size=0, figures_relative_font_size=0)[source]¶
- name = 'document'¶
- class pyexlatex.models.document.DocumentBase(content, packages=None, pre_env_contents=None, data_cleanup_func=None, pre_output_func=None)[source]¶
Bases:
pyexlatex.models.containeritem.ContainerItem
,pyexlatex.models.item.Item
- __init__(content, packages=None, pre_env_contents=None, data_cleanup_func=None, pre_output_func=None)[source]¶
- Parameters
content¶ (
Union
[IsLatexItemMixin
,str
,Sequence
[Union
[IsLatexItemMixin
,str
]]]) –packages¶ (
Union
[IsLatexItemMixin
,str
,Sequence
[Union
[IsLatexItemMixin
,str
]],None
]) –pre_env_contents¶ (
Union
[IsLatexItemMixin
,str
,Sequence
[Union
[IsLatexItemMixin
,str
]],None
]) –data_cleanup_func¶ (
Optional
[Callable
]) – should accept DocumentSetupData and modify it in place. This is called just before using the data.pre_output_func¶ (
Optional
[Callable
]) – function which modifies the latex string before outputting it. The function should accepts a single argument which is a string of the entire latex contents, and it should return a string which will be used as the latex contents for output.
- document_class_obj: Optional[pyexlatex.models.control.documentclass.documentclass.DocumentClass] = None¶
- name = '<invalid, do not use DocumentBase directly>'¶
- class pyexlatex.models.document.DocumentEnvironment[source]¶
Bases:
pyexlatex.models.environment.Environment
- name = 'document'¶
pyexlatex.models.documentitem module¶
- class pyexlatex.models.documentitem.DocumentItem(*args, **kwargs)[source]¶
Bases:
pyexlatex.models.mixins.IsSpecificClassMixin
,pyexlatex.models.item.IsLatexItemMixin
Used for differentiating which items can be directly included in a document
- is_DocumentItem = True¶
pyexlatex.models.documentsetup module¶
- class pyexlatex.models.documentsetup.DocumentSetupData(filepaths=None, binaries=None, begin_document_items=None, end_document_items=None, packages=None, source_paths=None, references=None, flags=None)[source]¶
Bases:
mixins.repr.ReprMixin
,mixins.attrequals.EqOnAttrsMixin
,mixins.attrequals.EqHashMixin
- __init__(filepaths=None, binaries=None, begin_document_items=None, end_document_items=None, packages=None, source_paths=None, references=None, flags=None)[source]¶
- equal_attrs = ['filepaths', 'binaries', 'begin_document_items', 'end_document_items', 'packages', 'source_paths', 'references', 'flags']¶
- ignore_attrs = ['ignore_attrs', 'repr_cols', 'attrs', 'readable_repr', 'equal_attrs']¶
- non_unique_attrs = ['filepaths', 'binaries']¶
- class pyexlatex.models.documentsetup.UniqueDataList(iterable)[source]¶
Bases:
list
A list where the items are always unique.
- class pyexlatex.models.documentsetup.UniquePackagesList(packages=None)[source]¶
Bases:
pyexlatex.models.documentsetup.UniqueDataList
A unique data list that allows passing of just a string to represent a package
pyexlatex.models.environment module¶
pyexlatex.models.environmenttemplate module¶
- class pyexlatex.models.environmenttemplate.EnvironmentTemplate(contents, **kwargs)[source]¶
Bases:
pyexlatex.models.section.base.TextAreaMixin
,pyexlatex.models.item.Item
Base class which makes it easy to create new environment types.
Examples: >>> import pyexlatex as pl >>> class BoldEnvironment(pl.EnvironmentTemplate): >>> name = ‘myenv’ >>> begin_def = r’f’ >>> end_def = ‘’ >>> >>> print(pl.Document(BoldEnvironment(‘woo’))) documentclass[]{article}
- ewenvironment{myenv}{f}{}
… egin{document} egin{myenv} woo end{myenv} end{document}
- begin_def = ''¶
- end_def = ''¶
pyexlatex.models.equation module¶
- class pyexlatex.models.equation.Equation(eq=None, str_eq=None, inline=True, numbered=True)[source]¶
Bases:
pyexlatex.models.mixins.IsSpecificClassMixin
,pyexlatex.models.item.IsLatexItemMixin
Pass sympy or string equations to have them rendered in LaTeX.
- property eq_str¶
- property formatted_eq¶
- name = 'equation'¶
pyexlatex.models.footnote module¶
pyexlatex.models.hyperlinks module¶
- class pyexlatex.models.hyperlinks.Hyperlink(href, content=None, **kwargs)[source]¶
Bases:
pyexlatex.models.section.base.TextAreaMixin
,pyexlatex.models.item.MultiOptionSimpleItem
Create links to urls, with or without displaying text instead of the link.
pyexlatex.models.item module¶
- class pyexlatex.models.item.Item(name, contents, pre_env_contents=None, post_env_contents=None, env_modifiers=None, overlay=None)[source]¶
Bases:
pyexlatex.models.item.ItemBase
- __init__(name, contents, pre_env_contents=None, post_env_contents=None, env_modifiers=None, overlay=None)[source]¶
- equal_attrs = ['contents', 'pre_env_contents', 'post_env_contents', 'data', 'env']¶
- class pyexlatex.models.item.ItemBase(*args, **kwargs)[source]¶
Bases:
pyexlatex.models.item.DataItem
,pyexlatex.models.mixins.IsSpecificClassMixin
,pyexlatex.models.item.IsLatexItemMixin
,pyexlatex.models.mixins.StringAdditionMixin
,mixins.attrequals.EqHashMixin
,mixins.attrequals.EqOnAttrsMixin
Base class for all latex generating classes
Note: Does not pass any args to super call, so do not put another class below this one expecting args to be passed
- class pyexlatex.models.item.SimpleItem(name, contents, modifiers=None, pre_modifiers=None, overlay=None, format_content=True)[source]¶
Bases:
pyexlatex.models.item.ItemBase
- __init__(name, contents, modifiers=None, pre_modifiers=None, overlay=None, format_content=True)[source]¶
- equal_attrs = ['contents', 'modifiers', 'pre_modifiers', 'overlay', 'format_content', 'data']¶
pyexlatex.models.jinja module¶
- class pyexlatex.models.jinja.JinjaEnvironment(*args, **kwargs)[source]¶
Bases:
jinja2.environment.Environment
A jinja Environment but with pyexlatex models as built in filters and handling extracting pyexlatex data
Examples:
>>> import pyexlatex as pl >>> from jinja2 import DictLoader >>> env = pl.JinjaEnvironment( >>> loader=DictLoader({'my_temp': '{{ my_var | Italics }}'}) >>> ) >>> temp = env.get_template('my_temp') >>> str(temp.render(my_var='woo')) '\textit{woo}'
- from_string(*args, **kwargs)[source]¶
Load a template from a source string without using
loader
.- Parameters
source¶ – Jinja source to compile into a template.
globals¶ – Extend the environment
globals
with these extra variables available for all renders of this template. If the template has already been loaded and cached, its globals are updated with any new items.template_class¶ – Return an instance of this
Template
class.
- template_class¶
alias of
pyexlatex.models.jinja.JinjaTemplate
- class pyexlatex.models.jinja.JinjaTemplate(source, **kwargs)[source]¶
Bases:
jinja2.environment.Template
,pyexlatex.models.containeritem.ContainerItem
A jinja Template but with pyexlatex models as built-in filters and handling extracting pyexlatex data
Examples:
>>> import pyexlatex as pl >>> str(pl.JinjaTemplate('{{ my_var | Italics }}').render(my_var='woo')) '\textit{woo}'
- environment: jinja2.environment.Environment¶
- render(*args, **kwargs)[source]¶
This method accepts the same arguments as the dict constructor: A dict, a dict subclass or some keyword arguments. If no arguments are given the context will be empty. These two calls do the same:
template.render(knights='that say nih') template.render({'knights': 'that say nih'})
This will return the rendered template as a string.
pyexlatex.models.label module¶
pyexlatex.models.landscape module¶
pyexlatex.models.latex module¶
pyexlatex.models.mixins module¶
pyexlatex.models.model module¶
- class pyexlatex.models.model.Model(template_str=None, template_path=None, environment=None)[source]¶
Bases:
pyexlatex.models.template.Template
A data model combined with a Jinja template.
Passes any class variables and methods to template to render the output string. Subclass this class to create your own data models for templates.
Set exclude_attrs class variable as a list of strings of any attributes which should not be passed to the template.
Examples:
>>> import pyexlatex as pl >>> template_str = "{{ my_var | Bold }} {{ my_link }} {{ my_text }}" >>> >>> class MyModel(pl.Model): >>> my_var = 'woo' >>> my_link = pl.Hyperlink('https://www.google.com', 'Link!!!!') >>> >>> def __init__(self, my_text: str, *args, **kwargs): >>> self.my_text = my_text >>> super().__init__(*args, **kwargs) >>> >>> model = MyModel('stuff', template_str=template_str) >>> str(model) '\textbf{woo} \href{https://www.google.com}{Link!!!!} stuff '
- property environment¶
- property template: pyexlatex.models.jinja.JinjaTemplate¶
- Return type
pyexlatex.models.package module¶
- class pyexlatex.models.package.Package(name, modifier_str=None, eq_on_modifier=True)[source]¶
Bases:
pyexlatex.models.package.PackageBase
Represents LaTeX usepackage{}, pass to Document if any custom LaTeX packages are needed.
- class pyexlatex.models.package.PackageBase(name, modifier_str=None, eq_on_modifier=True)[source]¶
Bases:
pyexlatex.models.item.ItemBase
Base class for usepackage and RequirePackage
- __init__(name, modifier_str=None, eq_on_modifier=True)[source]¶
- Parameters
modifier_str¶ (
Optional
[str
]) – any options to be passed to the LaTeX package. E.g. if ‘abc=true’ is passed, it will render as usepackage[abc=true]{mypackage}eq_on_modifier¶ (
bool
) – Whether to consider any package options when checking equality of the package. Useful to set it to False when this package should not be added if it was previously added with different options
- equal_attrs = ['name', 'modifier_str']¶
- class pyexlatex.models.package.RequirePackage(name, modifier_str=None, eq_on_modifier=True)[source]¶
Bases:
pyexlatex.models.package.PackageBase
Represents LaTeX RequirePackage, usually useful when building cls files and packages.
pyexlatex.models.ref module¶
- class pyexlatex.models.ref.NameRef(contents)[source]¶
Bases:
pyexlatex.models.item.SimpleItem
Pass a label to create an in text reference to that label. Will display the name of the section in the text.
- name = 'nameref'¶
pyexlatex.models.standalone module¶
- class pyexlatex.models.standalone.Standalone(content, packages=None, pre_env_contents=None, font_size=None, doc_class_options=None, pre_output_func=None)[source]¶
Bases:
pyexlatex.models.document.DocumentBase
The main high-level class for creating one-off graphics, equations, etc. Does not provide any document structure and will crop the document to the contents.
- __init__(content, packages=None, pre_env_contents=None, font_size=None, doc_class_options=None, pre_output_func=None)[source]¶
- Parameters
data_cleanup_func¶ – should accept DocumentSetupData and modify it in place. This is called just before using the data.
pre_output_func¶ (
Optional
[Callable
]) – function which modifies the latex string before outputting it. The function should accepts a single argument which is a string of the entire latex contents, and it should return a string which will be used as the latex contents for output.
- name = 'document'¶
pyexlatex.models.template module¶
- class pyexlatex.models.template.Template[source]¶
Bases:
pyexlatex.models.section.base.TextAreaMixin
,pyexlatex.models.item.ItemBase
Base class for creating custom Pyexlatex templates.
To use, simply subclass Template, then in __init__, set the attribute .contents, and call super().__init__(). The .contents attribute should be set to a string, pyexlatex object, or iterable of those.
Examples:
Contents can be a Pyexlatex object or string:
>>> import pyexlatex as pl >>> class BoldUnderline(pl.Template): >>> >>> def __init__(self, contents): >>> self.contents = pl.Bold(pl.Underline(contents)) >>> super().__init__() >>> >>> print(BoldUnderline('woo')) \textbf{\underline{woo}}
Contents can also be an iterable of strings or Pyexlatex objects
>>> import pyexlatex as pl >>> class BoldAndUnderline(pl.Template): >>> >>> def __init__(self, bold_contents, underline_contents, *other_contents): >>> self.contents = [ >>> pl.Bold(bold_contents), >>> pl.Underline(underline_contents), >>> *other_contents >>> ] >>> super().__init__() >>> >>> print(BoldAndUnderline('woo bold', 'woo underline', 'something')) \textbf{woo bold} \underline{woo underline} something