# Configure Latexmk in TeXworks for automation of bibliography compilation

I've been using LaTeX for almost four years now, so one could perhaps think I would know how to do this. But I don't. I'm at a complete loss here trying to get `latexmk` and, eventually, `BibTeX` to work.

I'm on a Windows using `TeXWorks`. I tried following this example, but with no luck. The issue is the last part - I've tried running it through `pdflatex`, then `BibTeX`and then `pdflatex` a couple of more times by simply changing in the drop-down menu. So I've been trying to get `latexmk` to work, but most guides lose me right away.

I tried following the installation instructions, but realized Perl wasn't installed. So I installed Strawberry Perl. I didn't find `C:\local\bin` so I put the files somewhere else and did step 4. Typing in `perl --version` returns perl 5, version 18. By a similar check, `latexmk` is also installed (which may or may not be because I installed it via the Package Update thing in `MikTeX`).

I then run

``````latexmk paper
latexmk -pv paper
latexmk -pv -ps paper
``````

and the last line just pops up a window saying no program was found to open the file. So I try

``````ps2pdf paper.ps paper.pdf
``````

but then there are no citations but only question marks.

Then I also found this guide which would be neat to get working. But I don't know where to find `latexmk`, and I don't know where to find where to find it either!

Maybe I explained my issue in too much detail, but for what it's worth I've at least tried to solve it on my own. Any help to get this working would be greatly appreciated.

-
Before you configure latexmk with TeXworks editor make sure it's installed properly by typing at commandline prompt `latexmk -v` or `latexmk -help` to see `10 Nov 2013.Version 4.39`. Another test is Download bib.tex and sample.bib to folder (Desktop) and open `command prompt` folder path, run `latexmk -pdf bib` to get bib.pdf –  texenthusiast Dec 12 '13 at 14:46
Thanks for the first link @texenthusiast! That looks like what I've been looking for. `latexmk -v` returns that string. When following the setup guide in your link, it afterwards say that "latexmk is not properly configured". I guess that's not referring to latexmk itself, but my typesetting tool. In the link, it says `Program: latexmk` but I don't know where to find this. Would you know how I would locate this? I'm assuming it's the .exe file? –  hejseb Dec 13 '13 at 10:05
@texenthusiast The second test worked! So I guess it's all "there", I just need to get it to start working with texworks... –  hejseb Dec 13 '13 at 10:19
Normally TeXworks has `LaTeXmk` programm near to the `Typeset` Button (if you scroll down the options) and it detects the MiKTeX bin path (No exact Idea, as I am on Linux). In the `Edit`-->`Preferences`-->`Typesetting`-->`Paths for TeX related Systems`--> Add the MiKTeX bin path something like `C:\Program Files (86)\MikTeX 2.9\miktex\bin` depending on where you installed miktex –  texenthusiast Dec 13 '13 at 13:43
@texenthusiast Thanks! It seems like it can't find the file. But I tried to manually compile my document using pdflatex, bibtex, pdflatex and then pdflatex again in the dropdown menu in Texworks and it worked and gave me my citations. Perhaps I don't need latexmk, if I just could get this sequence of compilations into some sort of code so I could add it as a typesetting tool that would be enough. Would you happen to know how to write that? If you want you can post it as an answer instead of a comment, so I can accept it too. Thanks for you help and patience with me :) –  hejseb Dec 13 '13 at 14:01

To run `Latexmk` on MiKTeX Windows with TeXworks editor:

Step 1: perl need to be installed. Since it's already installed by you. Make sure it's installed properly by typing at commandline prompt `latexmk -v` or `latexmk -help` to see current version `10 Nov 2013.Version 4.39`.

Also another test is using example files from http://www.andy-roberts.net. Download bib.tex and sample.bib to folder (`Desktop`) and open command prompt with Desktop folder path, run `latexmk -pdf bib` to get `bib.pdf`.

Step 2: Once `latexmk -pdf bib` works all fine (as perl was installed properly) from commandline prompt, then it should work from TeXworks editor also. Now Configure TeXworks editor to `Latexmk` from wiki guide of TeXworks https://code.google.com/p/texworks/wiki/AdvancedTypesettingTools#latexmk

Step 3: Normally TeXworks has `LaTeXmk` near to the `Typeset` Button in scroll down the options and it detects the MiKTeX bin path, if not Go to `Edit`-->`Preferences`-->`Typesetting`-->`Paths for TeX related Systems`--> Add the MiKTeX bin path something like `C:\Program Files (86)\MikTeX 2.9\miktex\bin` depending on where you installed miktex or typein `Path` at commandline prompt to see it's path

Note: BTW you don't need to run `latexmk` multiple times `latexmk paper latexmk -pv paper latexmk -pv -ps paper` as seen in your Q, it's 1 run enough. Basically `latexmk` is a perl script for automation of compilation sequence (`pdflatex`, `bibtex`,`pdflatex` and then `pdflatex` again).

-