Manual update of LaTeX packages on Ubuntu

June 21, 2012

I installed LaTeX in both the OS that I have: Windows 7 and Ubuntu 12.04.

Recently I just discovered a new command of LaTeX that lets you change the default margins of your output document. This command requires the package called “geometry“.

In Windows 7 I use MikTeX to write any LaTeX document. The first time I used the new command, the program asked me to download and install the new package. After this operation, everything worked fine and I obtained an output file with custom margins.

However, when I tried to compile the exact .tex file on Ubuntu, I would get an Undefined control sequence error.

The strange thing is that I already installed every basic, extra, recommended and math packages.

After some research on web, I found out that maybe my geometry package was not the newest version.

So I decide to download the newest version from CTAN and manually update the package.

The overall process are:

1) Download the package that you want. You need to save the file XXX.dtx, where XXX is the name of the package. In this case is geometry.dtx

2) Now we need to get a file ending with .sty that LaTeX can use. To do so we just need to type in the terminal:

tex geometry.dtx

This command works only if you are inside the same directory of the package you downloaded. Otherwise you need to write the full path.

3) Locate the geometry.sty that the command above created and move or copy it to

/usr/share/texmf-texlive/tex/latex/geometry/

in order to replace the old one.

Or, as said in the source (below), for any manual update you should put the new version in /usr/local/share/texmf/tex/latex/geometry/ (which always gets searched *before* the texmf-texlive tree). However I have not tested this option so I don’t know if it works or not.

4) After any (manual) update you need to run the command

sudo texhash

to update the texmf-texlive tree. Otherwise new files will not be found out.

Sources:


Installing MATLAB on Ubuntu

June 18, 2012

MATLAB (matrix laboratory) is a software developed by MathWorks that allows matrix manipulations, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs written in other languages, including C, C++, Java, and Fortran.

Although a lot of software are designed for OS like Windows, this software has also a version designed for Linux.

The installation is quite easy and one can just follow the instructions described inside the “install_guide.pdf” that can be found in the DVD of Matlab (or you can download it from the source at the end of this post) and if you are lucky you can start working with this software without encountering any errors during the overall process.

I decided to summarise the overall process trying to point out the most important part that could led to error.

1) obviously the first thing to do is insert the DVD inside the DVD drive of your pc. Otherwise if you have a back up copy of the DVD like as a disk image in the format .iso, then you just need to mount it.

2) open your terminal and change the location to the directory of your DVD. For my case it is: cd /media/cdrom1/

3) now we need to launch the installer. To do so you just need to type: ./install or sudo ./install

the secondo version with sudo is to give the permission to the installer to create directory in special directory that requires root privilege.

4) now you just need to follow the instructions that appear to complete the installation.

To start MATLAB software you just need to type in the terminal the path where is located the script-shell type file called “matlab“.

For my case it’s:

/usr/local/MATLAB/R2012a/bin/matlab

In the case you have Ubuntu 11.04 or newer you will notice a message of warning(although the software will open up just fine):

/usr/local/MATLAB/R2011a/bin/util/oscheck.sh: 605: /lib/libc.so.6: not found

Some answer to why there is this warning can be found here (it’s written in Italian). To solve this problem you just need to type this in the terminal:

for 32 bit version of Ubuntu

sudo ln -s /lib/i386-linux-gnu/libc-2.13.so /lib/libc.so.6

for 64 bit version of Ubuntu

sudo ln -s /lib64/x86_64-linux-gnu/libc-2.13.so /lib64/libc.so.6

In my case I noticed that insted of libc-2.13.so I have in my system libc-2.15.so. So I just changed the command up in this:

sudo ln -s /lib/i386-linux-gnu/libc-2.15.so /lib/libc.so.6

—————————————————————————————————————————————————–

UPDATE: I also noticed that, instead of doing the above command, you can just copy the file libc.so.6 that is inside the folder /lib/i386-linux-gnu/ into the required folder that is  /lib  . This method is the same as the above command that is creating a file called libc.so.6 that is linked to the file libc-2.15.so.

—————————————————————————————————————————————————–

Then I just relaunched MATLAB and now the warning has disappeared.

To have a fast access to the program we can create a Launcher inside of our Dash or better put in the sidesibar of Unity.

First we need to get an icon for our Launcher. Just type this inside of your terminal:

sudo wget http://upload.wikimedia.org/wikipedia/commons/2/21/Matlab_Logo.png -O /usr/share/icons/matlab.png

or simply save this image and put it in the directory /usr/share/icons/

then you just need to follow this tutorial.

PS: in the following links you can read about some extra problems and their solutions not indicated in this tutorial because for now it’s not of my interest.

Sources:


How to create custom Launcher for the Dash of Unity

June 16, 2012

When I finally installed a particular program in Ubuntu, I noticed that during the installing process Ubuntu didn’t create a shortcut launcher inside the Dash, let alone inside the sidebar.

The whole process of creating a custom launcher is really simple, all you need to do is to create a simple file with the format .desktop.

To begin you just need to paste the following code inside a text editor like gedit:

[Desktop Entry]
Name=
Comment=
Exec=
Icon=
Terminal=false
Type=Application
Categories=

Name-> refers to the name that will be displayed inside the Dash

Comment-> you can put a comment to describe the use of this launcher or whatever (by this you can guess that this parameter is optional)

Exec-> you need to type the path of the executable program that this launcher will run. Example: /usr/local/Matlab/R2012a/bin/matlab. If the program doesn’t start maybe you can add at the end ot the path the option -desktop. When I have this sort of problem, this solution works just fine. So the path will become this way /usr/share/Matlab/R2012a/bin/matlab -desktop

Icon-> you need to type the path of the icon that this launcher will display. Example: /usr/share/icons/matlab.png

Terminal-> determine if the program need to be run through the terminal or not.

Type-> describe which type is this launcher. It could be Application, Link or Directory

Categories-> indicates in which category the launcher will be put inside the Dash.

After filling up the all parts you just need to save this file in XXX.desktop, where XXX could be whatever name you want.

The last operation is to give this file the permission to run as an executable. To do so you just need to type this inside the terminal:

sudo chmod +x XXX.desktop

This works only if you are inside the same directory of the file .desktop, otherwise you need to change the XXX.desktop with the full path.

you should be able to notice a little difference in the displaying of the file .desktop you just created.

Before the command it was visible in this way

After, it become this way

To make it visible inside the Dash of Unity you just need to move it inside the directory

/usr/share/applications/

or

~/.local/share/applications/

In the second case the launcher will be visible only to the user that created it.

Now that everything is done you can open the Dash and type the name of the launcher you just created and if you did everything okay, you should find it easily.

To add it to the sidebar of Unity, you just need to drag and drop the launcher inside the Dash to the sidebar, just like with any other launcher already inside the Dash.

PS: The file .desktop let you also to create a menu that gives you access to custom shortcuts of the program. However that is not in my interest in this moment so I will not describe it now, but I thought it was useful to point it out.

Source: LauncherFileDesktop



LaTeX: include eps files in pdflatex

June 10, 2012

My problem is I have several image files that are in .eps format.

I need to include these images inside a .tex file and then compile it by pdflatex to create a pdf file.

I already knew that if I compile my .tex file using pdflatex it will give me an error because it doesn’t support .eps graphics but only jpeg, png, pdf…

After some search on the net I found an online solution. In this website you can upload your .eps files and as a result you will have your converted .pdf files to download and to use in your .tex file.

The only disadvantage about this online solution is that if you have a lot of files you need to convert, you will have to stay there to upload one by one because it doesn’t support multiple files.

So the next solution is what I prefer.

You need to declare these two package in your preamble:

\usepackage{graphicx}
\usepackage{epstopdf}

then you can include .eps files as any other simple images:

\includegraphics[option]{file_name}

The trick is that when you are compiling by using pdflatex it will check if the corresponding pdf version of the file exists or not. If it does, it will simply use the pdf version, otherwise it will convert the eps version to a pdf version and then use the pdf file.

NB: To compile the .tex file you need to add “-shell-escape” in your command of pdflatex:

pdflatex -shell-escape name_file.tex

Sources:


									

How to mount an ISO image on Ubuntu

June 10, 2012

An ISO image is an archive file of an optical disc.

In OS such as Windows you can mount it by using software like DAEMON tools lite.

However Ubuntu let you mount it just by typing some simple command on your terminal.

1) First you need to create a directory for your ISO image. To do this open your terminal and write this in it:

sudo mkdir /media/ISO

and then press enter. You will be asked to enter the password for root user.

2) Now is time to mount your disk image by executing this command on terminal:

sudo mount -t iso9660 -o loop /xxx/name_image.iso /media/ISO/

“/xxx/name_image.iso” is the path where is located your disk image.

“/media/ISO/” is the path where you want your disk image to be mounted. In this case it’s the directory that we just created before.

If everything goes well, it will open by itself the directory in which your mounted disk image is, otherwise you can access it like any other directory knowing its path.

To unmount the disk image you just need this command:

sudo umount /media/ISO/

Source:  montare-le-iso-senza-problemi


Fixing a stuck CD/DVD tray

February 2, 2012

It’s really a long time the last time that I used my DVD drive from my old desktop computer (bought in 2000) to read some CD/DVD.

But for some reason the CD tray just doesn’t want to open. So I decided to remove it from the pc to give a better view to the inside of this hardware.

It was easy to remove it from the pc, but I can’t seem to open it completely to reach the inner part to see how the hardware is working in order to search for the problem. (Maybe I was afraid of breaking it)

So I searched on Internet and I found out that all process that I was doing was unnecessary.

To open the disk tray, you can just do a manual eject.

  1. Search for a pinhole in the front panel of the CD/DVD drive;
  2. Then just use a paperclip or something similar and insert it inside the hole (with force if need it);
  3. Magically you will see your disk tray open up by itself.

This is a really simple way to solve the problem temporarily, but it’s annoying to go this way every time you need to use the disk drive.

Eventually I found a really interesting video that show you how to disassemble completely the DVD drive. In addiction it shows what’s the problem of the drive and a simple way to solve it.

It’s really a must see to all people who have the same problem and want a lasting solution.

Sources:


Firefox “save and quit” option

February 2, 2012

I don’t even remember from which version of Firefox that the useful option of asking you if you want to save the multiple tabs you opened before closing firefox disappeared.

At first I didn’t even care much about it, but in the few times that you need it, it’s really annoying not having with you.

In the end I found out that you just need to change some parameters of  Firefox to display it again.

You need to do the following actions:

  1. In the address bar type about:config. It will show a warning messages but it’s okay so just click the button to enter in the configuration page;
  2. Search for the variable called browser.warnOnQuit. If it has value false, then double click on it to change its value to true. In this way if you have multiple tabs opened, when you are going to quit Firefox it will display a message asking the confirmation of closing Firefox (This is really useful to me because quite often I click by mistake the quit button);
  3. Search for the variable called browser.showQuitWarning. Change this value again to true. This will activate the “save and quit” option.

Tips:

  • To reach the required parameters, you can just type the name of these in the filter bar.
  • If you can’t find some of these variables, you just need to create them by yourself. (Right click inside the page and then select new and eventually boolean)

Sources:


Brothers printer: error message “unable to clean”

January 4, 2012

Recently I just got in my hand a not working Brother printer. The model is MFC-215C Usb Printer.

The error that it shows whenever I plug it was “Unable to Clean” and something like search in the manual for instructions to solve the problem.

The User Manual, like always, was useless because in it was written this error however it suggests you to remove any significant thing/dirt that could block the printer. Obviously there wasn’t anything like that.

After some research on the internet I finally found out that the problem was the internal ink absorber box that is too full. So the solution was to clean it or replace it and then reset the purge count.

To make the printer works again the important part is to reset the purge count.

The part about cleaning or replacing the internal ink absorber box is optional (however it would better to do so to avoid the leak of ink when the ink absorber box can’t work anymore). To reach the internal ink absorber box you need to dismantle the printer. When I have time I will upload a new post to show how to dismantle this printer.

The machine counts all purge (cleaning) operations in order to prevent the internal ink absorber box from overflowing with purged ink. So whenever the counter reaches 6400 an internal “Machine Error 46” is generated. Further purge operations are prohibited, and therefore the printer becomes unusable.

The error “Unable to Clean” can be generated by many different internal error codes. So to be sure that our error is because of the internal “Machine Error 46” first we need to ascertain it.

First, with the printer turned off (by pulling out the main cable), hold down the Menu/Set key. Then re-insert the main cable into the machine (power on) always holding down the bottom. The internal Machine Error Code will be displayed.

After verified that it’s an internal “Machine Error 46”, the correct procedure is to dismantle the printer and then replace or at least clean the ink absorber box. Eventually reset the purge counter to zero.

Let’s suppose that the ink absorber box can be used again without the problem of overflowing of the ink, so we proceed to reset the purge counter.

First we need to enter the maintenance mode of the printer. To do so we can

  • FAX models with numerical keypads: Press the Menu/Set, *, 2, 8, 6 and 4 keys within two seconds. (if you fail to complete the correct key sequence within two seconds, press the Stop key to try again).
  • Other (non-FAX) models: With the printer turned off, hold down the Menu/Set button and re-insert the main cable.

To be sure that we are inside the maintenance mode we can see all four photo/copy/fax/scan lights flash (and on the display shows “maintenance mode” if there isn’t any error that overwrite these two words).

  1. Press the 8 then 0 keys. It will call up the machine’s log information list;
  2. With the Arrow keys we scroll through the log information list to reach the purge counter;
  3. Press the 2, 7, 8, and 3 keys in this order to reset the purge count to zero;
  4. Press the Stop/Exit key to return to the initial stage of the maintenance mode;
  5. Press the 9 key twice to return to the standby state.

Now the printer will work again.

NB: With different model there might be some differences about the keys to push to enter the maintenance mode and to set the numbers. To see the small changes of keys you can search in the source which contains also the keys sequence for model dcp – 115c.

Source: need reset purge counter due error 46


Customized Icon For Removable Devices

January 3, 2012

I don’t know why,  but today, when I just connected my USB to my computer, I couldn’t stand the usual image/icon used as default by Microsoft Windows.

After that I decided to convert some image found online to replace the USB icon.

To make this possible you just need :

  1. to create a simple file called “autorun.inf” ;
  2. and obviously an image that you want to use to replace the default icon.

These two files need to be put in the root of your USB.

Tip: If it’s annoying the view of these two files, after you are happy about the result, you can just hide them by changing their attribute in hidden/not visible.

The file autorun.inf can be created by just using a text editor which contains these lines:

[autorun]

icon = name of icon to use

After “icon = ” you can just type the name of the icon that you want to use. Or in the case the image is not in the root, you can just type the correct path.

Example:

icon = iconname.ico

icon = folder\subdirectory\..\iconname.ico

The typical size of the icon is  16×16 pixel, 32×32 pixel and 64×64 pixel all could be with 4, 8 o 32 bit of colors.

You can use a software called IconFX to create your personal icon. It’s a shareware program so you can use it for 15 times, after this the save option will be disabled.

Instead, if you have Photoshop you can save your image as “.ico” after installing a simple plugin open source called ICO (Windows Icon) Format. Just put the file “ICOFormat.8bi” you downloaded in the folder C:\Program Files\Adobe Photoshop XX\Plug-ins\File Formats\ . Be aware that the path written may be different with yours because of different OS and version of Photoshop.

The simplest method that is free and quicker than creating an image yourself is to convert an image (that you have or you find on internet) to “.ico” by using a free online service as Bradicon!. It’s really simple. You just upload the image you want to use and wait for few seconds to let the service finishes to upload and converts the image for you, then you can just download it and use it.

NB: After writing all these things in the file autorun.inf be sure to save it as “autorun.inf” and not as “autorun.inf.txt”

Then you just need to put the files autorun.inf and nameimage.ico in the root of your USB and from the next time you reconnect it to your computer, it will be displayed with the icon you just specified.

Further consideration:

The file autorun.inf could include other commands that could be useful.

  • label = name of your devices

The command label is used to specify the name which you want to be displayed for your removable device.

  • open = name_of_application.exe

The command open will run the specified executable application. It could be .exe, .msi, .bat

The command shellexecute will open the specified file that could be a document, an internet page, a video, a music, etc… Be sure that in the system where you let it open these files, the OS has the appropriate software to open these files.

Sources:


Customize Grub 2

December 17, 2011

When I install Ubuntu in my computer aside the other OS that I have, it’s always a pain to re-edit the files that control Grub because the way to edit it tend to change with some version of Ubuntu (although they’re small changes, but it’s always a tiresome task to surf the net and find out the little information you need in this vast internet environment) .

So in this article I collect the minimal knowledges about definitions and changes I need to do on this subject to obtain a satisfactory customized Grub.

Since the information I need are written in a perfect way from the sources from where I read them, instead of rearranging the information, I will just copy and paste them here always inside a quotation block. All the credits go to their creators.

GRUB 2 is the default boot loader and manager for Ubuntu since version 9.10 (Karmic Koala).

To determine the version installed in your computer, you can use the line command “grub-install -v” inside the shell of Ubuntu.

To modify GRUB 2, there are some files that need to be considered:

  1. /boot/grub/grub.cfg
  2. /etc/default/grub
  3. /etc/grub.d/  (directory)

/boot/grub/grub.cfg

This file contains the GRUB 2 menu information but the grub.cfg file is not meant to be edited.
Each section is clearly delineated with “(### BEGIN)” and references the script in the /etc/grub.d directory from which the information was generated.
grub.cfg is updated by running the update-grub command as root.

/etc/default/grub

The entries in this file can be edited by a user with administrator (root) privileges and are incorporated into grub.cfg when it is updated.

/etc/grub.d/  (directory)

The scripts in this directory are read during execution of the update-grub command and their instructions are incorporated into /boot/grub/grub.cfg.
The placement of the menu items in the grub.cfg menu is determined by the order in which the files in this directory are run. Files with a leading numeral are executed first, beginning with the lowest number.
Only executable files generate output to grub.cfg during execution of update-grub.
The major default files in this directory used by Ubuntu are:
00_header Sets initial appearance items such as the graphics mode, default selection, timeout, etc.
05_debian_theme The settings in this file set the GRUB 2 background image, text colors, selection highlighting and themes.
10_linux Identifies kernels on the root device for the operating system in use and creates menu entries.
20_memtest86+ Searches for /boot/memtest86+.bin and includes it as an option on the GRUB 2 boot menu.
30_os-prober This script uses os-prober to search for Linux and other operating systems and place the results in the GRUB 2 menu.
40_custom A template for adding custom menu entries which will be inserted into grub.cfg upon execution of the update-grub command.

After editing /etc/default/grub or the scripts in the /etc/grub.d folder the user should run sudo update-grub to incorporate the changes into the GRUB 2 menu.

To modify the aforementioned files you can use the command line “sudo gedit path_of_the_file_to_edit” inside the shell (example: sudo gedit /etc/default/grub). After you input the root password, it will open the software “text editor” with the privilege as root.

In the following lines I will describe only a small part of editing that is of interest to me. To have a more complete editing knowledges you can read the sources at the end of this article from which I collected these information.

First let’s see what’s inside /etc/default/grub (file)

After you opened this file, the entries that are of interest are :

GRUB_DEFAULT – Sets the default menu entry. Entries may be numeric, a complete menuentry quotation, or “saved”
GRUB_DEFAULT=0 Sets the default menu entry by menu position. Counting of entries is the same as in GRUB – the first “menuentry” in grub.cfg is 0, the second is 1, etc.
Note: Grub 1.99 introduces a submenu menu structure. For a menu item in a submenu, the entry becomes a two-digit entry. The first entry is the position of the submenu title in the main menu. The second entry is the position within the submenu. If the submenu is the 3rd entry in the main entry, and the user wishes to boot the first entry in the submenu, it would be designated as “2>0”

GRUB_TIMEOUT=10
Setting this value to -1 will cause the menu to display until the user makes a selection.
The GRUB 2 menu is hidden by default unless another OS is detected by the system. If there is no other OS, this line may be commented out unless the user changes it. To display the menu on each boot, uncomment the line and use a value of 1 or higher.

#GRUB_GFXMODE=640×480
You can remove the # symbol to make this line active. The entry sets the resolution of the graphical menu (the menu text size). It provides resolutions supported by the user’s graphics card (e.g. 640×480, 800×600, 1280×1024, etc). The setting applies only to the boot menu display, not the resolution of the operating system that boots.
Tip: Setting the same resolution in GRUB 2 and the operating system will decrease boot times slightly.
The user can also add multiple resolutions. If GRUB 2 cannot use the first entry, it will try the next setting. Settings are separated by a comma. Example: 1280x1024x16,800x600x24,640×480.
If using a splash image, the resolution setting and the splash image size should be compatible for best results.
Resolutions available to GRUB 2 can be displayed by typing vbeinfo in the GRUB 2 command line. The command line is accessed by typing “c” when the main GRUB 2 menu screen is displayed.

GRUB_DISABLE_LINUX_RECOVERY=true
Uncomment (remove the # symbol) to prevent the “Recovery” mode kernel options from appearing in the menu. If you want a “Recovery” option for only one kernel, make a special entry in /etc/grub/40_custom.

GRUB_BACKGROUND=/path_to_image/filename.   The GRUB 2 splash images are controlled by the GRUB_BACKGROUND variable in ‘/etc/default/grub‘. The image must be a .png, .tga, .jpeg, or .jpg image.

By changing the value about these variables you can create a more suitable menu list of your interest.

After turning up the computer I prefer to see a screen selection with only the lines about the different OS that is installed on my PC and in the order that is better to me.
The easiest way to obtain this result is to create a custom menu entries.

GRUB 2 allows users to create customized menu selections which will be automatically added to the main menu when sudo update-grub is executed. A 40_custom file is available in /etc/grub.d/ for use or to serve as an example to create other custom menus.

The file must be made executable: sudo chmod +x /etc/grub.d/filename. However if you are using the default file 40_custom and not the one you created then this is not necessary.

The easiest way to create the content of a custom menu is to copy a working entry from /boot/grub/grub.cfg. Once copied, the contents of 40_custom can be tailored to the user’s desires. The user can copy existing menuentries from the /boot/grub/grub.cfg file.

The part that is needed looks like this:

menuentry ‘Ubuntu 11.10 – Oneiric Ocelot’ –class ubuntu –class gnu-linux –class gnu –class os {
recordfail
set gfxpayload=$linux_gfx_mode
insmod gzio
insmod part_msdos
insmod ext2
set root='(hd0,msdos3)’
search –no-floppy –fs-uuid –set=root cb201140-52f8-4449-9a95-749b27b58ce8
linux    /boot/vmlinuz-3.0.0-13-generic-pae root=UUID=cb201140-52f8-4449-9a95-749b27b58ce8 ro   quiet splash vt.handoff=7
initrd    /boot/initrd.img-3.0.0-13-generic-pae
}

or

menuentry “Windows 7 Professional” –class windows –class os {
insmod part_msdos
insmod ntfs
set root='(hd0,msdos1)’
search –no-floppy –fs-uuid –set=root C406C64E37C181E7
chainloader +1
}

NB: make sure to change the old entry “gfxmode $linux_gfx_mode” in this new one “set gfxpayload=$linux_gfx_mode” otherwise it will give you an error like grub2 – Error: unknown command ‘gfxmode’  on the startup.
 

After you finished modifying the file 40_custom, you just need to remove all but the following files from the /etc/grub.d folder:

  • 00_header,
  • 05_debian_theme,
  • 40_custom
  • and README.

The unnecessary files are:

  • 10_linux
  • 20_linux_xen
  • 20_memtest86+
  • 30_os-prober
  • 41_custom

Alternatively, you may keep other files in the /etc/grub.d folder if you make them unexecutable (which is the way I prefer).

In this case the command needed is sudo chmod -x /etc/grub.d/filename.

Then you just need to run the command update-grub as root to apply the changes!

This is the basic you need to know to modify the list of the boot loader. In the next post I will describe some way to improve the graphic impact of the boot loader

Source: https://help.ubuntu.com/community/Grub2