3

I like latexmk but I use a variety of engines on files in the same folder. I'm trying to write a latexmkrc file that will look in the first few lines of the tex file for something like

% !TEX TS-program=xelatex

and then decide which tex engine to run for that file.

I know that the configuration variable $pdf_mode can determine which engine to use, but I'd like to do it dynamically for each target tex file. It seems like overriding the right subroutine could work. I tried reading the latexmk.pl source code, but it is several thousand lines long and I'm having trouble finding the right place.

Matthew Leingang
  • 44,937
  • 14
  • 131
  • 195
  • You can probably ask the maintainer for this as a feature request. My worry is probably that there might not be any common syntax for this. Should latexmk then also know arara syntax? – daleif Oct 20 '19 at 12:38
  • You could try DiCy instead of latexmk – DG' Oct 20 '19 at 12:45
  • From what I could understand of the source (disclaimer: I don't know Perl), this would only be possible Latexmk: 1) executes whatever is in .latexmkrc; 2) processes the command line arguments; 3) parses input files given in the command line. To have .latexmkrc parse the input file I think you would need it to do 2, 3, and then 1, otherwise .latexmkrc doesn't yet know about input files... – Phelype Oleinik Oct 20 '19 at 12:46
  • 5
    Latexmk maintainer here: This feature is on my list of things that I would like to implement in latexmk. But when that will happen I don't know – John Collins Oct 20 '19 at 15:52
  • 1
    Assuming you’re using TeXShop why not just use the xelatexmk engine? You’ll have to enable it if you haven’t done so already. Read the documentation in ~/Library/TeXShop/Engines/inactive/Latexmk. You can open ~/Library/TeXShop with the menu item in the TeXShop menu. – Herb Schulz Oct 20 '19 at 17:16
  • @JohnCollins Thanks for responding, and I'm glad this is on the list. I have some experience with perl so I may be able to contribute, if you'd be willing to point me in the right direction. Feel free to email me if you want. – Matthew Leingang Oct 21 '19 at 13:44
  • @HerbSchulz I am a long time TeXShop user, but I'm thinking of migrating to VS Code, since I use it for all my other projects. Plus I am working on something that would support non-Mac users I work with. – Matthew Leingang Oct 21 '19 at 13:46
  • 1
    @daleif latexmk's documentation says to go here first, then contact the maintainer directly. And we did get the maintainer. :-) I think that TS-program is somewhat of a standard syntax, based on this answer. It lists several IDEs that respect the directive, despite the "namespacing" prefix. – Matthew Leingang Oct 21 '19 at 13:50
  • @DG' thanks for letting me know about DiCy. I will check it out. I like latexmk because its config files are perl programs so there's a lot of flexibility. – Matthew Leingang Oct 21 '19 at 13:52
  • @MatthewLeingang I, too, use latexmk and would love to see your feature request implemented – DG' Oct 21 '19 at 14:04

0 Answers0