8w_qfw
Last Updated: February 25, 2016
·
1.116K
· qubyte
2b8729c02bc2fb886b32ed23cb7b0a31

Switch to select BibTeX or biber.

Originally discussed on TeX.sx: http://tex.stackexchange.com/questions/38348/in-texshop-is-there-a-directive-to-select-biber-or-bibtex-on-a-per-document-bas

Repo with code can be found at: https://github.com/qubyte/BibDirective

With TeXShop, TeXworks and some other TeX IDEs, the TeX engine to use can be selected near the top of the file with a directive like:

% !TEX TS-program = pdflatex

Bibliography management is shifting from BibTeX, which is showing its age, toward biber in the community. Unfortunately there is no similar directive in these IDEs for bibliography engine. I decided to code one myself in bash. By using the code below, and telling your IDE that it is the bibliography engine, you can use the usual hotkeys, and select the engine you want near the top of the file with:

% !BIB TS-program = bibtex

or

% !BIB TS-program = biber

The code:

#!/bin/sh

filestem=${1%.*}
bibtype=`head -n20 "${filestem}.tex" | sed -n 's/\%[ ]*![ ]*BIB[ ]*TS-program[ ]*=[ ]*\([a-z]*\)/\1/p'`

if [ -z $bibtype ]; then
    echo "No option detected in TeX file. Defaulting to BibTeX."
    bibtype="bibtex"
else
    echo "Option $bibtype detected in TeX file."
fi

eval $bibtype $filestem
Say Thanks
Respond

1 Response
Add your response

13341
2b8729c02bc2fb886b32ed23cb7b0a31

Inspired by this tip, the TeXShop developers have integrated support for bibliography engine selection. See http://pages.uoregon.edu/koch/texshop/version.html

over 1 year ago ·
Filed Under

Awesome Job

Cf448620 1654 11e8 9817 2b2a15567933
PHP Back-End Developer
·
Ch√Ęteauguay,Quebec, Canada
·
Full Time