Skip to main content


Showing posts from 2014

A script to fetch bibliography list from inspirehep by parsing through the latex file citing the references

While writing short scientific papers a major workload is in sorting the reference list. A professional article requires that the references be sorted in the bibliography list in the order that they appear in the main text (and not alphabetically which most LaTeX bst files do). This is a manual task which is laborious and needs to be repeated every time a reference is added. Therefore, it is instructive to write a script which will automate this tedious task. The following script that I wrote will look for the citation tags for the references and then fetch the references straight from the server at and prepare a reference file for the user to copy. Not only do we no longer need to copy and paste the references manually but the script will also sort the references in the order of their appearance.

An example of a citation appearing in the main text

... as it was shown in \cite{Chatterjee:2013daa} that merging black holes may not violate the second law of thermodynamics …

sed one liners explained

1. To select blocks of text and select only the first block (match)


-n suppress multiple prints



had the same effect. It deletes all lines which do not fall under this REGEXP matching pattern.

But this will select ALL blocks which match. Worse if there is PATTERN START and no PATTERN END then sed will go to the EOF and print everything. This is something we do not want.



so we have to make it quit after matching the first block.


; ends the first command and sed starts executing the next set of commands which in this case is match pattern /PATTERN END/ and the command for sed is to quit on encountering this pattern which happens after matching the first block of code.

Also see:

Remove pages from a pdf

Let's say we want to remove the first page of a bunch pdf files. Or there is one particular page that needs t be removed. Or the pages needs to be rearranged. There is no need for professional software for this like Adobe pro. A simple program called pdftk can do the job.

Let us say that we want to remove just the first page from the pdf. The following command does the trick.

pdftk file.pdf cat 2-end output newfile.pdf

More complicated page rearrangement can be done too. Say we want pages 3-5 after page 18.

First we save pages 3-5 in file temp2.pdf. Then cut out those pages and save the file in temp.pdf. Now the page 18 is page 15 since we have removed 3 pages from the original file. So we get pages 1-15 in one file and the rest in another. We can then join 1-15 + 3-5 + 16-end and voilĂ .

pdftk file.pdf cat 3-5 output temp2.pdf
pdftk file.pdf cat 1-2 6-end output temp.pdf
pdftk temp.pdf cat 1-15 output temp1.pdf
pdftk temp.pdf cat 16-end output temp3.pdf
gs -dBATCH -dNOPAUSE -q -s…

Eclipse does not run any JAVA programs

Problem : Eclipse does not run any JAVA program because it is not loading any JREs.

Window -> Preferences -> Java -> Installed JREs 
 An error has occurred when creating this preference page.
No JREs loaded :(

Solution: Solution is to reset the JAVA timezones .
1. sudo apt-get --reinstall install tzdata-java
2. putting the line
at the end of eclipse.ini