File: basic.py

package info (click to toggle)
python-pylatex 1.4.2%2Bds-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,044 kB
  • sloc: python: 3,810; sh: 209; makefile: 169; xml: 12
file content (86 lines) | stat: -rw-r--r-- 1,980 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# -*- coding: utf-8 -*-
"""
This module implements several classes that represent basic latex commands.

..  :copyright: (c) 2014 by Jelte Fennema.
    :license: MIT, see License for more details.
"""

from .base_classes import CommandBase, ContainerCommand, Environment
from .package import Package


class NewPage(CommandBase):
    """A command that adds a new page to the document."""


class LineBreak(NewPage):
    """A command that adds a line break to the document."""


class NewLine(NewPage):
    """A command that adds a new line to the document."""


class HFill(NewPage):
    """A command that fills the current line in the document."""


class HugeText(Environment):
    """An environment which makes the text size 'Huge'."""

    _latex_name = "Huge"

    def __init__(self, data=None):
        """
        Args
        ----
        data : str or `~.LatexObject`
            The string or LatexObject to be formatted.
        """

        super().__init__(data=data)


class LargeText(HugeText):
    """An environment which makes the text size 'Large'."""

    _latex_name = "Large"


class MediumText(HugeText):
    """An environment which makes the text size 'large'."""

    _latex_name = "large"


class SmallText(HugeText):
    """An environment which makes the text size 'small'."""

    _latex_name = "small"


class FootnoteText(HugeText):
    """An environment which makes the text size 'footnotesize'."""

    _latex_name = "footnotesize"


class TextColor(ContainerCommand):
    """An environment which changes the text color of the data."""

    _repr_attributes_mapping = {"color": "arguments"}

    packages = [Package("xcolor")]

    def __init__(self, color, data):
        """
        Args
        ----
        color: str
            The color to set for the data inside of the environment.
        data: str or `~.LatexObject`
            The string or LatexObject to be formatted.
        """

        super().__init__(arguments=color, data=data)