External tools
Running a custom external tool before a LaTeX compilation
To run any external tool every time before compiling a LaTeX file, see Run configuration settings.
Makeindex
Since b0.6.7
When you create a run configuration from context (for example using the button next to \begin{document}
or the shortcut Ctrl + Shift + F10) then TeXiFy will look whether you need to run makeindex, xindy, makeglossaries, etc., and when needed create the necessary run configurations automatically. Makeindex is only run when you actually include an index package like imakeidx
or a glossary package like makeglossaries
.
Makeindex will be run as a separate configuration, so you will see the output in a window next to your normal LaTeX output window. When you use the auxil/
or out/
directories, makeindex will be run there and the .ind
file will be copied next to your main file so that the index package can find it. It will be cleaned up as well to avoid cluttering your source directory, unless you copied it there manually (indicating you want to commit it to git, for example).
Note that when you use imakeidx
but no auxil/
or out/
then imakeidx will handle makeindex itself.
If you use xindy but no auxil/
or out/
then in order to allow imakeidx to run xindy, you need to provide the -shell-escape
custom compiler argument in the run configuration.
Example with an index using makeindex:
TeXiFy also supports using xindy (instead of makeindex) and a custom index name, for example:
See the imakeidx documentation at https://ctan.org/pkg/imakeidx for more details. Note that in order to use xindy to need to install Perl.
nomencl
Also the nomencl package is supported in the same way, as it uses makeindex. Example from the nomencl documentation:
Input index file filename.idx not found.
If you use an auxiliary directory (auxil/ or out/) then you may get an error message from imakeidx saying Input index file filename.idx not found.
. You can ignore it, because TeXiFy handles makeindex, but imakeidx doesn’t know that and it will try to handle makeindex itself. You can tell imakeidx to not worry about it with the noautomatic
option, so write \makeindex[noautomatic]
.
Glossary examples
Since b0.7.1
The glossaries
package Beginners' guide contains four options of building a glossary. For completeness we repeat these examples below, so you can easily copy paste and run them.
Option 1, using LaTeX.
Option 2, using makeindex.
Option 3, using xindy (so Perl is required).
Option 4, using bib2gls (requires at least Java 8).
Bonus example: you can even use both an index and a glossary.
Built-in
The run configuration External LaTeX Tool can be used to run other auxiliary tools which need to run inbetween LaTeX runs. Please raise an issue on GitHub if your favourite tool is missing here. Currently, the following tools are supported.
Pythontex
Since b0.7.2
Pythontex is a LaTeX package which can, among other things, run Python code which you included in your LaTeX file and nicely format the code and the output as well.
Sage
Since v2.0.0
To use Sage, you need to have Sagemath installed. On some operation systems, you might need to install sagetex separately (for Arch there is the sagetex
package, for example). Then, make sure the package is found, for example by adding TEXINPUTS=/usr/share/texmf//:
to your run configuration, assuming the package is located there. Now you can add \usepackage{sagetex}
and TeXiFy should be able to find it. Then you can use sagetex commands, for example \sage{EllipticCurve(GF(409),[1,2]).order()}
, and run the file.
If the run configuration is not created correctly the first time, you need to make sure to first run pdflatex, then a general command line step to run sage main.sagetex.sage
, then pdflatex again.
Jinja2 support
Jinja2 is a templating language, so you can write special commands in LaTeX which will be replaced by actual valid LaTeX by a certain Python script. The difference with using e.g. lualatex or simply outputting LaTeX from Python is that you can still do the formatting in LaTeX, and from the Python script you only give the raw data to be typeset to the LaTeX file (taking an abstract point of view).
PyCharm supports Jinja2 by default, you can enable it for LaTeX by going to https://www.jetbrains.com/help/pycharm/template-languages.html
and add LaTeX source file as language. Also seeThen you can write for example a LaTeX file containing
and note that you have basic autocompletion and syntax highlighting on the Jinja2 commands.
Then you can use a Python file like
which will produce a rendered LaTeX file. Now you can run the Python file to check that it works, run the produced LaTeX file using TeXiFy, and when it works you can edit the LaTeX run configuration to add under Before launch
the Python run configuration.
If at any time you encounter problems because Jinja is not interpreting the LaTeX correctly, you can use different Jinja delimiters. For example, as given by this blog post you can use
and
to get the same result.