Wednesday, March 30, 2005

Creating a simple user interface in shell scripts

To create a simple menu in a shell script I prefer to use dialog command (see man dialog for more info).

Here I present a simple script with menu that let you select an option and, according to your choice, take an action.

#START
dialog --backtitle "Foo" --title "Bar" --menu "Foo Bar Menu" 15 50 3 Option1 "Option 1" Option2 "Option 2" Option3 "Option 3" 2>/tmp/menuitem.$$

menuitem=`cat /tmp/menuitem.$$`

case $menuitem in
Option1)
echo "Opt 1 chosen";;
Option2)
echo "Opt 2 chosen";;
Option3)
echo "Opt 3 chosen";;
esac

rm /tmp/menuitem.$$
#END

Tuesday, March 29, 2005

Preparation of PDF papers from LaTeX in A4 format

Based on: http://www.cs.sfu.ca/~vis/Tasks/electronic.html
There are two ways to prepare a paper in PDF format from LaTeX:
-use pdflatex command instead of latex
-conversion dvi -> pdf
The former method is easy, however, I prefer the latter because it let me to control the conversion process.
Let's start:
1. Create dvi file (f.e. foo.dvi) from your LaTeX document using latex command with, for example, \documentclass[a4paper,12pt]{report} line in the preamble.
2. Convert dvi to ps format: dvips -t a4 -Ppdf -G0 -o foo.ps bar.dvi
3. Convert ps to pdf document: ps2pdf -sPAPERSIZE=a4 -dMaxSubsetPct=100 -dCompatibilityLevel=1.3 -dSubsetFonts=true -dEmbedAllFonts=true -dAutoFilterColorImages=false -dAutoFilterGrayImages=false -dColorImageFilter=/FlateEncode -dGrayImageFilter=/FlateEncode -dMonoImageFilter=/FlateEncode bar.ps final_paper.pdf