rstudio / tinytex

A lightweight, cross-platform, portable, and easy-to-maintain LaTeX distribution based on TeX Live
https://yihui.org/tinytex/
Other
992 stars 117 forks source link

User-defined compile engines #52

Open lgallindo opened 6 years ago

lgallindo commented 6 years ago

It would be nice to be able to pass a R function as compile engine. My goal is to be able to reuse some old makefiles and DOS-style bat files via system calls.

They are still more general than rubber, arara and latexmk, in particular if you need OS integration.

surmann commented 1 year ago

I would like to use arara to create png files out of TikZ TeX files.

@yihui Would you accept a pull request with this feature?

yihui commented 1 year ago

@surmann Yes, and could you show me a brief example so that I can understand this problem better? I don't have any experience with arara. Thanks!

surmann commented 1 year ago

@yihui This is an MWE TeX file:

% arara: lualatex: { shell: yes }
% arara: ghostscript: { resolution: 300 , allpages: true }
% Magic comments for TeXstudio
% !TeX spellcheck = en_GB
% !TeX program = lualatex

\documentclass[border=1pt, tikz]{standalone}

% additional packages
\usepackage{fontspec, lualatex-math}
\usepackage{pgfplots, tikz}
\pgfplotsset{compat=1.17}

\begin{document}
\begin{tikzpicture}
\draw (0,0) circle (2cm);
\end{tikzpicture}
\end{document}

Using tinytex::lualatex(file.tex) results in a pdf file. Sometime my collegues want to use this graphik in PowerPoint or other MS products. A know all the disadvantages but I don't want to exclude them from my graphics. Hence, I use arara, and compile the document currently via system2("arara.exe", args = "file.tex") which results in a png file. Is it possible to use arara via TinyTeX because currently, I have to switch my working directory etc.

Do you have an idea of my thoughts?

yihui commented 1 year ago

@surmann Thanks for the example! I feel the support for arara would be very similar to how tectonic is supported in https://github.com/rstudio/tinytex/blob/main/R/latex.R which should be simple enough to implement. However, I wonder what advantage tinytex::latexmk('file.tex', 'arara') has over system2("arara", "file.tex").

@lgallindo Similarly, I wonder the advantage of supporting a custom R function as the engine in tinytex::latexmk() vs just calling the function directly.

surmann commented 1 year ago

The advantage is the error handling by TinyTeX. However, my last compile test causes a TeX error but pdflatex does not handle it. It waits until I manually stop it. Currently, I use system2 and have a small handling for TeX errors. Hence, I see your point not to have an advantage for tinytex over system2.

yihui commented 1 year ago

The advantage is the error handling by TinyTeX.

I see. That makes sense.

However, my last compile test causes a TeX error but pdflatex does not handle it. It waits until I manually stop it.

I don't know why, since I don't know anything about arara.

Anyway, if you can figure out how to make arara work with TinyTeX's error handling, please feel free to submit a pull request. Thanks!

surmann commented 1 year ago

However, my last compile test causes a TeX error but pdflatex does not handle it. It waits until I manually stop it.

I don't know why, since I don't know anything about arara.

That doesn't happen with arara but with tinytex::pdflatex, and I don't know why. If this is not the expected behaviour, I would create an additional issue.