TeXRenderer
ClassSource
TeXRenderer(
path_temp: str | PathLike[str] | None = None, verbose: bool = False
)
The LaTeX renderer.
Render the LaTeX equation to pixel image. The backend is implemented by calling the latex command. Therefore, using this renderer requires the installation of a LaTeX released version.
Arguments
Requires
| Name | Type | Required | |
|---|---|---|---|
path_temp | str | PathLike[str] | None | The path to the folder storing the temporary files. If not specified, will create a folder in the temp path, | |
verbose | bool | Whether to show the running details of LaTeX. |
Methods
get_template
v_1: TeXTemplate = TeXRenderer.get_template(template: str | TeXTemplate = "default")
Get the LaTeX rendering template by specifying the template name.
Requires
| Name | Type | Required | |
|---|---|---|---|
template | str | TeXTemplate | The name of the template. |
Returns
| Name | Type | |
|---|---|---|
v_1 | TeXTemplate | The fetched LaTeX template. |
render
v_1: Image = self.render(equation: str, template: str | TeXTemplate = "default")
Render the equation into a pixel-based image.
Requires
| Name | Type | Required | |
|---|---|---|---|
equation | str | The LaTeX equation. This equation is treated as a block equation. Do not need to specify | |
template | str | TeXTemplate | The LaTeX template used for rendering the equation. If using Check |
Returns
| Name | Type | |
|---|---|---|
v_1 | Image | The image rendered from the LaTeX equation. |
render_png
self.render_png(
out_file: str | PathLike[str],
equation: str,
template: str | TeXTemplate = "default",
bg_color: str | tuple[float, ...] = "#1b2838",
fg_color: str | tuple[float, ...] = "#ffffff",
out_width: int = 3000,
)
Render the equation as a PNG file.
This method is recommended for previewing the rendered equations.
Requires
| Name | Type | Required | |
|---|---|---|---|
out_file | str | PathLike[str] | The path to the output file. | |
equation | str | The LaTeX equation. This equation is treated as a block equation. Do not need to specify | |
template | str | TeXTemplate | The LaTeX template used for rendering the equation. If using Check | |
bg_color | str | tuple[float, ...] | The background color of the rendered image. | |
fg_color | str | tuple[float, ...] | The foreground (text) color. | |
out_width | int | The width of the output image. If the rendered equation is not long enough, will place the equation in the center of the image. This option ensures that every output file to have the same image width. |