Friday, December 31, 2010

Using Unicode in Latex/Tex

To use Hindi Unicode, do the following -

In the .tex file include the line -
\font\texthi="Lohit Hindi:script=deva,mapping=tex-text" at 11pt.
(Remember to exclude the full stop at the end!)
Enter Hindi unicode text in the document as -
Some English text {\texthi हिन्दी...} more English text...
Compile the document using Xetex or XeLatex.

More information -

"texthi" is the name of the command we just defined to indicate Unicode text. You can give any other name, e.g. \font\abcd="...".

"Lohit Hindi" (remember the space between Lohit and Hindi) is the name of an Open Truetype Font (OTF) installed in the system. You can specify any other font that is installed. In Ubuntu, you can see what fonts are installed as follows -
Goto Main Taskbar -> System -> Preferences -> Appearance -> (Popup opens) -> Click 'Fonts' tab -> Try to change any of the fonts e.g. Application font. You get another popup where the fonts are listed under 'Family'. You can use any of these fonts instead of "Lohit Hindi".

"deva" is a tag that specifies which script (and hence which unicode range) should be used. Hindi uses the devanagari script. For other scripts, find out which script tag to use.

"mapping=tex-text" - I don't know what this. If you do, please tell me.

Linux command for listing files with complete paths

List all files (recursively) with complete paths (e.g. to use in shell scripts)
E.g. to get all .txt files, use find -type f -name "*.txt".

Tuesday, December 28, 2010

Linux shell script loop to process files in a directory

To process .txt files in a directory, but skipping the first few and the last few -

count=0
ls | grep -E "\.txt" | while read line; do
    count=`expr $count + 1`
    if [ $count -le 10 ] ; then
        continue
    fi

    echo $line

    if [ $line = "xyz.txt" ]; then
        break
    fi
done

Wednesday, December 22, 2010

Using screen command in linux

The 'screen' command creates in a console session, the equivalent of windows in a GUI-based desktop. These 'screen's persist even after logout. You can ssh into a remote machine, open a 'screen', start your job, detach the screen, and logout. You can ssh back later, reattach the screen and check how the job is going.

screen -R myjob1 - opens a new screen myjob1 (like opening a new window)
Ctrl+a followed by d - detaches screen, and goes back to main session (like minimizing all windows and going to the desktop)
screen -R myjob1 - reopens the screen myjob1 (since it already exists)
Ctrl+a followed by d - detaches screen
screen -R myjob2 - opens a second screen myjob2
Ctrl+a followed by d - detaches the second screen
screen -R - lists screens available (in this case - myjob1 and myjob2)
screen -R myjob1 - attaches that screen
Ctrl+d - terminates the screen

Monday, December 20, 2010

Packages for generating figures (esp. plate diagrams)

- Inkscape
- latex
    - pstricks
    - tikz (http://www.mpi-inf.mpg.de/~dietz/probabilistic-models-tikz.zip, http://www.mpi-inf.mpg.de/~dietz/dirfactor-notation.pdf)
    - TikZ and PGF
- xfig
- jPicEdt
- lpe (http://tclab.kaist.ac.kr/ipe/)
- omnigraffle (not free) (http://www.omnigroup.com/products/omnigraffle/)