4

I would like to add a new engine in TeXShop which is able to perform the xindy command in the following way:

texindy -g meindok.idx

I do not want to call the command every time from the command line, instead the dropdown menu integrated in TeXShop is quite comfortable. Unfortunately, I have no idea where the current engines shown in TeXShop are saved. There must have been a change since 2015 because all the posts which I found say that you have to create an engine in ~/Library/TeXShop/Engines but that path does not exist any more.

Alan Munn
  • 218,180
Andy
  • 55

2 Answers2

5

Making a texindy Engine

Here's what your texindy.engine should look like.

#! /bin/bash
PATH=/Library/TeX/texbin:/usr/local/bin:${PATH}
bfname=${1%\.*}
texindy -g "$bfname".idx

Make sure you set the executable bit on the file. In the Terminal type:

chmod +x ~/Library/TeXShop/Engines/texindy.engine

Making a texindy rule for arara

An alternative way to do this (although the two approaches are not incompatible) is to make an arara rule to run texindy. We can do this modelled after the makeindex rule given in the arara manual.

First, move the arara.engine from the Inactive folder to the Engines folder in ~/Library/TeXShop if you haven't already.

Then, you need to make a local configuration file for arara to tell it where to find your custom rules. This should be saved as ~/araraconfig.yaml (i.e., in your home folder.)

Make a directory for your local rules somewhere in your home folder. For example if you make a folder arara in your home folder you would put the following, but the folder can be anywhere (for example, mine is in my Dropbox folder so that all my Macs can find it.) You just need to specify the place in this file.

!config
paths:
- /Users/andy/arara

Now in the arara folder you've created, we can add the following rule called texindy.yaml

!config
identifier: texindy
name: texindy
command: texindy @{style} "@{ getBasename(file) }.idx"
arguments:
- identifier: german
flag: <arara> @{ isTrue( parameters.german, "-g" ) }

This is an arara rule that will allow you to call texindy with arara. I've set up the rule to be able to pass the -g option; if you need other options you will need to add them similarly to the rule.

Now in your source document you can put the following, which should do all the necessary runs for you automatically. (You may need to adjust the order.)

%!TEX TS-program = arara
% arara: pdflatex 
% arara: bibtex
% arara: pdflatex
% arara: texindy: { style: german }
% arara: pdflatex
\documentclass{book}
...
\begin{document}
...
\end{document}
Alan Munn
  • 218,180
  • Another and hopefully the last question so far: How to make an engine that executes the following other engines in that order: LaTeX, BibTeX, texindy, LaTeX, LaTeX – Andy Jun 24 '17 at 22:30
  • @Andy As I mentioned in the the other comment, it would probably be best to use latexmk for this. It is very smart and all you would need would be to create a latexmkrc file which tells it to use texindy instead of makeindex Or arara could do this too. The links I gave should give you an idea how to proceed. – Alan Munn Jun 24 '17 at 22:38
  • @Andy I've added an arara solution. – Alan Munn Jun 24 '17 at 23:06
  • Thanks again. It works perfect and does exactly what it has to do – Andy Jun 25 '17 at 06:17
2

Unless you always want to use xindy -g you may not need to do much to use pdflatexmk by creating a platexmkrc file that contains the line

$makeindex = "texindy -g %O -o %D %S";

(add a blank line after this) and place it in the same directory as the project that needs it. PS: the file has a leading 'p' in its name because it's meant to be used for a project and will be used for all files in the same directory as the file. Then place the line

% !TEX TS-program = pdflatexmk

near the top of your root .tex file. From then on using Typeset->Typeset (Cmd-T) will completely compile your document.

Alan Munn
  • 218,180
Herb Schulz
  • 3,410
  • Thanks, Herb. This is indeed simple. I didn't realize latexmk allowed project level configuration files. – Alan Munn Jun 24 '17 at 23:55
  • @AlanMunn : The TeXShop latexmk engines all allow for a project configuration file named platexmkrc with special configuration for all compilable files in a given folder. It turns out to be pretty useful for special cases. – Herb Schulz Jun 25 '17 at 17:08