1.1.1 LaTeXmk
As mentioned in the previous section, latexmk is a Perl script that automates the process of building a LaTeX document. In order to use latexmk, you must have Perl installed (see Volume 1). Both TeX Live and MikTeX come with latexmk but, if for some reason you don't have it installed, you can use the TeX Live or MikTeX update manager to install it. Alternatively, you can download http://mirror.ctan.org/support/latexmk.zip and install it manually.
Once latexmk is installed, you then need to add it to the list of available tools in TeXworks1.2. This is done via the Edit→Preferences menu item. This opens TeXwork's Preferences dialog box. Make sure the “Typesetting” tab is selected (Figure 1.4).
To add a new tool, click on the lower button next to the list of processing tools. This opens the tool configuration dialog box (Figure 1.5).
Type “LaTeXmk” in the “Name” box, then use the “Browse” button to locate latexmk on your computer. Next you need to click on the button to add each argument. The argument list should consist of the following (in the order listed):
-e $pdflatex=q/pdflatex $synctexoption %O %S/ -pdf -bibtex $fullname
Once you've done this, click “Okay” to close the tool configuration dialog, and click “Okay” to close the Preferences dialog box. LaTeXmk should now be listed in the drop-down menu next to the green “Typeset” button. Now, if you have LaTeXmk selected and you click on the “Typeset” button pdflatex and bibtex/biber will be run as necessary to create an up-to-date PDF.
Unfortunately, adding makeindex, texindy or
makeglossaries to LaTeXmk's set of rules is more
complicated. For this you need to create a configuration/initialisation (RC) file1.3. The
name and location of this file depends on your operating system. For
example, on a Unix-like operating system, this may be
$HOME/.latexmkrc
. You will need to consult the
latexmk manual [1] for further details.
Once you've found out the name and location of the RC file for your operating system, you can use the text editor of your choice to create this file. To add makeglossaries, you need to type the following in the RC file:
add_cus_dep('glo', 'gls', 0, 'makeglossaries'); add_cus_dep('acn', 'acr', 0, 'makeglossaries'); sub makeglossaries{ system( "makeglossaries \"$_[0]\"" ); }
To add makeindex, you need to type the following:
add_cus_dep('idx', 'ind', 0, 'makeindex'); sub makeindex{ system("makeindex \"$_[0].idx\""); }
If you prefer to use texindy instead of makeindex, you will need to replace the above lines with (change the language as appropriate):
add_cus_dep('idx', 'ind', 0, 'texindy'); sub texindy{ system("texindy -L english \"$_[0].idx\""); }
Now select “LaTeXmk” from the drop-down menu next to the green “Typeset” button in TeXworks (Figure 1.6), and you're ready to build your documents.
Footnotes
- ... TeXworks1.2
- If you are using a different front-end, you will have to consult your front-end's manual.
- ... file1.3
- There are some example RC files available at: http://mirror.ctan.org/support/latexmk/example_rcfiles/.
This book is also available as A4 PDF or 12.8cm x 9.6cm PDF or paperback (ISBN 978-1-909440-02-9).