text_and_organisation¶
- class BlB[source]¶
Create a styled bulleted list with optional title and animation features.
This class inherits from
Text_Generaland allows creation of animated bulleted lists for use in Manim scene constructions. Each bullet point can be highlighted individually using thenext_point()method.- Parameters:
content (list[str]) – List of bullet points to display.
the_title (str, optional) – Optional title displayed above the bulleted list.
kwargs – Additional arguments passed to
Text_General.
Note
Use
next_point()to iterate through bullet points with animation effects. Each call highlights the current point and dims the others.Example usage:
from manim import * from manim_beanim import * class BlB_Test(Scene): def construct(self): important_points = BlB( content=[ "This is a bulleted list with a title", "Use .next_point() to iterate over points", "The final point restores all to original color" ], the_title="This is a title for the bulleted list" ).to_corner(LEFT).shift(UP) important_points_2 = BlB( content=[ "This is a bulleted list without a title", "Use .next_point() to iterate", "Observe the different corner style" ] ).next_to(important_points, DOWN, aligned_edge=LEFT) self.add(important_points, important_points_2) for _ in range(len(important_points) + 3): self.play(important_points.next_point())
- Seealso:
- add_title_and_box(title_on_top, points)[source]¶
Add both title box and bullet points with appropriate decorative styling.
Creates a title box with rounded top corners and a points box with rounded bottom corners, positioning them to create a unified visual element.
- Parameters:
title_on_top (str) – The title text to display above the bullet points.
points (BulletedList) – The BulletedList object containing the bullet points.
- next_point(rf: float = <function linear>, rt: float = 1) Succession[source]¶
Animate to the next bullet point, highlighting it while dimming others.
Each call to this method advances through the bullet points sequentially, creating a presentation-style reveal effect. The final call restores all points to full opacity.
- Parameters:
rf (float) – Rate function for the animation transition.
rt (float) – Duration of the animation in seconds.
- Returns:
Animation sequence for the bullet point transition.
- Return type:
Succession
Note
After all bullet points have been shown, subsequent calls will return a Wait() animation.
- class Equation[source]¶
Create one or more LaTeX-formatted equations as part of a scene.
This class inherits from
Text_Generaland supports rendering equations provided directly as LaTeX strings or indirectly via references to an external equation dictionary.- Parameters:
content (str or list[str]) – A LaTeX string or a list of strings. Each string can either be: 1. A LaTeX expression input directly (e.g.,
"e^{i\pi} = -1"), or 2. A key that refers to an expression defined within a dictionary file.the_dictionary (str, optional) – Optional path to a .txt file containing a dictionary mapping keys to LaTeX equations. If set to
"data_base", the class will use a built-in Beanim equation dictionary.the_direction (np.ndarray, default=DOWN) – Direction in which multiple equations will be arranged, e.g.,
DOWNorRIGHT.
- Raises:
FileNotFoundError – if the specified dictionary file cannot be found (when used).
KeyError – if a specified equation key is not found in the dictionary.
- Seealso:
Note
Dictionary-based expressions allow equation management via external .txt files.
For extracting LaTeX equations into dictionary files, see the
toolspackage.
Example usage:
from manim import * from manim_beanim import * class Equation_Test(Scene): def construct(self): eq_from_data_base = Equation( content=["equation_data_base_1", "equation_data_base_3"], the_dictionary="data_base", text_size=30, the_direction=DOWN, aligned_direction=LEFT, ) eq_from_extract = Equation( content=["equation_extract_1", "equation_extract_3"], the_dictionary="example_extract_ref_equation/dictionaries_extracted/equations.txt", text_size=30, the_direction=DOWN, aligned_direction=LEFT, ) eq_from_manual_input = Equation( content=["x^{2}+y^{2} = R^{2}, \quad", "e^{i \pi} = -1"], text_size=30, the_direction=RIGHT, ) self.add(VGroup( eq_from_data_base, eq_from_extract, eq_from_manual_input ))
- class Reference[source]¶
Create academic-style citations and references formatted within brackets.
This class inherits from
Text_Generaland generates references in the format[surname1, surname2, ..., ref]. References can be provided directly as strings or retrieved from a dictionary file using lookup keys.- Parameters:
content (str or list[str]) – Reference content to display. Can be either direct reference strings (e.g.,
"[Smith et al., 2023]") or dictionary keys that map to reference entries.the_dictionary (str, optional) – Optional path to a
.txtfile containing reference mappings. If set to"data_base", uses the built-in Beanim reference dictionary.the_direction (np.ndarray, default=RIGHT) – Direction for arranging multiple references when content is a list.
kwargs – Additional parameters passed to
Text_General.
Note
Reference dictionaries should map keys to properly formatted citation strings, typically in the format
[Author, Publication, Year].Example usage:
from manim import * from manim_beanim import * class Ref_Test(Scene): def construct(self): ref_from_data_base = Reference( content=['ref_data_base_1', 'ref_data_base_2', 'ref_data_base_3'], the_dictionary='data_base' ) ref_from_extract = Reference( the_dictionary="example_extract_ref_equation/dictionaries_extracted/refs.txt", content=['ref_extract_1', 'ref_extract_2'] ) ref_from_manual_input = Reference( content='[Manually input ref, PP, 2025]' ) references = VGroup( ref_from_data_base, ref_from_extract, ref_from_manual_input ).arrange(DOWN, aligned_edge=LEFT) self.add(references)
- Seealso:
- class Text_General[source]¶
Base class for all Beanim TeX-supporting rendering components.
This class provides standardized behavior and styling for any derived classes that generate LaTeX-rendered content using Manim. It arranges and optionally decorates text content, with support for loading content from string literals or from dictionary sources.
Subclasses may override rendering behavior while keeping the base logic for positioning, styling, and decoration.
- Parameters:
content (str or list[str]) – The primary text to display. May be either a string or list of strings. Strings should contain valid LaTeX. Each list entry will be rendered individually.
dictionary (str, optional) – Optional path to a dictionary file used to resolve content labels into LaTeX code. If set to
"data_base", a built-in library dictionary is used.direction (np.ndarray) – Direction in which multiple entries will be stacked (e.g.,
RIGHT,DOWN).aligned_direction (np.ndarray or list) – Alignment edge for stacked/arranged objects (e.g.,
LEFT,UP).text_size (float) – Font size of the rendered text content.
text_color (ParsableManimColor) – Manim color of the LaTeX text.
decorator_presence (str) – Type of decoration to apply. Options include:
"box","box_long_left","box_long_right","back_frame","no".decorator_color (ParsableManimColor) – Outline or fill color used in decoration elements.
decorator_stroke_width (float) – Stroke width of the decorative borders.
corner_rad (float) – Scalar used in combination with
corner_rad_directionto round rectangle corners.corner_rad_direction (list[int]) – List controlling corner rounding; format: [top-left, top-right, bottom-right, bottom-left].
fill_opa (float) – Opacity for backgrounds (e.g., for surround boxes or frames).
tightness (float) – Buffer/margin around the decorated content.
stroke_opa (float) – Opacity of the border stroke around decorations.
dot_scale (float) – Scale of bullet points (used in subclasses like bullet lists).
kwargs – Other keyword arguments passed to Manim’s
VGroup.
- Raises:
FileNotFoundError – If the given dictionary file path is invalid.
KeyError – If requested keys are not found in the dictionary.
Note
This class is not intended to be used directly in scenes, but rather subclassed to create content blocks like paragraphs, bullet points, or formulas. See subclasses like
EquationorBlBfor examples of how this class is used.To create your own dictionaries for content control, see the functions in the
toolspackage, such asextract_pieces_from_bib().- add_decorator(mobject)[source]¶
Add a decorative element around the mobject based on the decorator settings.
Applies various types of decorative boxes or frames around the provided mobject according to the
decorator_presencesetting. Supports different box styles including standard boxes, extended boxes, and full-width frames.- Parameters:
mobject (Mobject) – The Manim object to decorate.
Note
If
decorator_presenceis set to"no"or any unrecognized value, the mobject is added without decoration.
- check_file_exists(directory, filename)[source]¶
Check whether a file exists in the specified directory.
- Parameters:
directory (str or Path) – The directory path to search within.
filename (str) – The name of the file to look for within the directory.
- Returns:
True if the file exists, False otherwise.
- Return type:
bool
Example:
>>> self.check_file_exists("path/to/dir", "file.txt") True
- get_tex_from_dict(the_piece, dictionary)[source]¶
Create a Tex object for a given key from the dictionary.
Looks up the provided key in the dictionary and creates a styled Tex object from the corresponding value. If the key is not found, creates a “Missing” placeholder.
- Parameters:
the_piece (str) – The dictionary key to look up.
dictionary (dict) – The dictionary containing key-value mappings.
- Returns:
A Tex object containing either the dictionary value or a missing key message.
- Return type:
Tex
- handle_no_dictionary()[source]¶
Handle rendering when no dictionary is provided.
If
contentis provided directly as a string or list of strings, this method creates a Tex object (or a group of Tex objects) and arranges them visually. Each element is styled according to the object’s text attributes and arranged using the specified direction and alignment.After rendering the Tex objects, this method applies any decorative box if defined by
decorator_presence, using theadd_decorator()method.Note
This method only processes direct input; if a dictionary path is provided instead,
handle_with_dictionary()is used.- Calls:
add_decorator()— applies a decorative box or frame to the rendered object(s).
- Modifies:
self.chosen_content— stores the generated content (either a single Tex or a VGroup of Tex).Adds the content to the object hierarchy via
self.add(...).
- handle_with_dictionary(dic_in_data_base)[source]¶
Handle LaTeX rendering when a dictionary file is provided.
If a dictionary path is passed via the
dictionaryparameter, this method loads the corresponding key-to-LaTeX mapping from the file and uses it to render the specified equation(s). Keys are resolved usingload_dictionary(), and their values are converted into Tex objects usingget_tex_from_dict().If
dictionary == "data_base", an internal library dictionary is used by locating a predefined.txtfile relative to the current module.- Steps performed:
The dictionary path is split into directory and filename using
split_dictionary_path().The dictionary file is loaded into memory using
load_dictionary().Each element in
contentis resolved to a LaTeX expression usingget_tex_from_dict().All rendered content is arranged and passed through
add_decorator()to apply optional styling.
- Parameters:
dic_in_data_base (str) – The base name of the dictionary file when using internal dictionaries.
- Creates:
self.chosen_content: Either a single Tex object or a VGroup of Tex objects built from the dictionary.
- Raises:
FileNotFoundError – If the dictionary path or file does not exist.
KeyError – If any key in
contentis not found in the loaded dictionary.
- Seealso:
- load_dictionary()[source]¶
Load the dictionary from the specified file.
Opens and reads a dictionary file, then evaluates its contents as a Python dictionary. The file should contain a valid Python dictionary structure as a string.
- Returns:
The loaded dictionary containing key-value mappings.
- Return type:
dict
- Raises:
FileNotFoundError – If the dictionary file cannot be found.
SyntaxError – If the dictionary file contains invalid Python syntax.
Warning
This method uses
eval()to parse the dictionary file contents, which can be a security risk if the file contains untrusted code. Ensure dictionary files contain only trusted data.
- split_dictionary_path(input_string)[source]¶
Split a string into two parts using the last
"/"character as the separator.This is typically used to separate a full file path into its directory and filename components.
- Parameters:
input_string (str) – The input path-like string to split.
- Returns:
A list with two elements: 1. The path leading up to the last slash, 2. The remaining string after the last slash (typically the filename).
- Return type:
list[str]
Example:
>>> self.split_dictionary_path("some/path/to/file.txt") ['some/path/to', 'file.txt']
- class Title_Presentation[source]¶
Generate presentation title slides with hierarchical text styling.
This class creates a title group containing the presentation title, affiliation, and author information, each styled with decreasing font sizes to create a visual hierarchy. An optional background decorator can be applied.
- Parameters:
content (list[str]) – A list containing presentation information in order: 1. The presentation title 2. Institution/affiliation 3. Author name(s)
kwargs – Additional parameters passed to
Text_General.
Note
The title text automatically scales to fit the frame width with appropriate margins. Font sizes decrease progressively: title (2x), affiliation (1.5x), author (1x).
Example usage:
from manim import * from manim_beanim import * class Title_Slide_Test(Scene): def construct(self): tp = Title_Presentation( content=[ "This is a Title Presentation", "Your institution", "Your name" ] ) self.add(tp)
- Seealso:
- class Title_Section[source]¶
Create section titles positioned in the upper-left corner.
This class generates section headers that are automatically positioned in the upper-left corner of the frame, typically used for slide section breaks or chapter headings in presentations.
- Parameters:
content (str) – The section title text to display.
kwargs – Additional parameters passed to
Text_General.
Note
The title is automatically positioned using
.to_corner(UL)and scaled to 1.5 times the base text size for emphasis.Example usage:
from manim import * from manim_beanim import * class Title_Section_Test(Scene): def construct(self): title_section = Title_Section( content='This is a title section test' ) self.add(title_section)
- Seealso:
- class Underbar[source]¶
Create a bar in the lower part of the slide with several information to be chosen by the author. The information will be rearranged to properly fit in the slide bottom part.
- Parameters:
content (str or list[str]) – A LaTeX string or a list of strings.
- Seealso:
Note
The content to be displayed is up to decision of the author. Author, affiliation, name of the talk, date, where the talk given… These are some of choices.
Example usage:
from manim import * from manim_beanim import * class Underbar_Test(Scene): def construct(self): under = Underbar(content=["Pano Pepino", "Some University", "My talk in the Mooon", "30th February 2050"]) self.add(under)
- add_decorator(mobject)[source]¶
Add a decorative element around the mobject based on the decorator settings.
Applies various types of decorative boxes or frames around the provided mobject according to the
decorator_presencesetting. Supports different box styles including standard boxes, extended boxes, and full-width frames.- Parameters:
mobject (Mobject) – The Manim object to decorate.
Note
If
decorator_presenceis set to"no"or any unrecognized value, the mobject is added without decoration.