Friday, July 13, 2007

Macbook/Synaptics Trackpad Configuration

A while back I upgraded my Macbook to Ubuntu Feisty Fawn. The installation was extremely smooth, and everything just worked.

But I have tweaked my TrackPad configuration. Make sure to edit the ServerLayout section to use the MacBook Touchpad input device.
Section "InputDevice"
Identifier "MacBook Touchpad"
Driver "synaptics"
Option "AccelFactor" "0.015"
Option "BottomEdge" "310"
Option "Device" "/dev/psaux"
Option "FingerHigh" "30"
Option "FingerLow" "20"
Option "HorizScrollDelta" "0"
Option "LeftEdge" "100"
Option "MaxDoubleTapTime" "180"
Option "MaxSpeed" "0.88"
Option "MaxTapMove" "220"
Option "MaxTapTime" "150"
Option "MinSpeed" "0.79"
Option "Protocol" "auto-dev"
Option "RightEdge" "1120"
Option "SendCoreEvents" "true"
Option "SHMConfig" "on"
Option "TapButton2" "3"
Option "TapButton3" "2"
Option "TopEdge" "50"
Option "VertScrollDelta" "25"
Option "VertTwoFingerScroll" "true"
EndSection
There are several advantages to this configuration, including mimicking the Mac OS X two finger scrolling and two finger tapping for a right click. But most importantly: SHMConfig is activated; and so we can enable syndaemon (at startup)
syndaemon -i 2 -t -d
syndaemon is a program that monitors keyboard activity and disables the touchpad when the keyboard is being used. The -i option specifics the time in seconds to wait after the last keypress before enabling the touchpad; -t disables only tapping, not mouse movements; there are -k and -K options to ignore modifier keys or modifier+key combinations; finally, -d starts the program as a daemon.

Sunday, July 08, 2007

Linux workstation setup (LaTeX+Vim+Xpdf+SVN+LaTeXSuite)

Here is what I do with a fresh Ubuntu/Debian installation to get my optimal LaTeX configuration setup.

Installation. Install LaTeX, Vim, LaTeXSuite, Subversion and XPDF.
aptitude install texlive-full
aptitude install vim-latexsuite
aptitude install subversion
aptitude install vim-gtk
aptitude install xpdf
Configuration.
  • Xmodmap. Swap the CapsLock and Control keys. Add the following to the file ~/.xmodmaprc.
     ! Swap Caps_Lock and Control_L
    remove Lock = Caps_Lock
    remove Control = Control_L
    keysym Control_L = Caps_Lock
    keysym Caps_Lock = Control_L
    add Lock = Caps_Lock
    add Control = Control_L
    Run xmodmap to implement the changes.
    xmodmap ~/.xmodmaprc
  • Xpdf. Configure XPDF to use vi keybindings for navigation. Add the following to the file ~/.Xresouces.
    xpdf.viKeys: true
    Enable the changes with xrdb:
    xrdb ~/.Xresouces.
  • Vim. Download my .vimrc and .gvimrc files.

XPDF with vi keybindings

Here is how to enable vi keybindings for xpdf navigation (j for up, k for down, h for left, l for right).

Add the following line to your ~/.Xresouces file.
xpdf.viKeys: true
Then run xrdb to load the changes:
xrdb ~/.Xresouces

PDFEdit: Edit PDF files in Linux


PDFEdit is the PDF editor that I have been looking for. It supports drawing and annotating PDF documents. It isn't included in the Ubuntu repositories yet, but there is a Debian/Ubuntu package.

Installation. Get the latest version of the software from here. The filename begins with pdfedit. Then install it with dpkg:
dpkg -i pdfedit_0.3.1-1~3v1ubuntu0_i386.deb
Use. Launch; load a PDF file; annotate.

Vim + LaTeXSuite + XPDF for LaTeX editing

Here is my LaTeX editing configuration.

Since XPDF has a refresh feature, I have set up my LaTeX editor (Vim + LaTeXSuite) to generate a PDF file and automatically refresh the XPDF window. Hence, one command compiles the LaTeX file (an appropriate number of times to get the references and citations correct!), converts the dvi file to a PDF file and refreshes the XPDF window.

General comment. If you spend a lot of time editing text, then it is well worth your time to learn to use an efficient editor. Vim is one example of such an editor. Another is Emacs.

Installation. Use apt-get to install all the software.
apt-get install vim-gtk vim-latexsuite xpdf
Configuration. Here are the relevant entries of my .vimrc file.
" General features.
syntax enable " enable syntax highlighting
set hlsearch " hightlight search
set textwidth=70 " set textwidth to 70 to cause wrapping
set history=50 " 50 lines of command lines history
set viminfo='20,\"50 " read/write a .viminfo file with at most 50 lines
set ruler " show the cursor position all the time
set spell " turn on speel checking
set nojoinspaces " only put one space after periods

"""""
" For latex-suite, as suggested by the LatexSuite documentation.
filetype plugin on " to enable latex-suite when a tex file is loaded
set shellslash
set grepprg=grep\ -nH\ $*
filetype indent off

" Run latex, then dvipdf, then refresh the xpdf window.
let g:Tex_FormatDependency_pdf = 'dvi,pdf'
let g:Tex_CompileRule_pdf = 'dvipdf $*.dvi; xpdf -remote 127.0.0.1 -reload -raise'
let g:Tex_ViewRule_pdf = 'xpdf -remote 127.0.0.1'
let g:Tex_DefaultTargetFormat = 'pdf'
" Set the target format to pdf.

" Set the warning messages to ignore.
let g:Tex_IgnoredWarnings =
\"Underfull\n".
\"Overfull\n".
\"specifier changed to\n".
\"You have requested\n".
\"Missing number, treated as zero.\n".
\"There were undefined references\n".
\"Citation %.%# undefined\n".
\'LaTeX Font Warning:'"
" This number N says that latex-suite should ignore the first N of the above.
let g:Tex_IgnoreLevel = 8

" TIP: if you write your \label's as \label{fig:something}, then if you
" type in \ref{fig: and press Ctrl-N you will automatically cycle through
" all the figure labels. Very useful!
set iskeyword+=:
Use. The command \lv launches xpdf and \ll runs latex, dvipdf, xpdf -reload. LaTeXSuite has many interesting features to allow for quick writing of LaTeX documents. For example, typing `a will insert \alpha and F5 offers a shortcut to inserting an environment (e.g., displaymath). Check out the online tutorial.

Set svn to ignore auxiliary LaTeX files

Using SubVersion for LaTeX document management is great. (See my earlier post on setting this up.) However, there are certain files (.aux, .log, etc.) that are best not put under revision control because they change very often. The following describes how to set svn to ignore these files, so that the output of 'svn status' doesn't report them.

1) Create a file called "ignore-these" with the (patterns of) files you want svn to ignore. For example,
*.aux
*.bbl
*.blg
*.bst
*.dvi
*.idx
*.lof
*.log
*.pdf
*.toc
includeonly.tex
2) Then run the command,
svn -R propset svn:ignore . -F ignore-these
3) Should you need to edit these properties, use the following command.
svn propedit svn:ignore .
(On Mac OS X you need to set the EDITOR variable: 'export EDITOR=vim')

KeyJNote: stylish presentations


KeyJNote is a PDF presentation displaying application. It is a python script that uses pdf and ghostscript for PDF rendering. It is very stylish and includes many cool page transitions, an overview feature and the ability to highlight and spotlight parts of the slide during the presentation. The above image shows the overview feature.

Installation. On Ubuntu, use apt-get:
apt-get install keyjnote
Otherwise download the software from the project site.

Use. Just launch the program from the command line with the name of a pdf file; it will use random transitions. You can specify which transitions to use through an auxiliary file.

More information. There is an online manual, and a demo presentation that highlights KeyJNote's features. It is best viewed with KeyJNote.

Mathematics on Linux

I should probably change the name of this blog to Mathematics on Linux, or something to that effect.

LaTeXDraw -- Pictue drawing for LaTeX and PSTricks: Part 2

LaTeXDraw is another GPL'd graphical PSTricks editor for LateX. It is developed in java, so it's independent of the OS, and it's available in English, in Spanish and in French.

Installation. Download and unzip. There is a readme.txt file with instructions, but you need only run 'java -jar installer.jar'.

Configuration. You need to configure some things, but the program lets you know if you try to do something that needs configuration.

Use. Draw. Cut and paste the PSTricks code into your LaTeX document.

Comparison with JPicEdt. Both have their strengths. It seems JPicEdt implements more drawing functions, but that is something that can easily change with some development. I like that one can see the PSTricks code generated by LaTeXDraw as one draws. I also prefer the look of the LaTeXDraw interface.

JPicEdt -- Picture drawing for LaTeX and PSTricks: Part 1

JPicEdt is an open source, multi-platform and interactive picture editor for LaTeX and PSTricks. You use a GUI to draw your pictures and the pictures are saved as tex source code, so you just paste the code into your latex document.

Installation. The webpage has installation instructions. Basically: download and launch the installer and follow the on-screen instructions.

Configuration. You must configure the program to point to the location of latex and friends. But I have already done this, so just copy the contents in the box below to the file ~/.jpicedt/preferences, and change USERNAME to your username.

Use. Use the TeX button to compile the image, the DviPS button to convert the image to PostScript, and the PS button to view the PostScript file. When completed, save it as a TeX file, then copy and paste it into your LaTeX document.

Comparison with LaTeXDraw. Both have their strengths. It seems JPicEdt implements more drawing functions, but that is something that can easily change with some development. I like that one can see the PSTricks code generated by LaTeXDraw as one draws. I also prefer the look of the LaTeXDraw interface.
#jPicEdt Preferences
#Sun Jul 08 11:55:29 EDT 2007
view.page-format=170 100 5 5
command.user2=
command.user1=
latex.max-emulated-line-slope=1000
latex.max-circle-diameter=14
latex.file-wrapper-prolog=\\documentclass{article} \n\\thispagestyle{empty}\n\\begin{document} \n
directory.files=/home/USERNAME
ui.dockable-panel.Toolkit.y=7
grid.snap-on=true
ui.dockable-panel.Toolkit.x=651
ui.dockable-panel.Toolkit.visible=true
eepic.thicklines=0.3
ui.desktop-color=-9803313
rendering.render=speed
pstricks.file-wrapper-epilog=\\end{document}
command.ghostview={i}/unix/tetex/ext_proc.sh {p} evince {f}.ps
ui.dockable-panel.Toolkit.width=165
canvas.zoom=100%
canvas.max-undoable-steps=100
app.language=en
ui.dockable-panel.Attributes.width=128
eepic.file-wrapper-prolog=\\documentclass{article} \n\\usepackage{epic,eepic} \n\\thispagestyle{empty}\n\\begin{document}\n
command.dvips={i}/unix/tetex/ext_proc.sh {p} dvips {f}
eepic.thinlines=0.15
latex.max-emulated-circle-segment-length=1
ui.dockable-panel.Attributes.y=0
latex.file-wrapper-epilog=\\end{document}
ui.dockable-panel.Attributes.x=0
ui.dockable-panel.Attributes.height=0
command.dvi={i}/unix/tetex/ext_proc.sh {p} xdvi {f}
view.text-font=SansSerif-10
grid.color=-4144960
latex.emulated-line-length=0.12
app.tmpdir=/tmp
grid.visible=true
ui.mdimgr=child-frames
ui.dockable-panel.Toolkit.height=343
menu.recent-file.1=/tmp/foo.tex
rendering.antialiasing=off
grid.snap-step=5.0
ui.look-and-feel=Metal
grid.line-style=solid
ui.geometry.height=720
eepic.file-wrapper-epilog=\\end{document}
ui.dockable-panel.Attributes.visible=false
rendering.fractional-metrics=off
pstricks.file-wrapper-prolog=\\documentclass{article} \n\\usepackage{pst-all} \n\\thispagestyle{empty}\n\\begin{document} \n
ui.geometry.y=0
ui.geometry.x=53
grid.display-step=10.0
rendering.text-antialiasing=off
ui.geometry.width=823
command.latex={i}/unix/tetex/ext_proc.sh {p} latex {f}
latex.max-disk-diameter=5.4
rendering.dither=off
canvas.content-type=jpicedt.format.output.latex.LatexContentType