# How to automate using biber in MiKTeX-TeXworks

I have MikTeX 2.9, 32-bit, Windows 7, all the latest updates are there. I'm using TeXworks ( `pdflatex` + `makeindex` + `bibtex`).

When I use `biblatex` package with option `[backend=biber]` I have no bibliography printed at all. If I run `biber.exe` over my file manually, then everything works fine.

My question is: How can I set up TeXworks, so it uses `biber.exe` when needed (i.e. I would like to have`pdflatex` + `makeindex` + `biber` typesetting)? I did not find any manual regarding the case. If there is such manual, could anybody point me out to it?

-
@percusse I guess the point is the MiKTeX adds 'pdfLaTeX + MakeIndex + BibTeX' to the 'Typeset' menu of TeXworks. –  Joseph Wright Sep 1 '12 at 17:54
@percusse MiKTeX isn't an editor, it's a TeX distribution on Windows. It includes the command `texify` which runs (pdf)LaTeX, BibTeX and MakeIndex in a single command. –  Joseph Wright Sep 1 '12 at 18:01
MikTeX is a project. It includes TeXWorks, and adds pdfLaTeX + MakeIndex + BibTeX typesetting. When I use this typesetting in connection to backend=biber option of biblatex, then the bibliography is not printed until manual run of biber.exe over my file. How shall I "tell" TeXWorks to run biber automatically when needed? –  Oleksandr Sep 1 '12 at 18:04
@JosephWright I don't know what I'm saying nevermind. I was thinking about TeXnicCenter for some reason, –  percusse Sep 1 '12 at 18:06
`texify` needs to have a update to be able to process `biber` instead of `bibtex`. But you can build a batch file calling `pdflatex`, `biber` etc. Then you can add the call of this batch in `TeXworks`, for example `pdfLaTeX+Makeindex+biber`. –  Kurt Sep 1 '12 at 19:12

Compiling a `*TeX` document can be involved - for example, if you wish to produce an index you have to run something more but the simple `pdflatex, bibtex, pdflatex` (or `biber` in your case). Therefore, I chose eventually to use `latexmk` which takes care of all this automatically - so far it didn't let down!

I'm not familiar with the windows setting, but I guess you could set the editor to use `latexmk` for the compilation of a document.

-

Let me suggest an other tool.

Every document has its own requirements regarding the compilation. As you wrote you need `pdflatex`, `makeindex` and `biber`. My recommended tool allows the setting of the compilation out of the `tex` file. The tool is named arara

Next to the short online introduction the author Paulo Cereda provides a complete manual which can be downloaded here: arara at github (download part)

`arara` provided and installer with some predefined rules. Based on your requirement you can setup you main tex file header as follows:

``````% arara: pdflatex: { draft: true }
% arara: makeindex: {  style: stylefile.ist }
% arara: biber
% arara: pdflatex: { synctex: true }
% arara: pdflatex: { synctex: true }
``````

If you need only one compilation e.g. pdflatex you can comment the other assignments with a previous `!`:

``````% !arara: pdflatex: { draft: true }
% !arara: makeindex: {  style: stylefile.ist }
% !arara: biber
% !arara: pdflatex: { synctex: true }
% arara: pdflatex: { synctex: true }
``````

The different compilation rules have more options and can be modified for your specification easily.

The integration and usage of the tool `arara` in TeXworks is described in the manual in section 2.7.

-
The suggested order of execution could lead to incorrect results. `makeindex` should be called after the result of `biber` has been compiled by (pdf)LaTeX, and in general one should not run `makeindex` after the first run of LaTeX (e.g., the table of contents should be longer than 1 page. –  Guido Nov 15 '12 at 21:12
@Guido: In general I agree with you. In your case we need two draft runs before and after makeindex. –  Marco Daniel Nov 16 '12 at 15:53

A little bit late, and the solution has been mentioned before in this thread, but I had just the same problem. A quick solution to use pdfLaTeX with `biber` in TeXworks is to use a batch file.

Create the file `pdflatex+biber.bat` in your MiKTeX directory, in the subfolder `/miktex/bin/`, with the following content:

```miktex-pdftex.exe -synctex=1 -undump=pdflatex "%1"
biber.exe "%2"
miktex-pdftex.exe -synctex=1 -undump=pdflatex "%1"
```

Now open the typesetting editor of TeXworks and add a new setting. Name it appropriate (e.g. "pdfLatex+Biber") and give the path to your batchfile (`.../miktex/bin/pdflatex+biber.bat`). Add two arguments: `\$fullname` and `\$basename`.

That's it, works fine for me and I think, the solution can be adopted to other situations, where more/other programs have to be involved in the typesetting process.

-
Welcome to TeX.sx! –  lockstep Nov 13 '12 at 17:10
Putting your own batch file into the main MiKTeX tree is dangerous, see Purpose of local texmf trees. For MikTeX then: Create a local texmf tree in MiKTeX. –  Speravir Nov 13 '12 at 21:16
BTW Why did you set all commands into one line? Put them into 3 lines and the code is far better readable. –  Speravir Nov 13 '12 at 21:21
Thanks for mention the fact about the main MiKTeX tree :-) I didn't had that in mind... Formatting: I didn't found an explanation for setting up Biber with MiKTeX anywhere on the web, and when I was happy with my solution I didn't care about the formatting. But you're right, and I changed the code above :-) –  benne08 Nov 15 '12 at 16:47

In the `pdflatex + makeindex + bibtex`-typesetting-configuration that you describe, TeXworks relies on `texify`. You can tell texify to run `biber` instead of `bibtex` via the environment variable `BIBTEX` (texify documentation).

Normally you can set the Variable here: `Control Panel --> System --> Advanced system settings --> Advanced --> Environment Variables --> New`. However, I would not recommend doing that, as it will break any legacy project you might be using with bibtex.

Instead, I'd recommand setting up a Batch-File:

``````@set BIBTEX=biber
@texify %*
``````

Then you set up a new typesetting in TeXworks. It should get the same Arguments as the `pdflatex + makeindex + bibtex`-Typesetting and the Batch-File as a command.

But there is another caveat: With texify might not reliably detect that it needs to re-run after biber changed things. You can re-run the whole thing manually, when in doubt. There is also this workaround that relies on inserting some code into your main TeX-File.

As you can see, this seems to be quite experimental the other solutions with different tools or editors might be more easy.

-