Just for completeness, a very nice and free client for working with a bibtex database is JabRef, which is available for MacOS, Linux and Windows.
If you work with TeXShop and use bibtex, compiling your document is quite hard work: first you need to set the texmode to "LaTeX", compile it, set it to "bibtex", compile it, set it back to "LaTeX" compile it. Indeed, a lot to point and click. The following tip will add an entry to your TeXShop called "lat-bib-lat", which does exactly this procedure for you:
- Open "Terminal". This will give you the nerdy mysterious window with the cursor line.
- Type in (or copy this line, and do a ctrl+click at the cursor position and paste it) and press return afterwards
cd Library/TeXShop/Engines/This changes the console to the folder Library/TeXShop/Engines in your home folder.
- Create a file named lat-bib-lat.engine in that specific folder by casting the following command closed by the return key in the terminal window
vi lat-bib-lat.engineThis creates the file and opens it in a console text editor, so you will see nothing than a cursor with many tildes below. - Press the "i"-key once. In the last line of the window "-Insert-" should appear (so you just switched the text editor to insert mode)
- Copy the following stuff and paste it by an ctrl + click at the cursor position in the Terminal
#!/bin/bashThis is a so-called script which does exactly what you want: execute latex, do bibtex and execute latex again.
pdflatex "$1"
for file in *.aux ; do
bibtex $file
done
pdflatex "$1"
pdflatex "$1" - Press the "Esc" key (which ends the insert mode) and write ":wq" (without quotation marks) followed by a keystroke of return which tells the editor to Write the file and Quit. You now should be back at the console as it was before the "vi"-command.
- Make the script executable with the command (press return at the end)
sudo chmod a+x lat-bib-lat.engineYou will be prompted for your password. Sudo is the command to become SUperuser and DO the following command. The command chmod a+x makes the file executable (x) for all. - Restart TeXShop - you will now find an entry called lat-bib-lat. If you choose it, your document will be latexed, bibtexed and latexed again
Remark:
Apparently you need two runs of pdflatex in order to get the correct citations, so the script does two calls of pdflatex after calling bibtex.
Update:
The lat-bib-lat.engine can be found in the drop-down menu where you can choose the profile to be run as can be seen here:
19 comments:
Thanks for the advice. I'm kind of disappointed, though, by your misleading blog title. I was hoping the people behind it would be some kickass nerd girls (who also happened to be Greek but living in Germany, or whatever)... turns out it's just another guy demeaning and objectifying women. 'cos that's what you're doing if you name an object after a woman and subsequently refer to said object as a bitch...
Thanks for this 'genious' comment. Just to let you know: the name was actually created by a woman who was the creator of the partner blog (which is now called eumenidae.blogspot.com for reasons you can read over there) and not by myself. We just took the German version of it to show the interconnection. And I would be very careful to blame other people of objectifying women (especially if you don't know them personally and know how their relation to women is...)
Best regards
Just for the record: I do kick ass. Preferably daWuzzzz's. Ὁ μὴ δαρεὶς ἄνθρωπος οὐ παιδεύεται.
And while I do commend your ardour, petitioning for equal opportunities in Greek mythology looks like a lost cause to me.
Thanks for this helpful tip. However I can't find where the engine appears? Yes the lat-bib-lat.engine file is in the correct folder as an executable and I restarted TexShop. I also checked that the script works by putting this line in my source:
% !TEX TS-program = lat-bib-lat
But I still can't see where in TexShop (including preferences) this option appears. Any help appreciated.
Hey "The Youd",
here you are, I've updated the blog article with a screenshot. You should find the entry "lat-bib-lat" in the dropdown menu, where you can choose the executed profile (normally set to "LaTeX")
Hi, nice blog. I did all steps mentioned in the post. Even compiles but could not able see biblography in my document. Can u please help me with what possible thing may go wrong.
Very helpful, thanks!
RE: Ankit
I had the same problem as you. As I was continually adding items to my bibliography, I found I had to compile bibtex first before using lat-bib-lat. This is easily remedied by a small addition to the engine file you create in terminal:
#!/bin/bash
for file in *.aux ; do
bibtex $file
done
pdflatex "$1"
for file in *.aux ; do
bibtex $file
done
pdflatex "$1"
pdflatex "$1"
Thank you so much, I'm writing my thesis and compiling the bibliography was very annoying, now I can focus on writing without worrying about that troublesome situation.
Again, thanks.
Thank you for this useful piece of code. I am also writing my thesis with two weeks left. I have inserted all my citations and using a single bibtex library that I call in each chapter. However I keep getting question marks in place of numbers but the list of references in each chapter is still displayed at the end. Any ideas on how to fix this?
Thank you for this useful piece of code. I am also writing my thesis with two weeks left. I have inserted all my citations and using a single bibtex library that I call in each chapter. However I keep getting question marks in place of numbers but the list of references in each chapter is still displayed at the end. Any ideas on how to fix this?
Is there also a way to trash the aux files immediately after the last pdflatex command?
Really good post, mate. Cheers!
Great. Works perfectly.
Hi every one,
A little improvement for the one interested:
#!/bin/bash
pdflatex "$1"
for file in *.aux ; do
bibtex $file
done
pdflatex "$1"
pdflatex --synctex=1 "$1"
The `--synctex` option in the last compilation allows you to jump from pdf to corresponding line on .tex file (and vice-versa). In mac for example it will be (cmd + click).
Anyway, very useful trick! Thank guy!
\HUGE Thank you !!
$ cd ~/Library/TeXShop/Engines/
$ subl lat-bib-lat.engine
#!/bin/bash
pdflatex "$1"
for file in *.aux ; do bibtex "$file"; done
pdflatex "$1"
pdflatex --synctex=1 "$1"
#See it : "$file" : names w/ space: corrigido por mim em 2020JUL10
$ sudo chmod a+x lat-bib-lat.engine
restart texshop :)
Many thanks for this little trick, it has at this point probably saved me hours I would otherwise have spent switching back and forth between Latex and Bibtex.
This being said, I just encountered a problem when I tried installing the command on a new (late 2020) MacBook with Big Sur pre-installed. I can create the new engine without problems, it also appears in TexShop and the first part (LaTeX - BiBTex) runs fine. It does crash when it starts the last two runs of LaTeX and returns the following error (replace 'filename' with actual name of .tex file):
! I can't find file 'filename.tex
pdflatex'.
<*> filename.tex
pdflatex
filename.tex
(Press Enter to retry, or Control-D to exit)
Please type another file name:
It seems to me that there's some confusion with the quotation marks, but I can't figure it out (neither an expert with the Terminal nor with Latex-hacks). If I run everything by hand, it works fine.
Any help would be greatly appreciated!!
Hey Carlo,
as far as I know big sure changed the standard shell, but since I don't have a machine running Big Sure I can't help you there. Maybe changing the standard shell is possible.
Post a Comment