GithubHelp home page GithubHelp logo

nilqed / latex2sixel Goto Github PK

View Code? Open in Web Editor NEW
24.0 4.0 2.0 402 KB

LaTeX to SIXEL conversion

License: BSD 2-Clause "Simplified" License

Shell 100.00%
latex sixel-graphics sixel computer-algebra-system pure fricas maxima

latex2sixel's Introduction

LaTeX to SIXEL

Sixel graphics is well suited to display images on terminals (emulation) like Mintty (Cygwin), mlterm or Xterm. Thanks to Hayaki Saito's libsixel, we can easily convert almost any format to sixel sequences (e.g. img2sixel).

ltx1

latex2sixel

This simple shell script converts (La)TeX chunks to sixel output by the following composition of tools:

  latex [dvi] --> dvipng [png] --> img2sixel  

Therefore, the requirements to render LaTex chunks to a sixel graphics capable console/terminal are as follows:

  • LaTeX distribution
  • dvipng (usually already included)
  • libsixel (see Install)
  • Sixel capable terminal
$ latex2sixel

This is latex2sixel V 1.0.2 (Mon Apr 11 15:59:19 CEST 2022)

Usage: ./latex2sixel [OPTION]... TEXSTRING
Options are chosen to be similar to dvips' options where possible:

  -D #         Output resolution
  -O c         Image offset
  -T c         Image size (also accepts '-T bbox' and '-T tight')

  -bg s        Background color (TeX-style color or 'Transparent')
  -fg s        Foreground color (TeX-style color)

  -h | --help  Help

  # = number   s = string
  c = comma-separated dimension pair (e.g., 3.2in,-32.1cm)

  TEXSTRING is a LaTeX expression betweeen apostrophes (not quotes).
  Examples: '$\alpha$' | '\LaTeX' | 'This is math: $x+y$'.

Required applications: latex, dvipng, img2sixel.
Terminals supporting sixel graphics: xterm -ti vt340, mintty, mlterm.
More info @  https://github.com/saitoha/libsixel


The script is just a skeleton and may be adjusted to your needs.

Installation

Just copy the file(s) in the script directory to a folder in the path, e.g. /usr/local/bin or .local/bin.

Examples

latex2sixel '$-\frac{\hbar^2}{2m}\,\Delta\psi+V\,\psi=E\,\psi$'
latex2sixel \\partial{T}\(\\phi\)=T\(d\\phi\)
latex2sixel '$$\int_{\partial\Omega}\omega=\int_\Omega\,d\omega$$'
latex2sixel '\LaTeX\ is\ cool :)'

latex2sixel '$$\sum_{j=0}^N q^j=\frac{q^{N+1}-1}{q-1}$$'
latex2sixel '$$\forall x\in\mathbb{Z},\exists y\in\mathbb{Z}:x+y=0$$'

mintty

Applications

A lot of mathematical software is able to produce TeX output, e.g. computer algebra systems (CAS) like FriCAS (Axiom), Maxima, Reduce, Sage, Sympy and a lot more. Many OO languages like Python or Pure have the capability to render the objects by a special representation field.
Certain applications, however, need a special treatment, that is for instance a preamble or macro definitions which should be prepended to the input. The script fricas2sixel is such an example. When we define the function

sixel(x:TexFormat):Void ==
  cmd:=concat ["system fricas2sixel -bg Black -D 150 -fg Orange '",tex(x).1,"'"]
  systemCommand(cmd)

we can render almost any expression as its LaTex representation in the console:

sixel-fricas

The function can be included into the startup file (.fricas.input), then the usage is: sixel expression.

fricas-xterm

Another example is Pure:

pure

For details consult the sample file sixel.pure in the samplefolder.

GnuPlot

GnuPlot is a portable command-line driven graphing utility for Linux, OS/2, MS Windows, OSX, VMS, and many other platforms. It can produce sixel output. It also provides an easy mean to check if your terminal is capable to display sixel output: gnuplot> test

gp1

gp2

gp3

gp4

gp0

Calibration

gp5

gp6


p7

p8

latex2sixel's People

Contributors

nilqed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.