Skip to main content

Enabling LaTeX support in LibreOffice in Ubuntu 12.04

If you want to write mathematical formulas in your LibreOffice document using LaTeX syntax, the TexMaths extension by Roland Baudin is what you are looking for. Installing it is pretty simple, just download the .otx file and you are done.

In order to work correctly, though, it requires that you have one of dvipng or dvisvgm installed. The former usually comes with your LaTeX installation and it is enough if you don't want support for vector graphics. I do like the svg format more though, which I think renders much more nicely in your documents, especially in presentation where you might want to use larger fonts.

dvisvgm is available on sourceforge and installing it from the source code is pretty straightforward. Here I will explain how to perform a system-wide install in Ubuntu 12.04. Read the INSTALL file that comes with the code if you have other needs.

First of all you need to download the package and extract it to a folder of your choice. Next open a terminal and cd to the folder where you have extracted the source code. Here issue the command

Read more…

Install the latest stable git version in Ubuntu 12.04

Installing the most updated stable release of git in Ubuntu 12.04 is extremely straightforward; in fact an official ppa exists.

To install the latest git version open a terminal and enter the following commands:

sudo apt-add-repository ppa:git-core/ppa
# to add the repository you have to confirm the action by pressing ENTER

sudo apt-get update && sudo apt-get install git

Setting up a git submodule for Bitbucket's wikis

One of the great features offered by Bitbucket is having a wiki for your projects. Bitbucket's wikis use Markdown and are themselves git repositories; wikis use however in a separate git repository than the main project's one. To manage my projects wiki and keep it in sync with my main repository I use a git feature called submodule. Git submodules are explained very well in the "Pro Git Book" by Scott Chacon --Chacon's book is a recommended reading to get a good knowledge of git--. As explained in the section dedicated to submodules:

Submodules allow you to keep a Git repository as a subdirectory of another Git repository. This lets you clone another repository into your project and keep your commits separate.

Submodules are therefore ideal to manage the wiki for your project. To setup one is quite straightforward and can be easily done in a shell:

cd /your/project/path/
git submodule add wiki
# note: the wiki subfolder must not be present in your project main directory

This will create a subfolder wiki in your project path and add the file .gitsubmodules. The wiki folder behaves as an indipendent git repository and you have to commit your changes manually by going in the directory and use the standard git commands. When you clone a repository that has submodules, the directory structure is created manually; you have, however, to manually init the submodules and pulling the content. You do this with the commands git submodule init and git submodule update.

For further information on git submodules check Scott Chacon's book

Reduce pdf size from command line

Ensure to have ghostscript installed. Open a terminal and use the following command:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH \

PDFSETTINGS can be one of these values:

selects low-resolution output similar to the Acrobat Distiller "Screen Optimized" setting ;
selects medium-resolution output similar to the Acrobat Distiller "eBook" setting;
selects output similar to the Acrobat Distiller "Print Optimized" setting;
selects output similar to Acrobat Distiller "Prepress Optimized" setting;
selects output intended to be useful across a wide variety of uses, possibly at the expense of a larger output file.


Creating named shortcuts to long paths in Ubuntu

I often browse through folder that have very long path names in bash. I have decided to enable shortcuts for this folders and reduce the amount of typing. To get this I created a directory .symlinks in my home folder:

mkdir ~/.symlinks

Next I created symbolic links to my project folders in .symlinks, for example:

cd ~/.symlinks ln -s /full/path/to/my/very/cool/project

Next add the following lines to your ~/.bashrc using your favourite editor:

CDPATH="$HOME/.symlinks:CDPATH" export CDPATH

Now whenever you type cd project you will be in your /full/path/to/my/very/long/project. The drawback is that in bash rather than seeing the full path to your project you will see something like: [bash]name@host:~/.symlinks/projects[/bash]. If you don't like this here is a workaround: add alias cd='cd -P' to your ~/.bash_aliases file.

As a last note, if in your project directory you have a subfolder called project (i.e. a directory /full/path/to/my/very/long/project/project exists) to which you want to cd to, you will need to use cd ./project or alternatively cd project/project. In fact, if you type cd project you would end up in /full/path/to/my/very/long/project and not in /full/path/to/my/very/long/project/project as intended.

Alternatively, you can set your CDPATH variable as:


This will give the precedence to the names in your current directory, but it might make you unable to use one of your shortcuts if you are in a directory containing a subdirectory with the same name of the shortcut.

Change bash prompt in a virtual environment

I like to have visual clues when I am working on my python code in a virtual environment. Virtualenv has an option (--prompt) to add a prefix to your default prompt, but the final result is quite ugly.

What I find more pleasant is substituting the name vename of the virtual environment to the user name in my bash shell prompt; I also like to have vename coloured, so that I immediately know when the virtual environment has been activated.

This can be achieved pretty easily by modifying the definition of $PS1 in the file bin/activate contained in your virtual environment folder.

For example, setting:

PS1="\\[\\e[1;31m\\]vename\\[\\e[0m\\]@\\h:\\w\\$ "

produces the prompt to be displayed like:


To customize your prompt with more advanced features check the official bash documentation.

EDIT 08/08/2013

Setting the variable as explained above prevents the title of a terminal to be updated when changing folder. To fix this one can set the PS1 variable as:

PS1="\\[\\e]0;vename@\\h:\\w\\a\\]${debian\_chroot:+($debian\_chroot)}\\[\\e[1;31m\\]vename\\[\\033[0m\\]@\\h:\\w\\$ "

Ubuntu 12.04: re-enable hibernation on your laptop

By default hibernation is disabled in Ubuntu 12.04. To re-enable it open a terminal and type:

sudo nano /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla

and enter the following

[Re-enable hibernate by default]

Save the file and exit. Next you have to update grub (sudo update-grub). After rebooting hibernation will be enabled again.

How to get Ubuntu to recognize again your Kindle 4

A few days ago while charging my Kindle 4 via the USB port of my laptop, the Kindle suddenly shutdown and restarted. To my greatest surprise, all the content on my Kindle was gone, and my Ubuntu 12.04 PC no longer recognized it.

I realized that due to a defective USB cable, the filesystem of my Kindle got corrupted. Performing a factory reset and formatting it using tools like Gparted didn't fix the issue. After looking around in various forums, I finally came up with a solution that worked for me.

Read more…