texsnip


Nametexsnip JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://github.com/pgrit/texsnip
SummaryTiny package to quickly add LaTeX text to your favorite vector graphics package.
upload_time2024-01-18 09:18:30
maintainer
docs_urlNone
authorPascal Grittmann
requires_python>=3.6
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # TeXSnip

A small single-module Python package to generate LaTeX text and equations for your favorite vector graphics tool, with no dependencies required! Except LaTeX, of course.

To get started, simply run:
```
pip install texsnip
```

With a few lines of Python code, you can create .pdf files that you can then drag'n'drop into Inkscape, Illustrator, Corel Draw, or most other vector graphics programms.


```python
from texsnip import Snip

# Here, you can modify the LaTeX preamble, for example to configure fonts.
# We use the 'libertine' package, the fonts for the current ACM SIGGRAPH template.
preamble = r"\usepackage{libertine}"

# Write the rendering equation to a file called 'rendering-equation.pdf'
Snip("rendering-equation", 8,
    r"$L_o = L_e + \int_\Omega L_i f \cos\theta_i \,\mathrm{d}\omega_i$"
).generate(preamble)
```

If .pdfs are not supported, don't worry: the script allows you to easily create .png files as well.

```python
Snip("rendering-equation", 8,
    r"$L_o = L_e + \int_\Omega L_i f \cos\theta_i \,\mathrm{d}\omega_i$"
).generate_png(preamble)
```

If you are using these in presentation slides, you can assemble a list of Snips in a .pptx file (uses .png conversion)

```python
from texsnip import Snip, pptx_snips

# Here, you can modify the LaTeX preamble, for example to configure fonts.
# We use the 'libertine' package, the fonts for the current ACM SIGGRAPH template.
preamble = r"\usepackage{libertine}"

snips = [
    # Write the rendering equation to a file called 'rendering-equation.pdf'
    Snip("rendering-equation", 14,
        r"$L_o = L_e + \int_\Omega L_i f \cos\theta_i \,\mathrm{d}\omega_i$"
    ),

    # Sometimes, you need individual terms
    Snip("omega_i", 14,
        r"$\omega_i$"
    ),

    # Or you might want captions for your illustrations with LaTeX typesetting
    Snip("a-caption", 14,
        r"\textsf{a) Some \textcolor[RGB]{200,110,5}{cool} illustration}"
    )
]

# Lets create a snips.pptx with all these snips in it
# This will also create the corresponding .pdf and .png files for use in other applications
pptx_snips(snips, preamble=preamble)
```


## Dependencies

* Python >= 3.6
* LaTeX with pdfcrop (requires Perl) and xcolor, graphicx, inputenc, fontenc

To generate .png images, you will additionally need:
```
pip install pdf2image
```
which requires Poppler to be installed and in the path.

To generate .pptx files, you will need the .png dependencies and also:
```
pip install python-pptx PyPDF2
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pgrit/texsnip",
    "name": "texsnip",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "Pascal Grittmann",
    "author_email": "grittmann@cg.uni-saarland.de",
    "download_url": "https://files.pythonhosted.org/packages/9a/8e/0f274ef3e53fc570e85a845c48d95160e2ee74b8bbe81f7fb54f2998ff73/texsnip-1.1.0.tar.gz",
    "platform": null,
    "description": "# TeXSnip\n\nA small single-module Python package to generate LaTeX text and equations for your favorite vector graphics tool, with no dependencies required! Except LaTeX, of course.\n\nTo get started, simply run:\n```\npip install texsnip\n```\n\nWith a few lines of Python code, you can create .pdf files that you can then drag'n'drop into Inkscape, Illustrator, Corel Draw, or most other vector graphics programms.\n\n\n```python\nfrom texsnip import Snip\n\n# Here, you can modify the LaTeX preamble, for example to configure fonts.\n# We use the 'libertine' package, the fonts for the current ACM SIGGRAPH template.\npreamble = r\"\\usepackage{libertine}\"\n\n# Write the rendering equation to a file called 'rendering-equation.pdf'\nSnip(\"rendering-equation\", 8,\n    r\"$L_o = L_e + \\int_\\Omega L_i f \\cos\\theta_i \\,\\mathrm{d}\\omega_i$\"\n).generate(preamble)\n```\n\nIf .pdfs are not supported, don't worry: the script allows you to easily create .png files as well.\n\n```python\nSnip(\"rendering-equation\", 8,\n    r\"$L_o = L_e + \\int_\\Omega L_i f \\cos\\theta_i \\,\\mathrm{d}\\omega_i$\"\n).generate_png(preamble)\n```\n\nIf you are using these in presentation slides, you can assemble a list of Snips in a .pptx file (uses .png conversion)\n\n```python\nfrom texsnip import Snip, pptx_snips\n\n# Here, you can modify the LaTeX preamble, for example to configure fonts.\n# We use the 'libertine' package, the fonts for the current ACM SIGGRAPH template.\npreamble = r\"\\usepackage{libertine}\"\n\nsnips = [\n    # Write the rendering equation to a file called 'rendering-equation.pdf'\n    Snip(\"rendering-equation\", 14,\n        r\"$L_o = L_e + \\int_\\Omega L_i f \\cos\\theta_i \\,\\mathrm{d}\\omega_i$\"\n    ),\n\n    # Sometimes, you need individual terms\n    Snip(\"omega_i\", 14,\n        r\"$\\omega_i$\"\n    ),\n\n    # Or you might want captions for your illustrations with LaTeX typesetting\n    Snip(\"a-caption\", 14,\n        r\"\\textsf{a) Some \\textcolor[RGB]{200,110,5}{cool} illustration}\"\n    )\n]\n\n# Lets create a snips.pptx with all these snips in it\n# This will also create the corresponding .pdf and .png files for use in other applications\npptx_snips(snips, preamble=preamble)\n```\n\n\n## Dependencies\n\n* Python >= 3.6\n* LaTeX with pdfcrop (requires Perl) and xcolor, graphicx, inputenc, fontenc\n\nTo generate .png images, you will additionally need:\n```\npip install pdf2image\n```\nwhich requires Poppler to be installed and in the path.\n\nTo generate .pptx files, you will need the .png dependencies and also:\n```\npip install python-pptx PyPDF2\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Tiny package to quickly add LaTeX text to your favorite vector graphics package.",
    "version": "1.1.0",
    "project_urls": {
        "Homepage": "https://github.com/pgrit/texsnip"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "12a6ae835ef4d2db83ba8f63bf2e25eec10a15a3fd4698be8d951de2d7ac4ba6",
                "md5": "a63cb03b1dda1b540f6c57e18dd0cb2e",
                "sha256": "7d05f9d7cc388442d3dcabffa43d07d22ad30404b05c2788cc35b805fd79ec44"
            },
            "downloads": -1,
            "filename": "texsnip-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a63cb03b1dda1b540f6c57e18dd0cb2e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 5513,
            "upload_time": "2024-01-18T09:18:29",
            "upload_time_iso_8601": "2024-01-18T09:18:29.024334Z",
            "url": "https://files.pythonhosted.org/packages/12/a6/ae835ef4d2db83ba8f63bf2e25eec10a15a3fd4698be8d951de2d7ac4ba6/texsnip-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9a8e0f274ef3e53fc570e85a845c48d95160e2ee74b8bbe81f7fb54f2998ff73",
                "md5": "baf33d6e07a73842288872832d1ba049",
                "sha256": "ae9d1ffb3365512d6c054585b7cc940bf154e7e815e28fee7f556c78f15efbfc"
            },
            "downloads": -1,
            "filename": "texsnip-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "baf33d6e07a73842288872832d1ba049",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 5125,
            "upload_time": "2024-01-18T09:18:30",
            "upload_time_iso_8601": "2024-01-18T09:18:30.634219Z",
            "url": "https://files.pythonhosted.org/packages/9a/8e/0f274ef3e53fc570e85a845c48d95160e2ee74b8bbe81f7fb54f2998ff73/texsnip-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-18 09:18:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pgrit",
    "github_project": "texsnip",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "texsnip"
}
        
Elapsed time: 0.18574s