pyfeyn2.render.latex.tikzfeynman.TikzFeynmanRender

class pyfeyn2.render.latex.tikzfeynman.TikzFeynmanRender(fd=None, documentclass='standalone', document_options=None, *args, **kwargs)[source]

Bases: LatexRender

__init__(fd=None, documentclass='standalone', document_options=None, *args, **kwargs)[source]
Parameters:
  • default_filepath (str) – The default path to save files.

  • documentclass (str or ~.Command) – The LaTeX class of the document.

  • document_options (str or list) – The options to supply to the documentclass

  • fontenc (str) – The option for the fontenc package. If it is None, the fontenc package will not be loaded at all.

  • inputenc (str) – The option for the inputenc package. If it is None, the inputenc package will not be loaded at all.

  • font_size (str) – The font size to declare as normalsize

  • lmodern (bool) – Use the Latin Modern font. This is a font that contains more glyphs than the standard LaTeX font.

  • textcomp (bool) – Adds even more glyphs, for instance the Euro (€) sign.

  • page_numbers (bool) – Adds the ability to add the last page to the document.

  • indent (bool) – Determines whether or not the document requires indentation. If it is None it will use the value from the active config. Which is True by default.

  • geometry_options (dict) – The options to supply to the geometry package

  • data (list) – Initial content of the document.

Methods

__init__([fd, documentclass, document_options])

param default_filepath:

The default path to save files.

add_color(name, model, description)

Add a color that can be used throughout the document.

append(item)

S.append(value) -- append value to the end of the sequence

change_document_style(style)

Alternate page style for the entire document.

change_length(parameter, value)

Change the length of a certain parameter to a certain value.

change_page_style(style)

Alternate page styles of the current page.

clear()

copy()

count(value)

create(child)

Add a LaTeX object to current container, context-manager style.

demo_propagator(propagator[, show, label, shape])

demo_vertex(vertex[, show, label])

dump(file_w)

Write the LaTeX representation of the class to a file.

dump_packages(file_w)

Write the LaTeX representation of the packages to a file.

dumps()

Represent the document as a string in LaTeX syntax.

dumps_as_content()

Create a string representation of the object as content.

dumps_content(**kwargs)

Represent the container as a string in LaTeX syntax.

dumps_packages()

Represent the packages needed as a string in LaTeX syntax.

extend(other)

S.extend(iterable) -- extend sequence by appending elements from the iterable

generate_pdf([filepath, clean, clean_tex, ...])

Generate a pdf file from the document.

generate_tex([filepath])

Generate a .tex file for the document.

get_src()

get_src_diag()

index(value, [start, [stop]])

Raises ValueError if the value is not present.

insert(i, item)

S.insert(index, value) -- insert value before index

pop([index])

Raise IndexError if list is empty or index is out of range.

remove(item)

S.remove(value) -- remove first occurrence of value.

render([file, show, resolution, width, ...])

Render the diagram.

reverse()

S.reverse() -- reverse IN PLACE

set_feynman_diagram(fd)

set_src(src)

set_src_diag(src_diag)

set_variable(name, value)

Add a variable which can be used inside the document.

sort(*args, **kwds)

valid_attribute(attr)

valid_attributes()

valid_shape(typ)

valid_shapes()

valid_style(style)

valid_styles()

valid_type(typ)

valid_types()

Attributes

begin_paragraph

Start a new paragraph before this environment.

content_separator

end_paragraph

Start a new paragraph after this environment.

escape

Determine whether or not to escape content of this class.

latex_name

Return the name of the class used in LaTeX.

omit_if_empty

Set to true if this full container should be equivalent to an empty string if it has no content.

packages

separate_paragraph

Same as enabling begin_paragraph and end_paragraph, so effectively placing this element in its own paragraph.

add_color(name, model, description)

Add a color that can be used throughout the document.

Parameters:
  • name (str) – Name to set for the color

  • model (str) – The color model to use when defining the color

  • description (str) – The values to use to define the color

append(item)

S.append(value) – append value to the end of the sequence

begin_paragraph = False

Start a new paragraph before this environment.

change_document_style(style)

Alternate page style for the entire document.

Parameters:

style (str) – value to set for the document style

change_length(parameter, value)

Change the length of a certain parameter to a certain value.

Parameters:
  • parameter (str) – The name of the parameter to change the length for

  • value (str) – The value to set the parameter to

change_page_style(style)

Alternate page styles of the current page.

Parameters:

style (str) – value to set for the page style of the current page

clear() None -- remove all items from S
count(value) integer -- return number of occurrences of value
create(child)

Add a LaTeX object to current container, context-manager style.

Parameters:

child (~.Container) – An object to be added to the current container

dump(file_w)

Write the LaTeX representation of the class to a file.

Parameters:

file_w (io.TextIOBase) – The file object in which to save the data

dump_packages(file_w)

Write the LaTeX representation of the packages to a file.

Parameters:

file_w (io.TextIOBase) – The file object in which to save the data

dumps()

Represent the document as a string in LaTeX syntax.

Return type:

str

dumps_as_content()

Create a string representation of the object as content.

This is currently only used to add new lines before and after the output of the dumps function. These can be added or removed by changing the begin_paragraph, end_paragraph and separate_paragraph attributes of the class.

dumps_content(**kwargs)

Represent the container as a string in LaTeX syntax.

Parameters:

**kwargs – Arguments that can be passed to ~.dumps_list

Returns:

A LaTeX string representing the container

Return type:

string

dumps_packages()

Represent the packages needed as a string in LaTeX syntax.

Returns:

A LaTeX string representing the packages of the container

Return type:

string

end_paragraph = False

Start a new paragraph after this environment.

property escape

Determine whether or not to escape content of this class.

This defaults to True for most classes.

extend(other)

S.extend(iterable) – extend sequence by appending elements from the iterable

generate_pdf(filepath=None, *, clean=True, clean_tex=True, compiler=None, compiler_args=None, silent=True)

Generate a pdf file from the document.

Parameters:
  • filepath (str) – The name of the file (without .pdf), if it is None the default_filepath attribute will be used.

  • clean (bool) – Whether non-pdf files created that are created during compilation should be removed.

  • clean_tex (bool) – Also remove the generated tex file.

  • compiler (str or None) – The name of the LaTeX compiler to use. If it is None, PyLaTeX will choose a fitting one on its own. Starting with latexmk and then pdflatex.

  • compiler_args (list or None) – Extra arguments that should be passed to the LaTeX compiler. If this is None it defaults to an empty list.

  • silent (bool) – Whether to hide compiler output

generate_tex(filepath=None)

Generate a .tex file for the document.

Parameters:

filepath (str) – The name of the file (without .tex), if this is not supplied the default filepath attribute is used as the path.

index(value[, start[, stop]]) integer -- return first index of value.

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

insert(i, item)

S.insert(index, value) – insert value before index

property latex_name

Return the name of the class used in LaTeX.

It can be None when the class doesn’t have a name.

omit_if_empty = False

Set to true if this full container should be equivalent to an empty string if it has no content.

pop([index]) item -- remove and return item at index (default last).

Raise IndexError if list is empty or index is out of range.

remove(item)

S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.

render(file=None, show=True, resolution=100, width=None, height=None, clean_up=True, temp_dir=None)

Render the diagram.

reverse()

S.reverse() – reverse IN PLACE

separate_paragraph = False

Same as enabling begin_paragraph and end_paragraph, so effectively placing this element in its own paragraph.

set_variable(name, value)

Add a variable which can be used inside the document.

Variables are defined before the preamble. If a variable with that name has already been set, the new value will override it for future uses. This is done by appending \renewcommand to the document.

Parameters:
  • name (str) – The name to set for the variable

  • value (str) – The value to set for the variable