Coder Social home page Coder Social logo

runtexshebang's Introduction

runtexshebang: Lua script running LaTeX document files with TeX-style shebang

Lua script running LaTeX document files with a TeX-style shebang (%#!)

What is a TeX-style shebang (%#!)

In short, a TeX-style shebang (%#!) is a special kind of TeX comment that you include in your TeX/LaTeX document file to tell the operating system's shell how to run the file for the rest of the file:

%#!lualatex foo.tex
\documentclass{article}
\begin{document}
Hello, {\LaTeX} World!

Happy {\TeX}ing.
\end{document}

If you are using a TeX-style shebang, it must appear on the line that matched 20 lines or less in your LaTeX document, and it has to start with a TeX comment symbol (%) followed by a hash sign (#) and an exclamation mark (!), colloquially known as the bang, hence the name shebang for TeX/LaTeX.

Getting started

1. Install runtexshebang.lua in your TeX Live system.

cp runtexshebang.lua /some/where/TEXMFDIST_or_TEXMFLOCAL/scripts/runtexshebang/runtexshebang.lua

cd TEXLIVE_BIN_DIRECTORY
ln -s ../../TEXMFDIST_or_TEXMFLOCAL/scripts/runtexshebang/runtexshebang.lua runtexshebang

2. Make a sample file with a TeX-style shebang.

Make the following LaTeX document.

%#!lualatex foo.tex
\documentclass{article}
\begin{document}
Hello, {\LaTeX} World!

Happy {\TeX}ing.
\end{document}

3. Run the sample file.

runtexshebang foo.tex

Then, it will run lualatex foo.tex.

Examples

TeXworks

Settings

  1. Open "Typesetting" tab in TeXworks Preferences.
  2. Add the tool configuration "runtexshebang" in "Processing tools" as below. - Name: runtexshebang - Program: runtexshebang - Arguments: $fullname - ☑ View PDF after running (if necessary)

LaTeX document in the internal editor of TeXwork

% !TEX program = is a magic comment of TeXworks. You can set one processing tool as % !TEX program = <your choice of tool configuration>.

% !TEX program = runtexshebang
%#! lualatex --synctex=1 foo

LaTeX Workshop: Visual Studio Code

Settings

Nothing!

LaTeX document in Visual Studio Code

% !TEX program = is a magic comment of LaTeX Workshop. You need another magic comment to the target LaTeX document file as below.

% !TEX program = runtexshebang
% !TEX options = "%DOC%".tex
%#! lualatex --synctex=1 foo

TeXShop

Settings

There the “Engine” settings for the command lines "TeX+dvipdfmx / TeX+dvips+distiller" as follows.

  • TeX: runtexshebang
  • LaTeX: runtexshebang

LaTeX document in the internal editor of TeXShop

% !TEX program = is a magic comment of TeXShop.

% !TEX program = runtexshebang
%#! lualatex --synctex=1 foo

Applications

What does the PATH variable set in my editor?

%#! echo $PATH

How about general configuration information for the activated TeX Live version and its configuration in my editor?

%#! tlmgr conf

Otherwise

You can run any command line on your OSs. For example, you can use any build tools as follows: make, rake, llmk, latexmk, and so on.

%#! make foo.pdf

% #! rake foo.pdf
% #! llmk
% #! latexmk foo
%% and so on.

You can typeset a LaTeX document file in a Docker container as below.

%#! docker run -i --rm --workdir /data --mount type=bind,src=$(pwd)/,dst=/data/   bar/foo     lualatex foo

References

Commentary

Tools supporting %#!

  • YaTeX: Yet Another TeX mode for Emacs
  • llmk: Light LaTeX Make

Enjoy Happy TeXing!

License

This program is licensed under the terms of the MIT License.


Munehiro Yamamoto https://github.com/munepi

runtexshebang's People

Contributors

munepi avatar

Watchers

 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.