mate-desktop / pluma

A powerful text editor for MATE
http://www.mate-desktop.org
GNU General Public License v2.0
158 stars 66 forks source link

Idea: Add pdfLaTeX template to external tools plugin #661

Open spixi opened 2 years ago

spixi commented 2 years ago

The external tools plugin adds support to run external commands. It already has some templates like a Build command, which runs make or a Remove trailing spaces command which removes whitespace characters from the document using sed.

I wrote that little script to enable pdfLaTeX integration. This template could be added as default.

#!/bin/sh
if test "$PLUMA_CURRENT_DOCUMENT_TYPE" = "text/x-tex"; then
    OUTFILE=`pdflatex -interaction=nonstopmode -halt-on-error $PLUMA_CURRENT_DOCUMENT_PATH | grep "Output written" | cut -d" " -f4`
    exec xdg-open $OUTFILE
fi
andrewfowlie commented 1 year ago

Looks good, though how about latexmk to handle bibtex etc?

spixi commented 1 year ago

Looks good, though how about latexmk to handle bibtex etc?

I have never used latexmk. It sounds like a good idea, but requires more preparation. I know that you sometimes have to call pdflatex multiple times when you use packages like hyperref (or packages which depend on hyperref, like beamer). I personally prefer biber, because it has more features like full Unicode support and the related= key, but bibtex is also fine. Feel free to expand the script to grep the pdflatex output for messages like "Package biblatex Warning: Please (re)run Biber on the file" if you want.

andrewfowlie commented 1 year ago

Something like the following,

#!/bin/sh
if test "$PLUMA_CURRENT_DOCUMENT_TYPE" = "text/x-tex"; then
  (
    cd $PLUMA_CURRENT_DOCUMENT_PATH
    latexmk 
  )
fi

a user could customize the build behavior through a .latexmkrc file in their $PLUMA_CURRENT_DOCUMENT_PATH directory or through a global rc file in their $HOME directory. latexmk automatically takes care running bibtex, pdflatex multiple times etc etc.