Sweet Macbook thesis setup

Written by Walter

This is how I write my thesis now that I have my MacBook.
I got this free dell lcd from my work and I just rotated it 90 degrees so that it can view a full A4 page from thesis.pdf onscreen. On my macbook screen I have 2 terminals, one todo a make and other to edit the .tex files with good old joe :).

Anyway here is a picture:



Now there is one frustration, how to reload the preview window? So that my latex changes appear onscreen after a make. Well that turned out to be simple too with an applescript I found by Trevor Harmon, download here:
reload_pdf.scpt
Place the script file in latex files dir (for me Documents/docthesis/)

Then in the terminal do following command to remake and reload document:
make clean && make print && osascript reload_pdf.scpt thesis.pdf

More cewl applescripts by trevor can be found here.

There was one problem with the script. It opens the preview window on my current screen and not on the second screen to the left. Resizing with mouse is a no no, using a mouse is always too slow, I need to make changes to my latex press enter and view them immediately. Scripting things like this not only makes you more productive but its also the main reason I think I've never had any RSI symptoms (I've been hacking away for at least 10 years, some years with large periods of 80 hour weeks non-stop programming).

So I hacked the reload script and added the following to the reload function:

-- position screen to left monitor (by walter schreppers)
tell application "Preview" to activate
tell application "System Events" to tell process "Preview"
tell front window
set position to {-767, 0}
set size to {767, 1023}
end tell
try
click menu item "Zoom To Fit" of menu 1 of menu bar item "View" of menu bar 1
end try
end tell


The resulting script now reloads my pdf and places the preview window with exact dimensions in my left lcd screen the way I want it! It was kinda a hassle to find this. You need to use System Events instead of directly asking preview to change its size. This is because preview app by itself is not scriptable. What we have learned from this is that by using system events you can basically automate menu clicks and properties of any application. Good to know :)

reload_thesis.scpt (you probably will need to change the coordinates on a single screen or different dual screen position. Mine is on left and vertical hence the -767 x-coordinate.

Now I run this line and all is well :
make clean && make && osascript reload_thesis.scpt thesis.pdf

Ow yeah, before you say but hey a mac is all about mice and windows. Install quicksilver!!! And you never need to use a mouse again to start and/or switch to a new application :D

Back to archive