Skip to content

Freed-Wu/texrocks

Repository files navigation

texrocks

readthedocs pre-commit.ci status github/workflow codecov DeepSource

github/downloads github/downloads/latest github/issues github/issues-closed github/issues-pr github/issues-pr-closed github/discussions github/milestones github/forks github/stars github/watchers github/contributors github/commit-activity github/last-commit github/release-date

github/license github/languages github/languages/top github/directory-file-count github/code-size github/repo-size github/v

luarocks

A (La)TeX package manager powered by luarocks and luaTeX.

Usage

LuaTeX

A minimal example:

\hoffset-1in
\voffset-1in
\hsize30mm
\pagewidth\hsize
\vsize20mm
\pageheight\vsize
\parindent0mm

Hello, \TeX!
$$\sum_{n = 1}^\infty{1\over{n^2}} = {\pi^2\over6}$$

\bye
texrocks install luatex
luatex examples/tex/plain/minimal.tex

luatex

LuaLaTeX

A minimal example:

\renewcommand\normalsize{\fontsize{10pt}{12pt}\selectfont}
\title{minimal}
\setlength\hoffset{-1in}
\setlength\voffset{-1in}
\setlength\oddsidemargin{0pt}
\setlength\topmargin{0pt}
\setlength\headheight{0pt}
\setlength\headsep{0pt}
\setlength\textheight{20mm}
\setlength\pageheight{\textheight}
\setlength\textwidth{40mm}
\setlength\pagewidth{\textwidth}
\setlength\parindent{0mm}
\begin{document}

Hello, \LaTeX!
$$\sum_{n = 1}^\infty\frac1{n^2} = \frac{\pi^2}{6}$$

\end{document}
texrocks install lualatex
lualatex examples/tex/latex/minimal.tex

lualatex

LaTeX require some required packages. You can install them by yourself.

Some packages are recommended:

More packages.

A more complicated example:

\documentclass[tikz]{standalone}
\usetikzlibrary{arrows.meta, quotes, graphs, graphdrawing, shapes.geometric}
\usegdlibrary{layered}
\usepackage{hyperref}
\usepackage{hologo}
\title{graph}
\begin{document}
\begin{tikzpicture}[rounded corners, >=Stealth, auto]
  \graph[layered layout, nodes={draw, align=center}]{%
    "\TeX" -> "\hologo{eTeX}" -> "\hologo{pdfTeX}" -> "\hologo{LuaTeX}";
    "\hologo{eTeX}" -> "\hologo{XeTeX}"
  };
\end{tikzpicture}
\end{document}

graph

TeXinfo

A minimal example:

@hoffset-1in
@voffset-1in
@node Top
@top Example

@node First Chapter
@nodedescription The first chapter is the only chapter in this sample.
@chapter Hello, @TeX{info}

@cindex chapter, first
This is the first chapter.
@bye
texrocks install texinfo
texinfo examples/tex/texinfo/minimal.tex
dvipdfmx minimal.dvi
pdftocairo -png minimal.pdf
magick convert minimal-1.png -crop 50%x10% minimal.png

texinfo

texdoc

texrocks install texdoc

Note, texdoc need a tlpdb database. Download it to ~/.local/share/texmf/texdoc/Data.tlpdb.lua. Then create ~/.local/share/texmf/texdoc/texdoc.cnf:

texlive_tlpdb = /home/user_name/.local/share/texmf/texdoc/Data.tlpdb.lua

Now it can work:

$ texdoc impatient
You don't appear to have any local documentation installed.

There may be online documentation available for "impatient" at
    https://texdoc.org/serve/impatient/0
This documentation may be for a different version than you have installed.

Would you like to search online? (y/N) y

https://texdoc.org/serve/impatient/0 is opened.

l3build

texrocks install l3build

texluap

Sometimes you need a REPL to debug luatex. you can refer texluap:

texrocks install prompt-style

Install

luarocks --lua-version=5.3 install texrocks

luarocks version must be > 3.11.1-1 to support build_dependencies. The latest is dev-1.

Configure

By default:

~/.config/texmf/init.lua:

local home = os.getenv('HOME')
rocks_path = home .. '/.luarocks',
luarocks_config_path = home .. '/.luarocks/config-5.3.lua'
luarocks_binary = 'luarocks'

Where:

  • all rocks will be installed to rocks_path
  • will use luarocks_config_path to configure luarocks_binary. See config

By default, ~/.local/share/texmf/fonts/map/luatex.map and ~/.local/share/texmf/web2c/texmf.cnf will be generated to configure luatex.

You can use ~/.config/texmf/fonts/map/luatex.map and ~/.config/texmf/web2c/texmf.cnf to override it.

Package

Version

Github release can tag version while CTAN cannot. Such as:

Formats

TeX packages have two formats:

  • source package *-ctan.zip, like:
    • lua: *.src.rock
    • python : sdist *.tar.gz
  • binary package *.tds.zip, like:
    • lua: *.any.rock, *.win-x86_64.rock
    • python: *-any.whl, *-win_amd64.whl

Like converting typescript to javascript, we need convert *-ctan.zip's *.dts and *.ins to *.tds.zip's *.cls and *.sty. We package *.tds.zip to skip converting, like npmjs.org packages only contain *.js not *.ts.

A lua package *.linux-x86_64.rock contains some files which will be installed to ~/.luarocks:

  • lua/foo.lua: ~/.luarocks/share/lua/5.3/foo.lua, lua module
  • lib/foo.so: ~/.luarocks/lib/lua/5.3/foo.so, lua binary module
  • bin/foo: ~/.luarocks/lib/luarocks/rocks-5.3/foo/1.0.0-1/bin/foo, executable program, and luarocks will generate a shell wrapper ~/.luarocks/bin/foo. You need to add it to $PATH.
  • doc/README.md: ~/.luarocks/lib/luarocks/rocks-5.3/foo/1.0.0-1/doc/README.md
  • doc/LICENSE: ~/.luarocks/lib/luarocks/rocks-5.3/foo/1.0.0-1/doc/LICENSE
  • foo-1.0.0-1.rockspec: ~/.luarocks/lib/luarocks/rocks-5.3/foo/1.0.0-1/foo-1.0.0-1.rockspec, package build script
  • rock_manifest: ~/.luarocks/lib/luarocks/rocks-5.3/foo/1.0.0-1/rock_manifest, package manifest

We repackage *.tds.zip to:

  • doc/{generic,plain,latex,luatex,lualatex}/foo/foo.pdf: ~/.luarocks/lib/luarocks/rocks-5.3/foo/1.0.0-1/doc/{generic,plain,latex,luatex,lualatex}/foo/foo.pdf, document for texdoc foo in shell
  • tex/{latex,lualatex}/foo/foo.sty: ~/.luarocks/lib/luarocks/rocks-5.3/foo/1.0.0-1/tex/{latex,lualatex}/foo/foo.sty, LaTeX macro package for \usepackage{foo} in LaTeX *.tex
  • tex/latex/foo/foo.cls: ~/.luarocks/lib/luarocks/rocks-5.3/foo/1.0.0-1/tex/latex/foo/foo.cls: LaTeX document class for \documentclass{foo} in LaTeX *.tex
  • tex/generic/foo/foo.cfg: ~/.luarocks/lib/luarocks/rocks-5.3/foo/1.0.0-1/tex/generic/foo/foo.cfg, configuration for \input foo.cfg in LaTeX *.cls and *.sty
  • tex/{generic,plain}/foo/foo.tex: ~/.luarocks/lib/luarocks/rocks-5.3/foo/1.0.0-1/tex/{generic,plain}/foo/foo.tex, TeX source for \input foo.tex in LaTeX/plainTeX *.tex
  • tex/luatex/foo/foo.lua: ~/.luarocks/share/lua/5.3/foo.lua, lua scripts for \directlua{require'foo'} in LuaLaTeX/LuaTeX *.tex
  • tex/scripts/foo/foo.lua: ~/.luarocks/lib/luarocks/rocks-5.3/foo/1.0.0-1/bin/foo, lua scripts with #!/usr/bin/env texlua
  • tex/scripts/foo/foo-bar.lua: ~/.luarocks/share/lua/5.3/foo-bar.lua, lua scripts for require'foo-bar' in ~/.luarocks/lib/luarocks/rocks-5.3/foo/1.0.0-1/bin/foo
  • fonts/type1/foo/foo.pfb: ~/.luarocks/lib/luarocks/rocks-5.3/foo/1.0.0-1/fonts/type1/foo/foo.pfb
  • fonts/source/foo/foo.mf: skip source code of metafont
  • source/foo/foo.dts: skip source code of LaTeX. docstrip can convert *.dtx to document *.pdf
  • source/foo/foo.ins: skip source code of LaTeX. docstrip can convert *.ins to *.sty, *.cls, *.tex and *.cfg
  • source/foo/foo.tl: skip source code of lua, tl can convert *.tl to *.lua
  • source/foo/foo.ts: skip source code of lua. TypeScriptToLua can convert *.ts to *.lua

Dependencies

*.tds.zip doesn't have meta information about packages. when we create *.rockspec, we need to add it from CTAN.

CTAN doesn't provide dependence information. You need search it. e.g.,

tex/latex/base/ltnews.cls:

% ...
\IfFileExists{hyperref.sty}{%
  \RequirePackage[hidelinks]{hyperref}}{}
% ...

hyperref is an optional dependency of latex-base.

Build Dependencies

Some TeX packages don't provide *.tds.zip. You have to build it from *.ctan.zip.

texrocks install &&
  lualatex --interaction=nonstopmode foo.ins

or:

l3build ctan

add { 'texrocks', 'lualatex', 'latex-base' } or { 'l3build', 'latex-base' } to build_dependencies.

Credit

  • rocks.nvim: a neovim package manager powered by luarocks
  • apltex: inspiration origin