ptyx


Nameptyx JSON
Version 29.1.0 PyPI version JSON
download
home_pagehttps://github.com/wxgeo/ptyx
SummarypTyX is a python precompiler for LaTeX.
upload_time2024-11-08 22:12:50
maintainerNone
docs_urlNone
authorNicolas Pourcelot
requires_python<4.0,>=3.10
licenseGPL-3.0-or-later
keywords python tikz latex pdf exam mcq student
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            pTyX
====

Overview
--------
pTyX is a LaTeX precompilator, written in Python.
pTyX enables to generate LaTeX documents, using custom commands or plain python code.
One single pTyX file may generate many latex documents, with different values.
I developped and used pTyX to make several different versions of a same test in exams,
for my student, to discourage cheating.
Since it uses sympy library, pTyX has symbolic calculus abilities too.

Installation
------------
pTyX is only tested on GNU/Linux (Ubuntu), but should work on MacOs X too.

Obviously, pTyX needs a working Python installation.
Python version 3.8 (at least) is required for pTyX to run.

pTyX also needs a working LaTeX installation. Command *pdflatex* must be available in your terminal.

The easiest way to install it is using pip.

    $ pip install ptyx

You may also download and install the latest version from Github:

    $ git clone https://github.com/wxgeo/ptyx.git
    $ cd ptyx
    $ pip install -e .

Usage
-----

To compile a pTyX file (see below), open a terminal, go to pTyX directory, and write:

    $ ptyx my_file.ptyx

For more options:

    $ ptyx --help


pTyX file specification
-----------------------
A pTyX file is essentially a LaTeX file, with a .ptyx extension, (optionally) some custom commands, and embedded python code.

To include python code in a pTyX file, use the #PYTHON and #END balise.
A special *write()* command is available, to generate latex code on the flow from python.

    This a simple \emph{addition}:\quad
    #PYTHON
    from random import randint
    a = randint(5, 9)
    b = randint(2, 4)
    write('%s + %s = %s\\' % (a, b, a + b))
    #END
    Now, some basic \emph{subtraction}:\quad
    #PYTHON
    write('%s - %s = %s\\' % (a, b, a - b))
    #END

To access any python variable outside python code scope, simply add a hashtag before the variable name.

Any valid python expression can also be evaluated this way, using syntax #{python_expr}.

    $#a\mul#b=#{a*b}$

However, pTyX has also reserved tags, like conditionals statements #IF, #ELSE, #ENDIF...

(More to come...)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/wxgeo/ptyx",
    "name": "ptyx",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "python, tikz, latex, pdf, exam, mcq, student",
    "author": "Nicolas Pourcelot",
    "author_email": "nicolas.pourcelot@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/89/f1/31413f1613d6f36094ffac5ae30056b8ffcb865134bb5465986a8f4c073e/ptyx-29.1.0.tar.gz",
    "platform": null,
    "description": "pTyX\n====\n\nOverview\n--------\npTyX is a LaTeX precompilator, written in Python.\npTyX enables to generate LaTeX documents, using custom commands or plain python code.\nOne single pTyX file may generate many latex documents, with different values.\nI developped and used pTyX to make several different versions of a same test in exams,\nfor my student, to discourage cheating.\nSince it uses sympy library, pTyX has symbolic calculus abilities too.\n\nInstallation\n------------\npTyX is only tested on GNU/Linux (Ubuntu), but should work on MacOs X too.\n\nObviously, pTyX needs a working Python installation.\nPython version 3.8 (at least) is required for pTyX to run.\n\npTyX also needs a working LaTeX installation. Command *pdflatex* must be available in your terminal.\n\nThe easiest way to install it is using pip.\n\n    $ pip install ptyx\n\nYou may also download and install the latest version from Github:\n\n    $ git clone https://github.com/wxgeo/ptyx.git\n    $ cd ptyx\n    $ pip install -e .\n\nUsage\n-----\n\nTo compile a pTyX file (see below), open a terminal, go to pTyX directory, and write:\n\n    $ ptyx my_file.ptyx\n\nFor more options:\n\n    $ ptyx --help\n\n\npTyX file specification\n-----------------------\nA pTyX file is essentially a LaTeX file, with a .ptyx extension, (optionally) some custom commands, and embedded python code.\n\nTo include python code in a pTyX file, use the #PYTHON and #END balise.\nA special *write()* command is available, to generate latex code on the flow from python.\n\n    This a simple \\emph{addition}:\\quad\n    #PYTHON\n    from random import randint\n    a = randint(5, 9)\n    b = randint(2, 4)\n    write('%s + %s = %s\\\\' % (a, b, a + b))\n    #END\n    Now, some basic \\emph{subtraction}:\\quad\n    #PYTHON\n    write('%s - %s = %s\\\\' % (a, b, a - b))\n    #END\n\nTo access any python variable outside python code scope, simply add a hashtag before the variable name.\n\nAny valid python expression can also be evaluated this way, using syntax #{python_expr}.\n\n    $#a\\mul#b=#{a*b}$\n\nHowever, pTyX has also reserved tags, like conditionals statements #IF, #ELSE, #ENDIF...\n\n(More to come...)\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-or-later",
    "summary": "pTyX is a python precompiler for LaTeX.",
    "version": "29.1.0",
    "project_urls": {
        "Homepage": "https://github.com/wxgeo/ptyx",
        "Repository": "https://github.com/wxgeo/ptyx"
    },
    "split_keywords": [
        "python",
        " tikz",
        " latex",
        " pdf",
        " exam",
        " mcq",
        " student"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9d7f57064305c11994d7b19136c665a00aca7574fe16a2ca66abb66bb201f883",
                "md5": "7caf75774dbba266cbffaf128af786b7",
                "sha256": "46a32cc1a51f1fff297936b7a2201928339835cde2e0c2dacc66961005534033"
            },
            "downloads": -1,
            "filename": "ptyx-29.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7caf75774dbba266cbffaf128af786b7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 73986,
            "upload_time": "2024-11-08T22:12:49",
            "upload_time_iso_8601": "2024-11-08T22:12:49.019486Z",
            "url": "https://files.pythonhosted.org/packages/9d/7f/57064305c11994d7b19136c665a00aca7574fe16a2ca66abb66bb201f883/ptyx-29.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "89f131413f1613d6f36094ffac5ae30056b8ffcb865134bb5465986a8f4c073e",
                "md5": "aa09d0271c2a5e19f2bd05eb8b43245c",
                "sha256": "0a22dfdad9b457091bf81f4e071df49100885c0c0f446c957bda2a4aa52f7484"
            },
            "downloads": -1,
            "filename": "ptyx-29.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "aa09d0271c2a5e19f2bd05eb8b43245c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 67016,
            "upload_time": "2024-11-08T22:12:50",
            "upload_time_iso_8601": "2024-11-08T22:12:50.326460Z",
            "url": "https://files.pythonhosted.org/packages/89/f1/31413f1613d6f36094ffac5ae30056b8ffcb865134bb5465986a8f4c073e/ptyx-29.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-08 22:12:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "wxgeo",
    "github_project": "ptyx",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "ptyx"
}
        
Elapsed time: 0.42306s