Wednesday, March 14, 2012

Latex in OpenOffice/LibreOffice

Latex equations can be inserted in Impress (powerpoint of OpenOffice/LibreOffice) via OOolatex. In this article I will talk on how to install and config OOolatex in linux and windows, pitfalls and a few tips.

Installation and config in linux


Install openoffice

It's probably a good idea to download and install openoffice from openoffice website. The latex extension works with 3.3. After download run the following commands:
tar -zxvf OOo_3.3.0_Linux_x86_install-deb_en-US.tar.gz
cd OOO330_m20_native_packed-1_en-US.9567/DEBS/
sudo dpkg -i *.deb
cd desktop-integration
sudo dpkg -i *.deb

Dependencies

Install the dependencies
sudo apt-get install texlive-latex-base dvipng

Font installation

Download the fonts and copy paste the *.ttf and *.otf files in
/usr/local/share/fonts/openoffice/
directory as root and then run the command
sudo fc-cache -fv

Extension installation

Download the linux version of the extension from the download section of the OOolatex website. To install, open the extension via Openoffice.


Config of OOolatex

After installation, reopen Impress. Click on the ``Config" button on the toolbar and fill in the paths. Change them according to your installation.
Latex: /usr/bin/
Ghostscript: /usr/bin/

Bug

Png output format is working, but not emf

In ubuntu if png output format is working, but not emf, then run impress from the command line and then try using OOolatex with emf selected. If the command line shows that it cannot find libstdc++5, then download the library file libstdc++5_x.y.z-w_i386.deb from here where x.y.z-w is the version number. Latest ubuntu repositories only provide libstdc++6, so one has to manually download and install this library.
For some reason OOolatex specifically requires the i386 version. So even if you have amd64 bit machine with amd64 ubuntu installed, you will still need the i386 version installed. After downloading the file from the above website install it with the following command:
sudo dpkg --force-architecture -i libstdc++5_x.y.z-w_i386.deb
Reopen impress and try again.


Installation and config in Windows


Install dependencies

Download and install miktex, ghostscript, openoffice and minsys from their respective websites. For minsys, use mingw-get-inst-xxxxxxxx.exe to install msys.


Font installation

Download the fonts and copy paste the *.ttf and *.otf files in C:\Windows\fonts\. Don't worry if it says bad font.


Extension installation

Download the windows version of the extension from the download section of the OOolatex website. To install open the extension via Openoffice.


Config of OOolatex

After installation, reopen Impress. Click on the ``Config" button on the toolbar and fill in the paths. Change them according to your installation.
Latex: C:\Program Files (x86)\MiKTeX 2.8\miktex\bin\
Ghostscript: C:\Program Files (x86)\gs\gs9.02\bin\
MinSYS: C:\MinGW\msys\1.0\bin\

Tips


  • If one wants to re-edit the equations after the file is re-opened, then the impress file needs to saved in ``odp" format rather than ``ppt" format.
  • For output format it is better to use emf format rather than png format.
  • Use ``Expand" button for inline equations and ``Equation" button for equations on a line of their own.
  • Example of writing multi-line equation
    \begin{array}{ccc}
    \mathcal{L} &=& T - V \\[0.2cm]
    \mathcal{H} &=& T + V 
    \end{array}
    

Monday, March 12, 2012

Bengali input in Windows/Linux

This probably will be one of very few times that I will talk about configuring windows os. Mostly because some of my friends use windows and also want to type bengali.

If one uses openoffice/libreoffice along with this method of typing bengali, then it won't matter if the person is using windows or linux since the files will be compatible with each other.

Windows

Download the ``Ekushey probhat" bengali layout from here. This layout is a phonetic layout and is very intuitive. Don't forget to download the Unicode Keyboard Conjunction list given in the above website. After downloading the ``Ekushey probhat" layout, unzip the file and double click on "Setup" and install it.
To easily switch between Bengali and English,
  • For Windows XP
    • Control Panel >Regional and Language Options >Languages > Text services and input languages >Details >Settings >Preferences >Language Bar. Tick mark both
      • Show the Language bar on the desktop
      • Show additional Language bar icons in the taskbar
  • For Windows 7,
    • Control Panel >Change keyboards or other input methods >Keyboards and Languages >Change keyboards >Language Bar >
      • Language Bar >Docked in the taskbar
      • Show additional Language bar icons in the taskbar
      • Show text labels on the Language bar

Linux (Ubuntu)

IBus (Intelligent Input Bus) helps in inputting various languages in linux. For ubuntu install the packages ``ibus", ``ibus-m17n", ``m17n-db" and ``m17n-contrib". To start up ibus for every login, System >Preferences >Startup Applications >Add
Name IBus Daemon
Command ibus-daemon -rd
Comment Input Method System
To setup the input method, go to System >Preferences >IBus Preferences >Input Method >Select an input method >Bengali > Probhat >Add.

Font installation

``SutonnyBanglaOMJ", FreeSerif and ``Free Sans" are good fonts for writing bengali. You can download the ``SutonnyBanglaOMJ" font from here.
You can also download other bengali unicode fonts from the internet. Just give a google search for ``Bengali Unicode fonts".

Windows

Copy the fonts to c:\WINDOWS\fonts\. Done.

Linux

You probably have the font FreeSerif in your system in
/usr/share/fonts/truetype/freefont/FreeSerif.ttf
If you don't, then install the file via you package manager. For ubuntu the package is ``ttf-freefont". You will need root access. However, if the font is not installed and you don't have root access, then create the directory $HOME/.fonts/f/. Notice the ``." in front of ``fonts". This makes the folder hidden. Now download the freefont-ttf.tar.gz font from here and copy the *.ttf files to $HOME/.fonts/f/. Open a terminal and run the command
fc-cache -fv

Default font selection in LibreOffice/OpenOffice

In the instructions below, substitute openoffice where ever I have said libreoffice if you have openoffice instead of libreoffice. However, I found that FreeSerif font has a problem with bengali conjuctions in the ubuntu version of libreoffice/openoffice. Workaround is either to work with FreeSans font or install libreoffice/openoffice downloaded from their respective sites.
To set the default font for bengali do the following. Open libreoffice

  • Tools >Options >Language Settings >Languages >``Enabled for complex text layout (CTL)". Also under ``Default languages for documents" >CTL, select ``Bengali (India)". Click OK.
  • Tools >Options >LibreOffice Writer >Basic Fonts (CTL) >
  • Choose the fonts as follows:
    Font Size
    Default FreeSerif 20
    Heading FreeSerif 22
    List FreeSerif 20
    Caption FreeSerif 20
    Index FreeSerif 20
  • Format >Character >Font >CTL font

    Font Typeface Size Language
    FreeSerif Regular 20 Bengali (India)
I have seen that sometimes, on some computers, FreeSerif font (windows/linux) won't write the conjuction alphabets correctly. I haven't been able to debug it. If that is the case stick to ``SutonnyBanglaOMJ" as your default font.

Input method


Windows

Click on the ``EN" icon on the right hand corner of the taskbar. Click ``Show the language bar". A bar appears on the top right hand. Open libreoffice-writer and click on ``English" to select ``Bengali (India)". The default keyboard shortcut to switch between input languages is ``Left Alt+Shift".

Linux

Open libreoffice-writer. To toggle between ibus input and default language, the keyboard shortcut is ``Ctrl+Space".