ptyx


Nameptyx JSON
Version 28.2.0 PyPI version JSON
download
home_pagehttps://github.com/wxgeo/ptyx
SummarypTyX is a python precompiler for LaTeX.
upload_time2024-02-09 14:40:56
maintainer
docs_urlNone
authorNicolas Pourcelot
requires_python>=3.10,<4.0
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": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "python,tikz,latex,pdf,exam,mcq,student",
    "author": "Nicolas Pourcelot",
    "author_email": "nicolas.pourcelot@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/99/25/4c3a98d462a8584666f39468ff35aff7699e76230b610b9560ad0597a6a1/ptyx-28.2.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": "28.2.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": "632571e518ce211a6ed283e0daaf81c15745e961ee2eadb2ed240fb2442f1799",
                "md5": "29a2cfc4eaa3b2456ba2ab64e810476d",
                "sha256": "2e5ab69d33b26ae108957fb0dca8ef67627ddaed319f9f50c5a9b11aa1aa6eac"
            },
            "downloads": -1,
            "filename": "ptyx-28.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "29a2cfc4eaa3b2456ba2ab64e810476d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 71776,
            "upload_time": "2024-02-09T14:40:54",
            "upload_time_iso_8601": "2024-02-09T14:40:54.715185Z",
            "url": "https://files.pythonhosted.org/packages/63/25/71e518ce211a6ed283e0daaf81c15745e961ee2eadb2ed240fb2442f1799/ptyx-28.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "99254c3a98d462a8584666f39468ff35aff7699e76230b610b9560ad0597a6a1",
                "md5": "707e4643870e30d12d438fd23c223afa",
                "sha256": "d2d05e1b3a961f8e8bc7c981031e6a74296b5761b4755474dea0fec40ed7fb28"
            },
            "downloads": -1,
            "filename": "ptyx-28.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "707e4643870e30d12d438fd23c223afa",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 64951,
            "upload_time": "2024-02-09T14:40:56",
            "upload_time_iso_8601": "2024-02-09T14:40:56.764574Z",
            "url": "https://files.pythonhosted.org/packages/99/25/4c3a98d462a8584666f39468ff35aff7699e76230b610b9560ad0597a6a1/ptyx-28.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-09 14:40:56",
    "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.17888s