Sunday, December 30, 2007

File Associations and PATH with MacVim

UPDATE: The newest release of MacVim has a preference pane that lets you "Launch Vim processes in a login shell." If turned on, it should solve the PATH problem suffered by some Vim users.
If you use Vim for OS X or the nascent MacVim, you may have noticed that
  • your PATH is not set correctly (i.e., compilations fail) and
  • Vim is not associated with all of your text files (i.e., it doesn't show up in the "Open With" context menu)
A while ago, I realized that the gvim.app available for download from the OS X Vim site had the potential to solve both of these problems, and so I hacked it to produce:
  • gvim.app (for Vim for OS X) and
  • mvim.app (for MacVim; maybe unneeded if "Launch ... login shell" preference turned on)
To install one of these files, download the archive, unzip it, and move the application into your /Applications folder. If you start Vim from that application, it will open as usual but will have the PATH set as if you were in the Terminal (i.e., it executes a bash login before exec'ing Vim). You should also notice that the new launcher application shows up in your "Open With" menus. Finally, if you put the launcher in your Dock, you can use it to generate new Vim windows, even if Vim is already open.

Saturday, December 29, 2007

PDFSync Inverse Searches in MacVim

Remember the post on doing inverse searches in Vim on OS X? The idea was to drop gvim-pdfsync into
/usr/local/bin
(or somewhere else in your PATH) and then execute
gvim-pdfsync "%file" %line
to do inverse searches in Vim for OS X just like you can in Windows or in other UNIXes. For example, in Skim, under the PDFSync section of the Sync tab of the Preferences, you can put
Preset: Custom
Command: gvim-pdfsync
Arguments: "%file" %line

For MacVim

I thought it might be nice if I published how to do the same thing in the nascent MacVim, which supports servers just like Vim for Windows. Provided that you've installed the mvim shell script somewhere in your PATH, you can setup Skim with
Preset: Custom
Command: mvim
Arguments: --remote-tab-silent +":%line;foldo!" "%file"

or, if you don't like tabs
Preset: Custom
Command: mvim
Arguments: --remote-silent +":%line;foldo!" "%file"

Retro-Approach

Alternatively, if you really liked the gvim-pdfsync approach and want something similar for mvim, put mvimtab-pdfsync or (if you don't like tabs) mvim-pdfsync in your PATH (e.g., in /usr/local/bin) and then setup Skim for:
Preset: Custom
Command: mvimtab-pdfsync
Arguments: "%file" %line

or (if you used mvim-pdfsync)
Preset: Custom
Command: mvim-pdfsync
Arguments: "%file" %line
I hope that helps.

Sunday, November 18, 2007

Frum rhymes with Doom

On the November 15, 2007 episode of Marketplace, they aired a commentary called "Learn a Lesson from the Dark Ages" by conservative demagogue David Frum. I couldn't help but send a response.
This correspondence is regarding "Learn a lesson from the Dark Ages" by David Frum, which aired on Thursday, November 15, 2007.

The argument offered by Mr. Frum is called the "environment Kuznets hypothesis," which is an application of the classic Kuznets hypothesis to conservation. The "environmental Kuznets curve" is a "U"-shaped curve on a plane with conservation on the vertical axis and economic growth on the horizontal axis. That is, with economic growth, conservation decreases until some critical point and then increases.

It's interesting that Mr. Frum uses the Kuznets hypothesis to argue that our salvation comes from focussing on globalization. In fact, the Kuznets hypothesis only matches observational data when looking locally. In developed countries, we do see that economic growth leads to cleaner air and water and increased conservation; rich people embrace their local nature. Unfortunately, the conservation of developed countries comes at the cost of the destruction of the rest of the world. Global energy use and human population growth is still on the rise and global conservation is still falling. Additionally, every species we drive to extinction is lost permanently, so it's hard to imagine that the global conservation-growth curve can ever slope upward.

I worry that Mr. Frum's optimism is not simply outdated but is dangerous. I encourage him to consider taking a more conservative approach to the environment.

In retrospect, I could have said "which erred on ..." instead of "which aired on ...," but I would never want to be accused of sounding snarky...

Tuesday, October 02, 2007

Journal Reviewer Review

A recent paper of mine was rejected from Journal of Theoretical Biology. For fun, lets compare and contrast and selection from the reviewer comments ("MS" = "manuscript"):

From Reviewer #1:
Overall I really liked the work presented in this MS - by generalising the traditional models of the ecological economics underpinning solitary foraging behaviour the authors offer a very interesting (& in retrospect) intuitively appealing justification for accepting that the concorde fallacy may not always be fallacious.

From Reviewer #2:
This result seems to be of significance in biology, psychology, economics, and business, and I think that the paper is deserving of publication in JTB. The paper is also very well written, and the mathematical presentation is clear and precise.

Those two were pretty nice, and suggest that I should resubmit the paper with a couple tiny revisions and I'll be off and running. Great! Wait... What's this?

From Reviewer #3:
I regret to say I have no idea what this paper is about. The mathematical lingo is completely unfamiliar to me (after about 50 years of teaching and research in maths)...(details omitted)...(I recently had a grad student who wrote in this vein. When I asked him to explain in ordinary math, he gave up.) I didn't read any further. My advice is reject.

HUH?!

Tuesday, September 18, 2007

Removing WiFind

The WiFind application from TastyApps has potential, but in the end it falls short and is not worth all of the bother. WiFind will slow down your computer nearly to a halt in some cases. Because the developers made it an input manager without a preference pane, it cannot easily be turned off. Even when it's running well, it still takes a click or two in order to get it to display the information you need.

The free application coconutWiFi is almost identical to WiFind, but because it's an application, it's much easier to install, load, unload, and uninstall.

Getting rid of WiFind can be a major pain (especially if it's in the process of grinding your machine to a halt at the time). The developers gave it an installer (because it's an input manager and not an application), but despite Apple's guidelines that all programs with installers must have uninstallers, they did not give it an uninstaller.

So, here's how I went about turning OFF WiFind. WiFind uses this InputManager called "SIMBL" to modify the wireless menu directly (rather than putting up its own menu, like coconutWiFi). So, you can either remove SIMBL or remove WiFind from SIMBL so that while SIMBL loads, WiFind will not.

To remove WiFind only, look for the folder
/Library/Application Support/SIMBL/Plugins

or the folder
~/Library/Application Support/SIMBL/Plugins

where ~ is your home directory. Inside that folder, you'll find a WiFind.bundle. Move it somewhere else (or delete it) and logout (or restart) to disable/remove WiFind.

Alternatively/additionally, you can remove SIMBL. Look in the folder:
/Library/InputManagers

or
~/Library/InputManagers

where ~ is your home directory. There should be a SIMBL folder inside one of these. To remove SIMBL, delete the SIMBL folder. To disable it, remove the SIMBL folder. Again, be sure to logout or restart after making this change. When you're logged back in, SIMBL should not be loaded.

If you think you will want to turn this off later, simply move the SIMBL folder out of the InputManagers folder and into some other folder that you create (I created an InputManagersOff folder in my /Library). Next, if you logout (or restart), WiFind will not be started. At some time, you should probably also get rid of the folders
/Library/Application Support/SIMBL/

and
~/Library/Application Support/SIMBL/

where ~ is your home directory.

You might notice that there are files dropped in /Library/Receipts (or maybe ~/Library/Receipts) from WiFind (or wifind) and SIMBL. You may consider removing these files too, but it won't hurt to leave them there.

Ted E.C.E. Bear

I put this together for my ECE webpage.
Ted E.C.E. Bear
That version has a transparent background. I have a version with a white background too.

Cute? Everything except for the bear was actually "drawn" in LaTeX, which I think is pretty cool. The bear is an image I found that Yahoo thought was Creative Commons (CC) licensed. I hope its particular CC license allowed for changes...

Friday, August 31, 2007

American Naturalist BibTeX BST style file

The American Naturalist, a University of Chicago Press - Journals Division journal, specifies that AASTeX should be used to typeset submissions; however, it does not provide any BibTeX BST bibliography style file. That means that authors still have to manually manage their reference list rather than using BibTeX and a central BIB bibliography database.

The BST: I've tried to remedy this by creating amnatnat.bst, a natbib-compatible BibTeX Bibliography STyle (BST) file for the American Naturalist.

As far as I can tell, this BST will generate a properly formatted BBL file that should not require modifications. Note that American Naturalist requires authors to upload their BBL files and NOT their BIB files (i.e., they don't have the ability to run BibTeX on the server).

ONE CAVEAT: If you have titles that contain colons in them, you will have to manually (either in the BIB or the BBL) change the case of the letter following the colon. For example, if "Some Title: Subtitle" is the title, change the "S" in "Subtitle" to "s". A feature/bug of BibTeX is that its sentence case keeps letters following colons capitalized. This does not match the sentence case definition used by many journals, which considers the words after a colon being at the middle of a sentence rather than the start of a new sentence. As far as I know right now, there is no easy way to change the BST file to do this automatically for you.

FYI: This BST file was generated using amnatnat.dbj (for more details, see amnatnat_full.dbj) and amnatnat.patch.

Wednesday, August 29, 2007

Viewing man pages and text files in Skim

As discussed on the Skim wiki, it is possible to view man pages (and more) nicely formatted as a PDF in Skim.

If you use bash, try adding these lines to your .bashrc:
function skimcat () { cat $* | enscript -p - | open -f -a Skim; }
function manp () { man -t $* | open -f -a Skim; }
Alternatively, if you use tcsh, try adding these lines to your .cshrc:
alias skimcat="cat \!* | enscript -p - | open -f -a Skim"
alias manp="man -t \!* | open -f -a Skim"
Then you'll be able to do skimcat to cat files to Skim, and you'll be able to use manp to view man pages formatted in Skim.

NOTE: You can actually pipe anything that is PostScript (or PDF) formatted to Skim (via the open command shown above).

Monday, August 27, 2007

What's wrong with engineers?

"Love Affair" (Regina Spektor) lyrics
There was a love affair in this building
The kind of love affair
Which every respectable building must keep as a legend
Slowly festering through an innocent "by the way"
Or "have you heard"
He was perfect except for the fact that he was an engineer
And mothers prefer doctors
And lawyers

Yet despite this imperfection
He was clean-looking and respectable-looking
And you'll never find a mother
Who doesn't appreciate a natural man
So he grew healthy aloe vera plants by the window
Healthy teeth in his mouth
Healthy hair on his head
He grew healthy wavy brown hair on his head
The kind, the kind that babies always go for
With sticky little fingers

I have healthy hair and teeth and wavy brown hair. I don't know about the baby thing...

I'm pretty sure my aloe vera plant is dying too...

I suppose it is true that mothers rarely like me...

Thursday, August 23, 2007

LaTeX for generating Behavioral Ecology manuscript

UPDATE: Check out a more complete math-oriented template/example, that I posted as behavecol_math_template.tex. This is ready to use out of the box. It has comments. It is setup for AMS math. It has table, figure, and autoreferencing examples too.

IMPORTANT NOTE: If using amsmath environments, be sure to check out my information on making lineno compatible with amsmath environments.

UPDATE: I have put behavecol_template.tex and behavecol.bst on-line so that you don't have to do any of the following to get them.

The Oxford Journal Behavioral Ecology is not setup for LaTeX manuscript submissions. This baffles me.

So, I spent some time putting together some macros and a BibTeX style file to get up and running with this journal.

First, a template (that uses the article document class), which fixes incompatibilities between figcaps, caption, and anything that uses \ref (see behavecol_template.tex for what is below, or see behavecol_math_template.tex for a more complete example):
\documentclass[12pt]{article}

\usepackage[paper=letterpaper,margin=1.5in]{geometry}
\usepackage{setspace}\doublespacing

\usepackage{graphicx}

\usepackage[%
labelsep=newline,
justification=RaggedRight,
singlelinecheck=false,
labelfont=bf,
tableposition=top,
]{caption}
\captionsetup[table]{textfont=bf,position=above}
\makeatletter
\let\oldmakecaption\@makecaption
\makeatother

\usepackage[figon,printfigures]{figcaps}
\def\figurecapname{Figure legends}
\def\tablepagename{Tables}
\def\figurepagename{Figures}

\makeatletter
% This lets figcaps work with \ref
% However, forces \label outside of \caption
\def\phantomsection{\relax}
\let\oldfigurepage\@figurepage
\def\@figurepage{%
\@ifundefined{tf@pof}{}{%
\let\oldlabel\label%
\let\oldinput\@input%
\def\@input{\def\label{\oldlabel}\oldinput}%
\phantomsection%
\addcontentsline{toc}{section}{\figurepagename}}%
\oldfigurepage%
}
\let\@makefcaption\@makecaption
\let\oldtablepage\@tablepage
\def\@tablepage{%
\@ifundefined{tf@pot}{}{%
\clearpage%
\phantomsection%
\addcontentsline{toc}{section}{\tablepagename}}%
\oldtablepage%
}
\makeatother
\usepackage[subrefformat=subparens,labelformat=parens]{subfig}
\captionsetup[subfloat]{position=top}

\setcounter{secnumdepth}{0}

% Lines are numbered, starting at 1
% (add pagewise to reset at each page)
%\usepackage[modulo,pagewise,mathlines]{lineno}
\usepackage[modulo,mathlines]{lineno}
\modulolinenumbers[1]
\firstlinenumber{1}
\linenumbers

\usepackage{natbib}
\bibliographystyle{behavecol}
\setcitestyle{%
authoryear,round,semicolon,%
aysep={},%
yysep={,},%
notesep={, }%
}

\usepackage{tocbibind}
\def\tocbibname{\refname}

\usepackage{varioref}
\labelformat{equation}{\textup{(#1)}}
\labelformat{enumi}{\textup{(#1)}}

\usepackage[%
pdftitle={},
pdfsubject={},
pdfauthor={},
pdfkeywords={},
pdfstartview=FitH,
bookmarks=true,bookmarksopen=true,
breaklinks=true,
colorlinks=false,
pdfpagelabels=true,hypertexnames=true,
plainpages=false,naturalnames=false,
%draft,
]{hyperref}

% \Autoref is for the beginning of the sentence
\let\orgautoref\autoref
\providecommand{\Autoref}
{\def\equationautorefname{Equation}%
\def\figureautorefname{Figure}%
\def\subfigureautorefname{Figure}%
\def\Itemautorefname{Item}%
\def\tableautorefname{Table}%
\orgautoref}

% \Autorefs is plural for the beginning of the sentence
\providecommand{\Autorefs}
{\def\equationautorefname{Equations}%
\def\figureautorefname{Figures}%
\def\subfigureautorefname{Figures}%
\def\Itemautorefname{Items}%
\def\tableautorefname{Tables}%
\orgautoref}

% \autoref is used inside a sentence
% (renew of the standard autoref)
\renewcommand{\autoref}{\Autoref}

% \autorefs is plural for inside a sentence
\providecommand{\autorefs}{\Autorefs}

\let\oldsection\section
\newcommand{\uppercasesection}[2][]{%
\oldsection[#1]{\MakeUppercase{#2}}}
\newcommand{\uppercasesectionstar}[1]{%
\oldsection*{\MakeUppercase{#1}}}
\makeatletter
\def\section{%
\@ifstar{\uppercasesectionstar}%
{\@dblarg{\uppercasesection}}}
\makeatother

\hypersetup{%
pdftitle=
{The title},
}
\title{The title}
\author{}
\date{}

\begin{document}

\maketitle

\begin{abstract}
% ...The abstract...
\textit{Key words:} Keywords separated with comma+space,
List ends with period.
\hypersetup{%
pdfkeywords=
{Keywords separated with comma+space,
List ends with period},
}
\end{abstract}
\newpage

% ...The document...

% The following line loads the references
\bibliography{the_bib_database_name}

\end{document}
Of course, remember to put table captions before the actual table insertion. In fact, it is important that the inside of a table environment has caption first, then label OUTSIDE of the caption, then the actual table content. Additionally, subfigures should be inserted (within a figure environment) with something like:
\subfloat[]{
% ... something like an \includegraphics ...
\label{fig:a}
}
Also, when you're ready to submit, get rid of the % on the %draft, line of the hyperref options. This will turn off all hyper linking, which will prevent strange little unlinked boxes from being drawn in your autogenerated proof.

Next, the bibliography style file, which I may end up posting later separately. As of right now, it has to be constructed from pieces. First, save the following as behavecol.dbj (see behavecol_full.dbj for more details):
%% Driver file to produce behavecol.bst from merlin.mbs
%% Generated with makebst, version 4.1 (2003/09/08)
%% Produced on 2007/08/23 at 12:02
%%
\input docstrip

\preamble
----------------------------------------
*** Bibliography style for _Behavioral Ecology_. ***

\endpreamble

\postamble
End of customized bst file
\endpostamble

\keepsilent

\askforoverwritefalse
\def\MBopts{\from{merlin.mbs}{%
ay,nat,nm-rvx,ed-rev,jnrlst,keyxyr,dt-beg,yr-per,note-yr,jxper,%
jttl-rm,thtit-a,vnum-x,pp-last,num-xser,btit-rm,bt-rm,add-pub,%
pre-edn,in-col,pp,abr,ednx,ord,jabr,xand,etal-xc,nfss,}}
\generate{\file{behavecol.bst}{\MBopts}}
\endbatchfile
and then run latex behavecol.dbj. Next, save the following to behavecol.patch:
--- behavecol.bst 2007-08-29 12:07:40.000000000 -0400
+++ behavecol_new.bst 2007-08-29 12:08:01.000000000 -0400
@@ -89,7 +89,7 @@
FUNCTION {output.nonnull}
{ 's :=
output.state mid.sentence =
- { ", " * write$ }
+ { ". " * write$ }
{ output.state after.block =
{ add.period$ write$
newline$
@@ -144,6 +144,9 @@
FUNCTION {add.blank}
{ " " * before.all 'output.state :=
}
+FUNCTION {add.semicolon}
+{ ";" * before.all 'output.state :=
+}

FUNCTION {date.block}
{
@@ -248,7 +251,7 @@
{ "in" }

FUNCTION {bbl.pages}
-{ "pp." }
+{ "p." }

FUNCTION {bbl.page}
{ "p." }
@@ -260,10 +263,10 @@
{ "Tech. Rep." }

FUNCTION {bbl.mthesis}
-{ "Master's thesis" }
+{ "[Master's thesis]" }

FUNCTION {bbl.phdthesis}
-{ "Ph.D. thesis" }
+{ "[PhD thesis]" }

FUNCTION {bbl.first}
{ "1st" }
@@ -488,6 +491,16 @@
}
if$
}
+FUNCTION {format.book.pages}
+{ pages "pages" bibinfo.check
+ %duplicate$ empty$ 'skip$
+ empty$ 'skip$
+ { add.semicolon
+ add.blank
+ pages "pages" bibinfo.check
+ " " * bbl.pages * }
+ if$
+}
FUNCTION {format.note}
{
note empty$
@@ -950,6 +963,10 @@
}
if$
}
+FUNCTION {format.university.address}
+{ school "school" bibinfo.warn format.org.or.pub
+}
+
FUNCTION {format.publisher.address}
{ publisher "publisher" bibinfo.warn format.org.or.pub
}
@@ -1148,12 +1165,11 @@
author format.key output
format.date "year" output.check
date.block
- format.title
- "title" output.check
- new.block
+ format.title "title" output.check
+ add.blank
bbl.mthesis format.thesis.type output.nonnull
- school "school" bibinfo.warn output
- address "address" bibinfo.check output
+ format.university.address output
+ format.book.pages output
new.block
format.note output
fin.entry
@@ -1178,12 +1194,11 @@
author format.key output
format.date "year" output.check
date.block
- format.title
- "title" output.check
- new.block
+ format.title "title" output.check
+ add.blank
bbl.phdthesis format.thesis.type output.nonnull
- school "school" bibinfo.warn output
- address "address" bibinfo.check output
+ format.university.address output
+ format.book.pages output
new.block
format.note output
fin.entry
Then run
patch < behavecol.patch
from the same directory that you ran the DBJ command in. That should generate the behavecol.bst file that is needed for the above template to work.

Wednesday, August 22, 2007

d'Feet ALS Walk Time Again!

This year, the Columbus d'Feet ALS Walk is on Sunday, September 16, 2007.

My brother has ALS (Lou Gehrig's disease), and we participated in this walk for the first time last year (he was diagnosed last year). There was a great turnout. It was neat to see the support from the community.

So, while it's getting late, I hope people will visit my d'Feet ALS walk page and make a donation or become a walker themselves.

Wednesday, August 08, 2007

Broken sections in Elsevier elsart1p, elsart3p, and elsart5p

UPDATE: You should probably add
\def\@seccntformat#1{{\@secnumfont{}\csname the#1\endcsname.}\quad}
around line 128 (i.e., after the \@secnumfont definition) as well. Alternatively, you could add something similar (surrounded by \makeatletter and \makeatother) to your preamble.

Ever notice how section* is broken in elsart1p.cls, elsart3p.cls, and elsart5p.cls from Elsevier? Because of this, the section titles for the acknowledgments (i.e., from \ack) and the references look like normal text. Plus, the references do not show up in the PDF bookmarks. This "feature" is annoying; working with journals generally is.

How to fix this? You have to hack the document class files. In particular, you need to remove (or comment by placing a % on the beginning of the line) a chunk of lines from the document class of interest to you. In particular, remove
  • elsart1p.cls - lines 144--196
  • elsart3p.cls - lines 147--199
  • elsart5p.cls - lines 144--196
These lines redefine the LaTeX internals \@startsection, \@sect, and \@ssect. However, it does not appear there is any good reason why Elsevier has done this, so just stick with the standard ones. This will make your document look much better too.

Until Elsevier does this for you, you should upload your modified document class with your article OR use the elsart document class in the version you send to Elsevier.

Tuesday, August 07, 2007

lineno and amsmath compatibility

UPDATE 2 (READ THIS!): As Ulrich Diez points out, this can be made more compact. Here's the result (place this in the preamble, probably anywhere):
\newcommand*\patchAmsMathEnvironmentForLineno[1]{%
\expandafter\let\csname old#1\expandafter\endcsname\csname #1\endcsname
\expandafter\let\csname oldend#1\expandafter\endcsname\csname end#1\endcsname
\renewenvironment{#1}%
{\linenomath\csname old#1\endcsname}%
{\csname oldend#1\endcsname\endlinenomath}}%
\newcommand*\patchBothAmsMathEnvironmentsForLineno[1]{%
\patchAmsMathEnvironmentForLineno{#1}%
\patchAmsMathEnvironmentForLineno{#1*}}%
\AtBeginDocument{%
\patchBothAmsMathEnvironmentsForLineno{equation}%
\patchBothAmsMathEnvironmentsForLineno{align}%
\patchBothAmsMathEnvironmentsForLineno{flalign}%
\patchBothAmsMathEnvironmentsForLineno{alignat}%
\patchBothAmsMathEnvironmentsForLineno{gather}%
\patchBothAmsMathEnvironmentsForLineno{multline}%
}
This is all that is needed for the standard AMS math environments. However, if you want to add environment BLAH, you can add
\patchAmsMathEnvironmentForLineno{BLAH}
before the closing curly brace. If you want to add environments BLAH and BLAH*, you can add
\patchBothAmsMathEnvironmentsForLineno{BLAH}
before the closing curly brace.

UPDATE 1: If you use the mathlines lineno option, you may notice that amsmath environments like align may create strange double numbers at the end of the environment. I haven't looked into why this is the case. If you really need mathlines loaded, you may want to consider ways of using equation or equation* exclusively. Keep in mind that you will still need to load at least the equation and equation* lines:
\AtBeginDocument{%
%
\let\oldequation\equation%
\let\endoldequation\endequation%
\renewenvironment{equation}%
{\linenomath\oldequation}{\endoldequation\endlinenomath}%
%
\expandafter\let\expandafter\oldequationstar\csname equation*\endcsname%
\expandafter\let\expandafter\endoldequationstar\csname endequation*\endcsname%
\renewenvironment{equation*}%
{\linenomath\oldequationstar}{\endoldequationstar\endlinenomath}%
}
You may think that the displaymath option of lineno will do this for you, but loading amsmath seems to prevent that. I haven't looked into why.

A comp.text.tex post gives some history behind this fix.

It's well-known that lineno and amsmath don't play well together. After loading amsmath, the paragraph that precedes an equation, equation*, align, align*, or any of the other amsmath environments will cease to get line numbers. The ugly fix to this is to wrap every math environment with a linenomath environment. That's pretty annoying. Here's a fix that redefines the equation environment and the amsmath environments so that they'll work with noalign. Yes, it even handles the starred versions of these.
% To deal with amsmath, must redefine math environments later
\AtBeginDocument{%
%
\let\oldequation\equation%
\let\endoldequation\endequation%
\renewenvironment{equation}%
{\linenomath\oldequation}{\endoldequation\endlinenomath}%
%
\expandafter\let\expandafter\oldequationstar\csname equation*\endcsname%
\expandafter\let\expandafter\endoldequationstar\csname endequation*\endcsname%
\renewenvironment{equation*}%
{\linenomath\oldequationstar}{\endoldequationstar\endlinenomath}%
%
\let\oldalign\align%
\let\endoldalign\endalign%
\renewenvironment{align}%
{\linenomath\oldalign}{\endoldalign\endlinenomath}%
%
\expandafter\let\expandafter\oldalignstar\csname align*\endcsname%
\expandafter\let\expandafter\endoldalignstar\csname endalign*\endcsname%
\renewenvironment{align*}%
{\linenomath\oldalignstar}{\endoldalignstar\endlinenomath}%
%
\let\oldflalign\flalign%
\let\endoldflalign\endflalign%
\renewenvironment{flalign}%
{\linenomath\oldflalign}{\endoldflalign\endlinenomath}%
%
\expandafter\let\expandafter\oldflalignstar\csname flalign*\endcsname%
\expandafter\let\expandafter\endoldflalignstar\csname endflalign*\endcsname%
\renewenvironment{flalign*}%
{\linenomath\oldflalignstar}{\endoldflalignstar\endlinenomath}%
%
\let\oldalignat\alignat%
\let\endoldalignat\endalignat%
\renewenvironment{alignat}%
{\linenomath\oldalignat}{\endoldalignat\endlinenomath}%
%
\expandafter\let\expandafter\oldalignatstar\csname alignat*\endcsname%
\expandafter\let\expandafter\endoldalignatstar\csname endalignat*\endcsname%
\renewenvironment{alignat*}%
{\linenomath\oldalignatstar}{\endoldalignatstar\endlinenomath}%
%
\let\oldgather\gather%
\let\endoldgather\endgather%
\renewenvironment{gather}%
{\linenomath\oldgather}{\endoldgather\endlinenomath}%
%
\expandafter\let\expandafter\oldgatherstar\csname gather*\endcsname%
\expandafter\let\expandafter\endoldgatherstar\csname endgather*\endcsname%
\renewenvironment{gather*}%
{\linenomath\oldgatherstar}{\endoldgatherstar\endlinenomath}%
%
\let\oldmultline\multline%
\let\endoldmultline\endmultline%
\renewenvironment{multline}%
{\linenomath\oldmultline}{\endoldmultline\endlinenomath}%
%
\expandafter\let\expandafter\oldmultlinestar\csname multline*\endcsname%
\expandafter\let\expandafter\endoldmultlinestar\csname endmultline*\endcsname%
\renewenvironment{multline*}%
{\linenomath\oldmultlinestar}{\endoldmultlinestar\endlinenomath}%
%
}
The pattern is pretty clear. You can use it along with any of your own environments. For example, add this at the end (before the closing curly brace) to fix your BLAH environment:
\let\oldBLAH\BLAH%
\let\endoldBLAH\endBLAH%
\renewenvironment{BLAH}%
{\linenomath\oldBLAH}{\endoldBLAH\endlinenomath}%
and drop this at the end (before the closing curly brace) to fix your BLAH* environment:
\expandafter\let\expandafter\oldBLAHstar\csname BLAH*\endcsname%
\expandafter\let\expandafter\endoldBLAHstar\csname endBLAH*\endcsname%
\renewenvironment{BLAH*}%
{\linenomath\oldBLAHstar}{\endoldBLAHstar\endlinenomath}%
I hope that's useful for someone.

cleveref incompatibilities with Elsevier and Springer

elsart problems: If you try using cleveref with any of the elsart packages, you may get this error:
! TeX capacity exceeded, sorry [input stack size=5000].
\cl@part ->\cl@part
\@elt {section}
This is due to a flaw in the elsart packages. They setup some part counters even though part isn't defined. This confuses cleveref. To fix this, add the following anywhere in your preamble:
\makeatletter \let\cl@part\relax \makeatother
Later, you can use cleveref's poorman option to strip all of the cleveref stuff from your document. After that, you can remove this line.

svjour problems: Similarly, if you try combining cleveref with Springer journal support files, you may get this error:
! TeX capacity exceeded, sorry [input stack size=5000].
\cl@chapter ->\cl@chapter
\@elt {theorem}
Again, this is due to a flaw in the Springer packages. They setup some chapter counters even though chapter isn't defined. To fix this, add the following anywhere in your preamble:
\makeatletter \let\cl@chapter\relax \makeatother
Again, this can be removed after cleveref's poorman procedure is applied.

Source and acknowledgments: The Springer solution was given by "Dan" in a comp.text.tex post. I used it to generate the elsart solution.

Friday, August 03, 2007

Eww York

I attended a wedding on, appropriately enough, Wednesday. The wedding was in New York. Before the wedding, I received this from the bride:
I'm having wedding moments that I actually want to share with you like a giddy little girl! First, all of my "bridesmaids" (they're actually just roasting me at the dinner) are getting vibrators as gifts, and all of our groomsmen (read: same as the other) are getting flasks engraved "Cunt" in roman lettering. Ha! I thought you'd find that amusing, if nothing else.
It was a small wedding. This was the for-friend version. There will be a larger for-family reception in Jersey o'er the weekend. While I think the bride and groom are atheists, notheists, or both, the wedding was a little Goddy. However, that was to be expected since the bride used to work for the church. It was a beautiful church and a lovely wedding. Instead of a reception, there was a dinner with a small after-party. Since the wedding didn't start until 5:30PM, we had a chance to see New York (NY) during the day. Some reflections/reports about the New York City (NYC) visit (my first NY visit ever, BTW):

  • My first memorable experience in New York was merging into the single lane that goes through the Holland Tunnel. There was a surprising amount of traffic considering that we were entering NY at 1AM. In Ohio, when we go from four lanes into one, we merge lanes 1 and 2 into one land and 3 and 4 into another lane, and THEN merge those two lanes. That's not how they do it in NY. In NY, they just get rid of the concept of "lane" at all and have everybody merge at once. Turn signals and stoplights are optional, and so they are generally ignored. Nudge your way in wherever you can. People will probably stop, but you won't have more than an inch on any side of your car at any time.

  • My second memorable NY experience was a few minutes later when we got into the Hotel Room. Jessie looks out the hotel room window at the apartment building an alley away and says to me, "There's a naked guy in that apartment!" I look a little closer and respond, "Huh. He's masturbating." In fact, he continued masturbating for the next few hours. This was done in front of wide open windows. We would periodically check back on him by peeking through our closed blinds. At one point, he came up to his window bent over (while still whacking off) and waved at us. At another point, he picked up a large towel and dabbed his forehead with it (I'm guessing he used it for cleanup as well). Yes, he was completely shaven. Yes, we did get pictures and video. No, I'm not going to post it. I was going to post pictures or the video, but then I remembered that there are people out there who think free speech does not extend farther than burning a cross in a blackie's yard. Thus, I'll let you imagine it. We figured he just didn't have any blinds to close. However, his blinds were closed when we woke up the next morning.

  • I hope Times Square is better looking at night. In the day, it's just a little ugly, creepy, and underwhelming.

  • Madison Square Garden is old and ugly (at least from the outside).

  • Paninis in NYC are of equal or lesser value to paninis anywhere else.

  • The American Museum of Natural History is wonderful and huge and a terrific value (considering that you set your own price to get in).

  • Central Park is pretty in some parts.

  • Dogs defecate on the sidewalks in a city like NYC.

  • New Jersey is full service by law, and I hate it, and I think I made that pretty clear to the attendant.
So, there you have it. :)

Friday, July 27, 2007

Star Trek XI? How did I miss this?!

How did I miss that in April 2006, it was announced that there would be an eleventh Star Trek film?! This just made my day!
Star Trek is the working title of the planned eleventh entry in the Star Trek film series—based on Gene Roddenberry's science fiction franchise. Sometimes referred to as Star Trek XI, the film received extensive coverage in the entertainment press during 2005 and 2006. In April 2006, after several years of rumor and speculation, Paramount Pictures announced that the film will be produced by Lost co-creators J. J. Abrams (who is also directing the film) and Damon Lindelof, and written by Roberto Orci and Alex Kurtzman, who will also be executive producing along with Bryan Burk. In July 2007, it was revealed and officially announced by Paramount that the movie will star Zachary Quinto and Leonard Nimoy.

Although few details are known about the film at this point, it has been confirmed that the film will feature James T. Kirk and Spock, and will be released on December 25, 2008.

I need to go to more movies! I don't think that there have been trailers for this yet, but maybe!! I'm getting chills when I look at...
Star Trek teaser poster
And look at the directors! And creators! And actors!! I need to get away from the computer and go and calm down somewhere... You should check out more information that was recently released.

The Shell is Back!

As of Windows XP, the shell is back. Microsoft now distributes PowerShell (PoSH). It has lots of nice features. See the Microsoft website where you can download it for free. You can find other PoSH links at Wikipedia.

Notice how command-line interfaces (CLI's) are making a huge comeback? After years of mousing, people have finally come to the (correct) realization that mousing sucks. So now we have things like QuickSilver, Spotlight (and Vista's equivalent), SlickRun, and others [1, 2, 3, 4, 5]. Mozilla Quick Searches and Google Desktop are just as much examples of this. The real hacker moves around with hot keys, macros, and short commands. Dare I say it is hip and trendy to stay close to the keyboard and use the mouse as little as possible?

I'm not saying the mouse has no place. Certainly, there are lots of applications where that interface is needed. However, the operating system is not one of those places. We need multiple interfaces, and the mouse probably belongs best to graphics applications that call for tugging and shifting things around in continuous ways. For the rest of the computer, just give me the keyboard.

Thursday, July 26, 2007

Tedly Quick Searches

If you're not familiar with keywords and quick searches in Mozilla Firefox and Mozilla Camino, you should check out "Fifteen Firefox Quick Searches" and "Firefox and the art of keyword bookmarking." Mozilla quick searches and keywords shave hours off each of my weeks (if not days).

I've posted my quick searches, and you can save them and import them into your own Mozilla bookmarks. For instructions on how to do this, see the quick searches post from above. My quick search bookmarks are basically an improvement on the bookmarks given in that post. I've fixed some annoying things about her selections, and I've added a few more.

If you do use my bookmarks, be sure to modify the local one and change the zipcode from 43210 to your zipcode.

Wednesday, July 25, 2007

VIM-LaTeX Modification: Forward Searching in OS X

UPDATE 3: If it doesn't seem like commands are launching from within Vim, check out my post on setting PATH in Vim. In particular, if you are using the nascent MacVim, checking the "Launch Vim processes in a login shell" preference may fix your problems.

UPDATE 2: I've updated the patch file to fix a few bugs in my original implementation (thanks to Ross M. Richardson for the help!). This version supports forward searching from multi-file projects. By the way, if you didn't know, if you have a project with multiple files where the main LaTeX document is called my_latex_file.tex, you should create a dummy file called my_latex_file.latexmain in the same directory. That way, VIM-LaTeX will know to run its compiler and viewer on the main file and not on any of the smaller constituent files.

UPDATE 1: Skim 0.6 and up supports spell checking of a PDF. This is a strange feature of a PDF viewer since Skim does not allow you to edit the PDF text directly. However, it makes a lot of sense when inverse searches are supported. After doing Shift+Command+CLICK on the misspelled word, the TeX editor will open up near the line of TeX where the word is found.

I have already commented on doing inverse searches (or backward searches) in Vim on OS X. However, I have not handled forward searches. Ross M. Richardson offers a hack for doing forward searches into PDFView; however, it's clear that while this is a hack it is certainly not a lifehack. What I really want is a version of VIM-LaTeX that supports using PDFView, Skim, TeXniscope, or any UNIX shell script as a forward-search-compatible viewer.

The script I presented in an earlier post makes backward searches compatible in nearly any PDF/DVI viewer. Now, I just need to hack compiler.vim to do the reverse. I did this by modifying the Tex_ViewLaTeX and Tex_ForwardSearchLaTeX functions from the 20060325 release of VIM-LaTeX. You can find my changes in VIM-LaTeX-osx-inverse-search-compiler.patch. To apply the patch, go into your ~/.vim/ftplugin/latex-suite/ directory, backup your old compiler.vim file, and try
patch -p0 < VIM-LaTeX-osx-inverse-search-compiler.patch
Of course, you should either drop the patch file into that directory or change the patch command so it has the full path to the patch. Now, all you need to do is configure your ~/.vimrc and you'll be able to use \lv for viewing and \ls for forward searches.

OS X Applications: Say that I want to use Preview to view PostScript files, TeXniscope to view DVI files, and Skim to view PDF files (note that both TeXniscope and Skim can open all of these, but only TeXniscope supports DVI source specials). In that case, I could put these lines in my ~/.vimrc file:
let g:Tex_ViewRule_ps = 'Preview'
let g:Tex_ViewRule_pdf = 'Skim'
let g:Tex_ViewRule_dvi = 'TeXniscope'
Now, VIM-LaTeX will use these whenever \lv (for viewing) or \ls (for forward search) are used. That's right, it will do forward searches with these OS X applications (well, Skim and TeXniscope)! That's easy enough.

UNIX Viewer Scripts: Now, let's say I wanted to use the skim and texniscope scripts that I built earlier. In this case, I use the following in my ~/.vimrc file:
let g:Tex_TreatMacViewerAsUNIX = 1
let g:Tex_ExecuteUNIXViewerInForeground = 1
let g:Tex_ViewRule_ps = 'skim'
let g:Tex_ViewRule_pdf = 'skim'
let g:Tex_ViewRule_dvi = 'texniscope'
That g:Tex_TreatMaxViewerAsUNIX tells VIM-LaTeX not to use open -a to open the viewer. The g:Tex_ExecuteUNIXViewerInForeground gets rid of the & appended to the end of the execution strings used by VIM-LaTeX. For some reason, this option needs to be set to get UNIX viewers to work in MacVim.

Empty Viewer Scripts and Other Stuff: As before, if those ViewRule variables are set to empty values (i.e., ''), open -a will be used. On the other hand, if g:Tex_TreatMacViewerAsUNIX is set, VIM-LaTeX will act like it does on a UNIX machine, and xdvi, xdvik, and kdvi can be used. These three DVI viewers are handled specially. Any other UNIX script should follow the convention:
script "%target_file" %line "%source_file"
where script is the UNIX command, %target_file is the main PDF, PS, or DVI file to open, and %line is the line in the TeX source file %source_file for forward searching (i.e., using \ls). If \lv is being used, the %line and %source_file parts are omitted.

Tuesday, July 24, 2007

Google School: Synonyms and Info

From Google School:

Google School: Rank Wikipedia articles in your results
If you want to get general background on something with Google, append the word "info" or "information" to your search term.

If your words appear in the title of a Wikipedia page, Google will list that article at the top of your results, for a convenient way to search both Google and the Wikipedia at once. --Gina Trapani


Also, from Lifehacker: 88 Tech Tricks to Turbocharge Your Day, by Gina Trapani:

Synonyms (Chapter 9, p. 223)
Search for synonyms using the tilde (~) next to keywords. This comes in handy when you are searching for a concept rather than for a specific word or sequence. For example:
  • ~nutrition ~information muffins returns exact matches as well as matches on Muffins Food Facts and Muffins Vitamin Information.
  • ~car turns up information on trucks and vehicles.
  • A search for ~pen yields pencils, graphite, and sketch.

Beware of Aronoff?

I walk by this "Caution: Floor Wet" sign every day. I think it's funny because it's in Dreese Labs, which is very far away from Aronoff Laboratory.
Caution: Aronoff

It's as if the ECE's are being warned about the EEOB people.

Monday, July 23, 2007

Scrobbling Pandora Songs to Last.fm!

UPDATE: I just found OpenPandora, which is like a PandoraJam for Windows (i.e., it is a desktop Pandora application that scrobbles to Last.fm). So, our list of cool Pandora+Last.fm apps and mashups is now...
  • PandoraJam - OS X Desktop application that plays Pandora and scrobbles to Last.fm. It also includes lots of other cool features, like recording Pandora streams to a format that can be used by iTunes and the iPod.

  • OpenPandora - Windows Desktop application that plays Pandora and scrobbles to Last.fm. It also includes other cool features, like integration with the Wiimote and some software applications.

  • PandoraFM - Web mashup that combines Pandora and Last.fm. This mashup does more than just scrobble to Last.fm; it really combines nearly everything of Pandora with nearly everything of Last.fm. For example, you can access tags and music information from Last.fm.
I'm not sure which is my "favorite." I'm just happy that these are available. I have a feeling there are more too.

I love Pandora. I also love Last.fm. I feel bad when I listen to Pandora because my songs don't get scrobbled to Last.fm. It's like all of that good listening time is just being wasted. However, I feel like I get exposed to more NEW music through Pandora because I primarily use Last.fm to listen to my own station.

Today, I accidentally found PandoraJam, which solves this problem! It is a desktop application (like PandoraBoy) that streams from Pandora and, at the end of each Pandora song, scrobbles to Last.fm! This gives me the best of both worlds! It has other features too. For example, you can record Pandora audio so you can take it with you later on your iPod. However, the scrobbling feature (which is the only entirely free feature) is the one that really impresses me.

However, this isn't a perfect solution. For one, it doesn't help me when I'm on a Windows machine. Second, it doesn't let me do cool Last.fm things like "Love" tracks. So, I went searching, and I found PandoraFM. This is a WEB mashup that combines Last.fm and Pandora. In fact, it even scrobbles at half the length of the song after a configurable number of seconds (default is 90), which is more like what you'd expect. So it's great! Solves all my problems.

So, if you use both Last.fm and Pandora, you need to check out PandoraFM.

iUseThis: The OS X Software that I Use

Are you interested in the software that I use on my Mac? See my iUseThis profile.

You can use iusethis.com to see what people are using and find software related to other software. You can even setup your own profile and keep track of the software that you use.

Desktop Manager for OS X

This is not anything new, but there is a very nice freeware (open source) Desktop Manager for OS X. That is, this implements virtual desktops (i.e., multiple desktops that you can switch between; this lets you spread your apps across different screens).

It has a lot of cool features.

The Quick Reference Site (Cards and Books)

UPDATE 3: I did find the source of that regular expression card at Gordon McKinney's Pro IT Blog. Well, it's not a LaTeX source, but it's at least in letter format.

UPDATE 2: I found another good list of quick reference cards at the plantOzh blog. It includes a a regexp card, Perl 5 booklet, and CSS cards (1.0, 2.0). Yes, these cards are archived at the blog, so all of the commentary below still applies.

UPDATE 1: It's also annoying when someone simply archives existing quick reference cards because sometimes those archives use A4 paper. If these were linked to their origins, the source code (perhaps LaTeX) might be available, making a conversion to letter paper easy.

Lately, I have been quick reference happy [1, 2, 3, 4]. I cannot explain why, but I suddenly want to surround myself with quick references.

I think I found a great new quick reference resource. It's The Quick Reference Site, which features quick reference cards, e-books, and other papers and tutorials. From the site:
Throughout the years I have collected a huge pile of documents that deal with almost every aspect of software development. The purpose of this site is to centralize this information and to make it available to everyone who may need it or shares my passion on this subject. There are still a lot of documents in my "archive" that I like to share with you all.
At the moment this site represents only a fraction of what I want to provide, so a lot of work still needs to be done. As a result, you should consider this site as a work in progress. I'll try to keep you updated on the most challenging, powerful and continuously evolving software technologies of the moment. I hope that especially Java and C++ fanatics (like myself) will find some valuable information over here.
As far as I can tell so far, the author archives quick references that he has found over time and links us, the readers, to those archives. The advantage of this is that it minimizes the chances of broken links. The disadvantage is that the archives may not be the most recent versions. Additionally, if this site ever goes down and our bookmarks point there, those bookmarks will be broken.

Some quick reference cards that I want to point out (if you go to his list, you can also read descriptions of these programs):

So, that's fun.

On a slightly unrelated note, you can also check out Hawk Wings to find a QuickSilver quick reference and the QuickSilver user manual.

Sunday, July 22, 2007

Top 10 Computing Energy Savers

Top 10 Computing Energy Savers
Reducing the amount of energy your hungry computers eat up every day won't only save you money on electricity bills, it will reduce your carbon footprint. If you haven't thought about how much electricity your gadgets use up every day, now's the time. Turns out just a few changes in habits and system settings can save you money AND the environment. After the jump, have 10 ways to reduce your energy consumption and compute greener.

The site lists 10 tips for reducing the amount of energy your computer (and other devices) waste. Each tip has a link giving more information (e.g., what a "smart power switch" is).

Seeqpod: Playable Search

Also try SkreemR (http://skreemr.com/), another playable music search (with some other cool features). The Tech-Reicipes Blog has a good description of the coolest features.

Try out SeeqPod (http://www.seeqpod.com).

It's a new search engine that searches the web for playable MP3 songs and then lets you play them right on the web page.

It's a great way to find free MP3 music, and it's arguably legal! :)

Copyright Explained

"Copyright Explained: I May Copy It, Right?" from Smashing Magazine
With blogging comes great responsibilty. You define the content of your weblog and you carry the full responsibility for every word you’ve published online. More than that, you are responsible for comments in your posts. To make sure you fulfill your legal obligations, it’s important to know, what you, as blogger, may or should do; and you have to know, how to achieve this. After all, the ignorance of the law does not make one exempt from compliance thereof.

This article explains copyright and how it applies to electronic material. Sure, it's focussed at bloggers, but anyone who is starting a career that involves publishing might be interested in this.

Thursday, July 19, 2007

Tech. Cheat Sheets!

Check out the recent "Developer’s Alarm: 200+ Hotkeys To Boost Your Productivity" from Smashing Magazine for more hotkeys. This focusses on Windows apps, but there are some apps that have cross-platform support, and so this isn't an entirely worthless post.

In the spirit of previous posts [1, 2, 3], here are some more!

I found TechCheatSheets.com, which includes some nice reference sheets, and some broken links. However, it got me thinking about "cheat sheet," which got me searching, and I found these popular links:
That last one probably beats my Thunderbird quick reference (PDF, LaTeX). However, those do not replace my Camino quick reference (PDF, LaTeX).

My (Reference) Desk

Now that I have compiled all of these quick references [1, 2, 3], I can put them together to surround myself in easy-to-access information. In fact, I will. I did. Here it is! From left to right (pictures taken with my wonderful phone and stored in a flickr photoset)...

Left of the Desk
Right of the Desk
Next to the Desk

Hot Key References

NOTE: The two updates below may serve as good LaTeX examples featuring the use of multicol.

UPDATE 2: I have used the Thunderbird list to make a Thunderbird quick reference PDF (LaTeX source available).

UPDATE 1: I have used the Camino list to make a Camino quick reference PDF (LaTeX source available).

I have been posting about quick references a lot lately [e.g., 1, 2]. I found another good quick reference site, allhotkeys.com. It has lots of software hotkey quick references. For example,
So that's potentially helpful. But right now the pages are really slow to come up, so I have no idea what they look like. Nor do I know if I can easily get them onto a landscape sheet of paper that I can tape to the wall somewhere...

Wednesday, July 18, 2007

Traditional way to change cleveref defaults

UPDATE: cleveref also includes a set of defaults for the ntheorem package when the ntheorem option is given. I've just put those defaults into cleveref_nthoerem_defaults.tex. Include it with \input{cleveref_ntheorem_defaults.tex} after (or instead of) including the other file.

Because it will probably be a long time until a simpler way of changing cleveref defaults gets implemented, I needed a way to change these defaults without adding tens of lines to my LaTeX source. I came up with cleveref_defaults.tex, which basically contains all of the default lines from the cleveref documentation, plus a set of table defaults. You can include it with:
\input{cleveref_defaults.tex}
Then, go ahead and modify cleveref_defaults.tex to match your conventions (e.g., change the four "eq." to "Eq." and the four "eqs." to "Eqs.").

Protype for simplifying changing cleveref defaults

UPDATE: I have created crefntheoremdefaults.tex, which does this same stuff to the ntheorem package. You have to be sure to include the crefdefaults.tex file first. The files crefntheoremdefault_constants.tex and crefntheoremdefault_formats.tex play a similar role as the analogous ones below.

I think the package cleveref is great. In fact, I think it has much of what has been missing from LaTeX for a long time. See its documentation for more information about the package.

My only gripe about cleveref is that it is tedious to change something like all of the default "eq." and "eqs." to "Eq." and "Eqs.", respectively. So I put together these scripts as a kind of proof of concept (they also setup cleveref to handle table references, something that is not done by default at the moment):

The first script, crefdefaults.tex, is simply crefdefault_constants.tex concatenated with crefdefault_formats.tex. Therefore,
\input{crefdefaults.tex}
is equivalent to
\input{crefdefault_constants.tex}
\input{crefdefault_formats.tex}
However, if the poorman option is used and the corresponding sed script is applied, the resulting file will need to have the content of crefdefault_formats.tex removed; crefdefault_constants.tex should not be removed. In other words, if you are planning on using poorman, use the 2-line include and comment the crefdefault_formats.tex line out of the script that results from the sed script.

What's the outcome of this? I can now do
\renewcommand{\crefenumilabelformat}[3]{\textup{(#2#1#3)}}
in order to change every item reference so that it is surrounded by upright round braces. Additionally, changing "eq." to "Eq." and "eqs." to "Eqs." is as simple as it was in hyperref (for use with \autoref); that is, it is these two lines:
\renewcommand{\crefequationname}{Eq.}
\renewcommand{\crefpluralequationname}{Eqs.}
Unfortunately, the output of the poorman sed filter is a little messy. However, if these are someday integrated into cleveref, that could be fixed. There are other shortcuts built into crefdefaults.tex as well. It probably requires documentation, but it's just a prototype for now.

Good idea? Bad?

MATLAB Quick Reference Cards (and more)

UPDATE: I list an AMSTeX reference card below. There is also an AMSLaTeX reference card available at refcards.com.

This is meant to be a follow-up to the "TeX Reference Card (and others)" post.

I found a list of a bunch more quick reference cards, which include applications/packages like MATLAB, MATLAB toolboxes, Perl, MFC, MySQL, Linux, UNIX, Vi, Vim, Windows, AMSTeX, TeX, and a bunch more...

However, I was just looking for MATLAB quick reference cards. So, here are these (some of which did not come from the above site):
So, that's nice. I recommend one of the bottom two [i.e., 1, 2].

Tuesday, July 17, 2007

Using Skim with MATLAB

I found a hint for using TeXShop as a MATLAB previewer on OS X, primarily because plots look better in PDF and TeXShop auto-updates files from disk. This was a tip from back in 2005. Since then, MATLAB's OS X plotting has gotten a lot better. Additionally, Skim has been invented.

Because of the advances in MATLAB, this may not be a useful hint anymore, but give this a try sometime:
figure(1);
set(gcf, 'Visible', 'off');
plot(x, y);
print(gcf, '-dpdf', 'figure1.pdf');
system('open -a Skim figure1.pdf');
Now, I believe there's a way to do this without having to plot first. That is, I think there's a way to plot to PDF without first generating that figure.

What's cool about this is that any future updates of the PDF will cause Skim to update automatically. Therefore, Skim becomes your plot viewer. That might be nice, right?

Using Skim, PDFSync, and TeXShop

UPDATE 3: I have updated the script to support command-line options that will prevent TeXShop from doing things like refreshing text (and trashing your unsaved changes), activating (taking your focus away), and opening (possibly getting in front of your view). Try the -h option for details.

UPDATE 2: There is a related Skim revision that will make it easier to use AppleScript for PDFSync interfacing. This change will prevent having to make UNIX shell scripts that must be modified with chmod.

UPDATE 1: As you can see in the Skim revision history, future versions of Skim will include their "Application Support" directory (e.g., ~/Library/Application Support/Skim/) as well as a "Scripts" subdirectory in their path. When that occurs, scripts like the one below can be stored there and executed from Skim without specifying the full path name.

I know there are ways to change TeXShop's previewer; however, I don't know how to do them. Additionally, I don't use TeXShop, so I have little incentive to look those things up.

However, I do use Skim, which is compatible with pdfsync, and recently someone asked me how they could get Skim to call up TeXShop at a particular line (as someone would want to do when using pdfsync).

For that, I generated a texshop script that looks like this (an earlier version of this can be found on the Skim wiki):
fileName="$1"
lineNumber="$2"
gotoString=""

[ "${fileName:0:1}" == "/" ] || fileName="${PWD}/${fileName}"
[ "${lineNumber}" == "" ] || gotoString="goto line ${lineNumber}"

exec osascript \
-e "set texFile to POSIX file \"${fileName}\"" \
-e "tell application \"TeXShop\"" \
-e "activate" \
-e "open texFile" \
-e "tell front document" \
-e "refreshtext" \
-e "${gotoString}" \
-e "end tell" \
-e "end tell"
To use this script, follow these steps:
  1. Save that file as something (preferably in the PATH somewhere, but this is not necessary) like
    /usr/local/bin/texshop
    or anywhere you would like (e.g., /Users/username/bin/texshop). However, if you place it somewhere differently, be sure to update the red text in these instructions.

  2. Next, chmod it 0755, as in
    chmod 0755 /usr/local/bin/texshop
    This can be done from the Terminal.

  3. Finally, tell Skim's PDFSync preferences (under Preferences->LaTeX or Preferences->Sync depending on your Skim version) to use a "Custom" editor with
    Command: /usr/local/bin/texshop
    Arguments: "%file" %line
    Make sure you click AWAY (e.g., onto a different tab) from the PDFSync settings before you close the Preferences. Otherwise, one of your text boxes may not get saved.
After this is done, doing Shift+Command+CLICK in Skim on a location in the PDF will bring up the source in TeXShop located at the that generated that point in the PDF.

Note that if you have saved texshop somewhere in your PATH, then you should be able to drop the /usr/local/bin/ from the front of the Command: line.

Great 2-port USB KVM switch: IOGEAR GCS632U MiniView Micro USB Plus

A while ago I made a couple of posts about KVM switches [i.e., 1, 2]. In that case, I was searching for a PS/2 KVM switch that supported 5-button mice. Several KVM switches failed me, including a switch from Belkin that looked great on paper but was awful in practice. In the end, it was the cheapest switch that worked like a charm. Well, here's how things went this time.

  • Again, Belkin makes crap: Last week I went through virtually the same process with 2-port USB KVM switches. This time I needed a USB switch to go back and forth between my Apple PowerBook and my Dell Workstation (I'm spanning the PowerBook's second monitor onto the Windows machine). Because it looked to be the cheapest, I tried the Belkin F1DK102U 2-Port USB KVM Switch with Built-In Cabling first. It said it supported OS X and XP. Strangely, it also required software to be installed in order to use it. This should have been my first clue that I was wasting my time and money with this awful Belkin product. I don't remember the last time I was pleased with a Belkin product (I suppose I had some UPS's from them that weren't that bad). Despite being OS X compatible, booting with the product connected caused the PowerBook to crash pretty bad. It gave me that little black window of death on bootup. Again, because it required software in order to use, that made uninstalling it (while the monitor was still connected to it) was a pain. PLUS, when it was connected, it wasn't able to emulate my monitor and mouse and keyboard, and so Windows and OS X weren't convinced that I was using the monitor, mouse, and keyboard that I was using. Oh, and on TOP of that, one of its attached cables (you can see this in the picture) is only about a foot long, and it's the DEFAULT PORT! This was a lousy product.

  • IOGEAR is lovely as always: Luckily, I had to go back to the store for a different reason, and I noticed that they had four IOGEAR GCS632U MiniView Micro USB Plus 2-port KVM switches, and two of those switches were marked at a price CHEAPER than the Belkin piece of crap. I had someone check, and the correct price was the low price. So I took the Belkin back and got the IOGEAR instead. This switch said it was Mac compatible (Mac mini compatible, even). Heck, it even said it was SUN compatible! It also had ANALOG AUDIO support, which is kinda nice. Finally, right on the box it said, "USB sniffing technology allows complete USB mouse and keyboard emulation for error-free boot-up." This feature was one of the major things I LOVED about the old QVS PS/2 switch. Plus, I figured this meant that it would crash my PowerBook like the Belkin thing did. Both of its cables were the same length (6'), and it would choose a "default" port based on what was powered on. Oh, and did I mention it didn't require software?
The result? The IOGEAR GCS632U, the cheapest 2-port USB KVM switch that was available to me, worked EXACTLY as I wanted it to. It's beautiful. It's slick. I love it. I love IOGEAR.

NOTE: IOGEAR also has a PS/2 version of this switch that I'm guessing works as superbly as the QVS KVM-12CK (the PS/2 switch from the previous posts) that is still working great today.