Giter Club home page Giter Club logo

phpytex's Introduction

(PH(p)y)TeX

Phpytex transpiles hybrid code (ordinary LaTeX files augmented by blocks of python code) to a python script, which in turn generates a single LaTeX file (which in turn may be optionally compiled to pdf), i.e.

augmented code ⟶ python script ⟶ single .tex [⟶ pdf]

What exactly does it do? Show me examples!

Phpytex allows you interweave inline python code, python code blocks, and text blocks across multiple files, incorporating global variables and imports. It allows you to manage complex document structures and generate single file outputs. This can be demonstrated in the cases in the examples subfolder. Each case contains a set of initial files and a counterpart folder with the outputs.

Getting started

System requirements

  • Bash (windows users may install git/bash for windows)
  • Python 3 (currently developed under python 3.9.5)

Installation

Follow the instructions in install/README.md. This will enable you to call phpytex within any project containing a .phpytex.yml config file.

Usage - quick start

  • phpytex or phpytex help displays a message with the commands.
  • phpytex version displays in plain text the version number.
  • phpytex run [file=<name of config file>] runs the programme within a project using the named config file.
    If the file flag is left empty, the programme searches for the first yaml-file matching the pattern *.(phpytex|phpycreate).(yml|yaml) and uses this as the config file.

Set up of config file

To use phpytex, a .phpytex.yml file is required in the (root of) the project folder. This should contain 4 parts with the following structure:

########################################
# COMPILE OPTIONS
########################################
compile:
  root:   root.tex
  output: main.tex
  ...
########################################
# STAMP OPTIONS (optional)
########################################
stamp:
  file:      stamp.tex
  overwrite: true
  options:
    ...
########################################
# DOCUMENT PARAMETERS (optional)
########################################
parameters:
  file: src.parameters
  overwrite: true
  options:
  ...
########################################
# DOCUMENT TREE (optional)
########################################
files:
  ...
folders:
  ...

See LONGREADME.md for more details and see the examples subfolder for concrete examples.

But why Phpytex? There are lots of transpilers out there!

There are many (insert language here)-to-LaTeX transpilers available. And many of these do all sorts of fancy things like incorporate lots of extra special syntax to embed plots, etc. By contrast our transpiler is intentionally designed to be 'boring' (=sufficently general)! It has no built-in 'We can produce these cool graphics with this one command!'1 selling point.

And neither—in our opinion—does it need to.

By our philosophy, the only things a transpiler should do are:

  • assume the user can already use {python,LaTeX};
  • not burden the user with a bunch of extra syntax beyond an absolute minimum (e.g. markdown languages achieve this wonderfully);
  • reliably incorporate the full generality of features of an ordinary (python) coding project; and
  • leave the bells-and-whistles (generation of graphics, usage of complex mathematical objects, data-frames, etc.) completely over to the user's imagination and mastery of both languages.

That is, transpilation allows the user to marry the two languages with little effort but in as generic a manner as possible, leaving the specific applications over to the user.

Furthermore Phpytex was originally conceived for the personal reason to

  • allow the user to easily manage complex folder structures and generate a single-file-output.

And this shall remain a cornerstone feature of Phpytex.






[1] But incidentally, with Phpytex one can do this and just about any such task. The user simply has to program their own methods, say a python function makegraphics(...) in a code block or an importable script, and ensure this method takes desired inputs and either generates an image and returns suitable LaTeX command to include this, or returns a series of LaTeX commands (e.g. tikz commands) to produce the image natively in LaTeX.

One can clearly make a standard suite of such functions. But creating such things should not be in the scope of a good, sufficiently general, transpiler, but rather of package development.

phpytex's People

Contributors

rlogik avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.