Thursday, June 28, 2007

Preamble for Journal of Mathematical Biology

Update 5: The updated svglov2.clo and svglov3.clo are not needed if the preamble is used below (i.e., if the \RequirePackage{fix-cm} line is added before the documentclass line.

Update 4: See the section that redefines \autoref. Changed definition to support starred commands that are unlinked.

Update 3: See the section starting with the comment "%% Level 1 Subsections". It forces subsections to show up like sections in the PDF bookmarks; this is a (strange) JMB convention. In the comment I make some suggestions for improvements.

Update 2: See the small commented section "%%%% Table Support". If the LaTeX code is uncommented there, there is no need for the \noalign{\smallskip} stuff around \hline horizontal table rules. It uses the tabls package to do this.

Update 1: I've mirrored this content on my web page.

I'd like to combine some of the previous posts. I've been trying to fix and modernize some of the Springer LaTeX support files for the Journal of Mathematical Biology (JMB). I've come up with these...

  • svglov2.clo - document class option for svjour2.cls. I used fix-cm to get rid of some of the warnings about not being able to scale the Computer Modern fonts. This is not needed if the preamble below is used (i.e., with the fix-cm line before the documentclass line).

  • svglov3.clo - document class option for svjour3.cls. I used fix-cm to get rid of some of the warnings about not being able to scale the Computer Modern fonts. This is not needed if the preamble below is used (i.e., with the fix-cm line before the documentclass line).

  • spmpsci.bst - BiBTeX bibliography style file for JMB. The original version of this did not reverse the first and last name of the editors as required; I fixed that.

  • spmpscinat.bst - natbib compatible BiBTeX bibliography style file for JMB. Be sure to include natbib with numbers and sort&compress options.
I recommend using a preamble like this one...
%%%% Journal of Mathematical Biology (JMB) setup

% Allow Computer Modern fonts to be scaled (must be before svjour3)
\RequirePackage{fix-cm}

% Use running heads
\documentclass[runningheads]{svjour3}

% The journal's name
\journalname{Journal of Mathematical Biology}

% use Times fonts
\usepackage{mathptmx}

% flush right qed marks (Halmos square),
% e.g., at end of proof
\smartqed

% Use natbib for \citet, \citep, etc.
% (JMB: numbered citations that are sorted
% and compressed)
\usepackage[numbers,sort&compress]{natbib}
%\bibliographystyle{spmpsci}
\bibliographystyle{spmpscinat}

%%%% Some useful packages

% Allow for smarter labeling of enumerations
% and itemizations (consider using enumitem instead)
\usepackage{paralist}

% Provides \labelformat, which changes how \ref
% references look
\usepackage{varioref}

% Mathematical symbols, etc.
\usepackage{amssymb,amsfonts,amsmath}

%%%% Table Support

% UNCOMMENT THE FOLLOWING LINES TO GET RID OF
% \noalign{\smallskip} STUFF AROUND \hline's IN
% TABLES
%
% % The following three lines remove the need for
% % the \noalign{\smallskip} around the \hline's
% % in the _Journal of Mathematical Biology_ LaTeX
% % template
% \usepackage{tabls}
% \addtolength\extrarulesep{\smallskipamount}
% \addtolength\extrarulesep{1pt}

%%%% Graphics and Figure Support

% Use subfig for subfigures
\usepackage[nearskip=-3pt,captionskip=4pt,
listofformat=subsimple,
labelformat=simple]{subfig}

% Make sure subfigures have parentheses around
% them everywhere
\renewcommand\thesubfigure{(\alph{subfigure})}

% Use graphicx for including graphics
\usepackage{graphicx}

% When picture environments are used, use
% pict2e for better resolution and flexibility
\usepackage{pict2e}

%%%% Hyperlink and Autoreference Support

%% Level 1 Subsections
%
% JMB does this weird thing where all
% subsection-level PDF bookmarks are displayed as
% section-level bookmarks. Strangely, they do
% *NOT* turn on the ``bookmarksnumbered'' hyperref
% option. I think their articles would be MUCH more
% readable with all level-1 bookmarks if they were
% prefixed by their section number. I'm sure they'd
% argue that since the sections are linked within
% the document, this is not needed.
%
% (note: another option is to set tocdepth=2 and turn
% on the ``bookmarksopen'' hyperref option)
%
% Anyway, the following redefines \addcontents line
% to setup the bookmarks like JMB articles. Must do
% this after hyperref because it redefines
% \addcontentsline. Therefore, just use an
% AtBeginDocument.
%
\usepackage{ifthen}
\AtBeginDocument{%
\let\orgaddcontentsline\addcontentsline
\renewcommand{\addcontentsline}[3]{
\ifthenelse{\equal{#1}{toc}}
{\ifthenelse{\equal{#2}{subsection}}
{\orgaddcontentsline{#1}{section}{#3}}
{\orgaddcontentsline{#1}{#2}{#3}}}
{\orgaddcontentsline{#1}{#2}{#3}}}}

% Include hyperref for link support
% Include hyperref for link support
%\usepackage[dvipdfmx, % If need dvipdfmx
%\usepackage[dvips, % If need dvips
\usepackage[% % Fine in most cases
pdfpagelabels,hypertexnames=true,
plainpages=false,
naturalnames=false]{hyperref}

% Configure the hyperlink color
\usepackage{color}
\definecolor{darkblue}{rgb}{0,0.1,0.5}
\hypersetup{colorlinks,
linkcolor=darkblue,
anchorcolor=darkblue,
citecolor=darkblue}

% In the future, it would be nice to use the package
%
% cleveref
%
% Right now, it breaks svjour3 and svjour2, so we just
% have to use autoref and labelformat :(.

% Make sure \autoref puts parentheses around
% equations and enumeration items (similar to \eqref)
% NOTE: This allows us to use \ref instead of \eqref
\labelformat{equation}{\textup{(#1)}}
\labelformat{enumi}{\textup{(#1)}}

% Make sure equations are numbered by section
\numberwithin{equation}{section}

%% We need to redefine \autoref. We should use
%% abbreviations inside the sentence and full names
%% at the beginning of sentences. Additionally,
%% need to handle the plural cases.

% \Autoref is for the beginning of the sentence
\let\orgautoref\autoref
\providecommand{\Autoref}
{\def\equationautorefname{Equation}%
\def\figureautorefname{Figure}%
\def\subfigureautorefname{Figure}%
\def\sectionautorefname{Section}%
\def\subsectionautorefname{Section}%
\def\subsubsectionautorefname{Section}%
\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\sectionautorefname{Sections}%
\def\subsectionautorefname{Sections}%
\def\subsubsectionautorefname{Sections}%
\def\Itemautorefname{Items}%
\def\tableautorefname{Tables}%
\orgautoref}

% \autoref is used inside a sentence
% (this is a renew of the standard)
\renewcommand{\autoref}
{\def\equationautorefname{Eq.}%
\def\figureautorefname{Fig.}%
\def\subfigureautorefname{Fig.}%
\def\sectionautorefname{Sect.}%
\def\subsectionautorefname{Sect.}%
\def\subsubsectionautorefname{Sect.}%
\def\Itemautorefname{item}%
\def\tableautorefname{Table}%
\orgautoref}

% \autorefs is plural for inside a sentence
\providecommand{\autorefs}
{\def\equationautorefname{Eqs.}%
\def\figureautorefname{Figs.}%
\def\subfigureautorefname{Figs.}%
\def\sectionautorefname{Sects.}%
\def\subsectionautorefname{Sects.}%
\def\subsubsectionautorefname{Sects.}%
\def\Itemautorefname{items}%
\def\tableautorefname{Tables}%
\orgautoref}

This lets you do cool things like... (hyperlinks depicted in blue)

\ref{eq:1} produces linked "(1)"
\ref*{eq:1} produces unlinked "(1)"
\autoref{eq:1} produces linked "Eq. (1)"
\autoref*{eq:1} produces unlinked "Eq. (1)"
\Autoref{eq:1} produces linked "Equation (1)"
\autoref{sec:2} produces linked "Sect. 2.1"
\Autoref{sec:2} produces linked "Section 2.1"
\Autorefs{sec:1} and \ref{sec:2} produces linked "Sections 1 and 2.1"
\autorefs{sec:1} and \ref{sec:2} produces linked "Sects. 1 and 2.1"
\autoref{item:1} produces linked "item (i)"
\autorefs{item:1} and \ref{item:2} produces linked "items (i) and (ii)"
\citep{SK86} produces linked "[61]"
\citep[p.~41]{SK86} produces linked "[61, p. 41]"
\citep{Cha76,SK86} produces linked "[14, 61]"
\citep[e.g.,][]{SK86,Cha76} produces linked "[e.g., 14, 61]"
\citeauthor{SK86} produces linked "Stephens and Krebs"
\citet{SK86} produces linked "Stephens and Krebs [61]"

spmpscinat.bst: A natbib style file for Journal of Mathematical Biology (e.g., Springer journals)

UPDATE: I learned how to use custom-bib's makebst. I've updated the spmpscinat.bst file in a more proper way by using makebst. I also regenerated the spmpsci.bst file so it properly reverses editor names to match the JMB format. I will submit these to JMB and hopefully they'll use them. FYI, these were mostly generated from spmpscinat.dbj and spmpsci.dbj, respectively.

I was frustrated to find out that the Journal of Mathematical Biology (JMB) has been using some outdated LaTeX support files. In particular, they distribute a BiBTeX style file that has no support for natbib use (or anything similar, like apacite). This appears to be less of a problem with JMB and more of a problem with Springer in general (i.e., most of its journals). They actually expect people to type the names of the authors that they reference directly (either that or use references (e.g., [2]) as nouns, which is bad style even though it saves space)! Can you believe that?

Civilized people use a package like natbib to do something like \citet{SK86} on every textual citation, which will then generate "Stephens and Krebs (1986)" (in Harvard mode) or "Stephens and Krebs [61]" (in numerical mode). There are lots of good reasons to do this. For one, it prevents me from accidentally turning "Krebs" into "Krbes".

To deal with this, I took the abbrvnat.bst style file packaged with natbib and hacked its support into the spmpsci.bst file from Springer. The result is spmpscinat.bst, which seems to work as desired for most bibliography entries I have tried.

I don't have a lot of experience with working with BiBTeX support files, so I have a feeling that it would have been better to use custom-bib to generate a BiBTeX style file in the JMB format that would be compatible with natbib. I may do that later.

So basically, I reserve the right to update or changed spmpscinat.bst at any time and without any notice, so look out for updates.

Wednesday, June 27, 2007

paralist, varioref, and hyperref: a happy combination

Consider the following...
\usepackage{varioref}
\labelformat{equation}{\textup{(#1)}}
This uses the clever varioref package to alter how equation references are displayed. The reference will be displayed with parentheses around the reference and the whole thing will be forced upright (so things don't look stupid in an italicized theorem environment). For example, for an equation labeled "eq:1" and a figure labeled "fig:1", I get these results:
\ref{eq:1} produces "(1)"
\ref{fig:1} produces "1"
This removes the need for \eqref from amsmath; just use \ref instead. Now, let's add hyperref:
\usepackage{hyperref}
So,
\ref{eq:1} produces a linked "(1)"
\ref*{eq:1} produces an unlinked "(1)"
\ref{fig:1} produces a linked "1"
\ref*{fig:1} produces an unlinked "1"
\autoref{eq:1} produces a linked "Equation (1)"
\autoref*{eq:1} produces an unlinked "Equation (1)"
\autoref{fig:1} produces a linked "Figure 1"
\autoref*{fig:1} produces an unlinked "Figure 1"
So this gives us the equivalent of an unlinked "\eqref*" through \ref*. Now, let's add paralist...
\usepackage{paralist}
\labelformat{equation}{\textup{(#1)}}
and an enumerate environment with automatic bracketed lowercase roman numeral numbering...
\begin{enumerate}[(i)]
\item This is item one. \label{item:1}
\item This is item two. \label{item:2}
\end{enumerate}
The \label macros can be associated with any enumerate item, even without paralist. The package paralist allows us to easily customize the displayed labels (enumitem is nice alternative). So, we get an enumerated output like...
 (i) This is item one.
(ii) This is item two.
Now we get...
\ref{item:1} produces a linked "(i)"
\ref*{item:1} produces an unlinked "(i)"
\autoref{item:1} produces a linked "item (i)"
\autoref*{item:1} produces an unlinked "item (i)"

Isn't life sweet? Notice the similarities between these things and stuff provided by prettyref and typedref. I think hyperref's autoref with the flexibility provided by varioref is a nice way to replace those old goodies.

Now can someone convince the Journal of Mathematical Biology to start using a bibliography style compatible with natbib? That would truly make me happy...

Pine, PASSFILE, all-patch, and Thunderbird 2.0 IMAP keywords

Thunderbird 2.0 has been released! It's fast and finally supports an arbitrary number of custom IMAP keywords (IMAP keywords are similar to the labels used in GMail). I'm thrilled about this.

However, regardless of how wonderful Thunderbird gets, I will always keep PINE around (which has supported IMAP keywords for a long time).

When I build PINE for my systems, I usually pick up a few of the most popular patches as well. I never noticed that there was an all of the above patch that packages ALL of the most popular patches, new features, and bug fixes. I think this is pretty exciting too.

To build PINE with PASSFILE support (i.e., support for saving passwords to file), I recommend using the infinite ink instructions:
#!/bin/sh
./build clean
./build 'EXTRACFLAGS=-DPASSFILE=\".pine.pwd\"' osx
# ^^^
# platform
You can find a list of platforms in the doc/pine-ports file. Some common ones include (see the document for any special build instructions):
    BSD (original BSD 4.3 from U.C. Berkeley)
bsd BSD 4.3

BSDi
bs3 BSDi BSD/386 Version 3 and Version 4
bs2 BSDi BSD/386 Version 2
bsi BSDi BSD/386 Version 1

Cygwin
cyg Cygwin environment under Windows

HP-UX
hpx HP-UX 10.x
hxd HP-UX 10.x w/ DCE
ghp HP-UX 10.x using gcc
hpp HP-UX 8.x and 9.x
shp HP-UX 8.x and 9.x w/ TCB
gh9 HP-UX 8.x and 9.x using gcc

Linux
lnx Linux using crypt from the C library
lnp Linux using PAM
slx Linux using -lcrypt for crypt()
sl4 Linux using -lshadow for crypt()
sl5 Linux using shadow passwords
ldb Debian Linux
lmd Mandrakelinux
lrh RedHat Enterprise and RedHat 7.2 or later
lsu SuSE Linux

Macintosh
osx Macintosh OS X
ox2 Macintosh OS X 10.2 and earlier

NetBSD
neb NetBSD

OpenBSD
bso OpenBSD w/ shared-lib

QNX
nto Neutrino

SCO
sc5 SCO Open Server 5.x
go5 SCO Open Server 5.x using gcc
sco SCO Unix
gsc SCO Unix using gcc

Sun Solaris (Solaris 9 is the same as SunOS 5.9)
gs5 Sun Solaris >= 2.5 using gcc
soc Sun Solaris >= 8 using Sun C
gs4 Sun Solaris <= 2.4 using gcc
so5 Sun Solaris >= 2.5 (try soc or gs5)
so4 Sun Solaris <= 2.4

Sun SunOS (This is pre-Solaris SunOS)
sun Sun SunOS 4.1
ssn Sun SunOS 4.1 w/ shadow passwords
gsu SunOS 4.1 using gcc
s40 Sun SunOS 4.0

System V Release 4
sv4 System V Release 4

Windows
wnt Windows NT 3.51
Happy mailing!

Tuesday, June 26, 2007

Most PostScript to PDF LaTeX Stuff: pst-pdf

This is a follow-up to Bounding Boxes and EPS to PDF Conversion (in LaTeX).

There is also the LaTeX package pst-pdf, which uses the tool from the package ps4pdf.

This is a clever package with a more general approach to PS-to-PDF conversion than epstopdf. Rather than focusing only on the EPS graphics, it looks at the document as a whole. This means that it takes care of converting PSTricks (CTAN, TUG) graphics as well. It's a simple way of using pdflatex to produce a PDF while using constructs inside the document that are normally only allowed with latex (I assume that psfrag/psfragx will also work well with pst-pdf).

Of course, regardless of what you are producing, you should not be using epsfig anymore; use graphics and graphicx instead. In fact, epsfig isn't even supported anymore. There is a version included with the graphicx package for backwards compatibility.

For more information about including imported EPS files in LaTeX, see epslatex.pdf.

Related post:

Eating Tips

This year, a bunch of people have asked me for eating tips. This is because I went from 220+ pounds to 185 pounds in a couple of months. I didn't mean to lose that much weight--I just wanted to come up with an eating schedule that would save me money in graduate school.

I recently posted the following at 43things. I hope it will be helpful to someone. I shared these tips with a few people I know, and I found out that they recently lost a bunch of weight as well. I don't think there's anything unique about this. The basic idea is to eat smart. Just think about what you're eating, why you are eating it, and what you think it is going to do for you.
It's all about eating more often (you should never be hungry) and eating smart. I never expected to lose weight; I just wanted to get on an eating schedule to save money while in grad school. After a couple of months, I found myself almost 40 pounds lighter.

Some general rules:

* Cut out soda

* Cut out high-fructose corn syrup.

* Cut out PROCESSED sugars (fruits and veggies are fine; flavored juices are not)

* Frozen fruits are fine -- they'll keep better anyway; microwave them if you can't stand them being cold and hard.

* Cut out orange juice; try tomato juice and grapefruit juice instead (grapefruit juice will make you feel fuller longer)

* Cut out salad dressings except for vinigrettes (vinegars and grapefruit juices have a similar beneficial effect on keeping you full and lean)

* Avoid bread unless it is made with whole grains. The worst part of a McDonald's cheeseburger is the bun. Read the ingredients on most bread -- it is nearly impossible to find a bread without high fructose corn syrup on it. There are simply too many empty calories in most breads (an "empty calorie" is a calorie that does not make your stomach feel full because your body has not been adapted to process it; this is much of what's wrong with high fructose corn syrup).

* Consider quinoa (pronounced "keen-wah") as an alternative to rice. Lots of protein. Plus it's LEAFY (rather than grassy) so it has amino acids in it.

* Nuts (especially almonds) are wonderful. High protein. High fiber. Vegetable fats. However, each day try not to eat more than an Altoids-tin full of almonds and a tablespoon (or 2 MAYBE) of peanut butter. That's all you need.

* *NATURAL* peanut butters are wonderful. Unnatural ones are awful. Look at the ingredient list. Generic Meijer peanut butter is JUST peanuts and is CHEAP. This is ideal.

* Ground flaxseed is wonderful. Add it to everything. Omega-3's and all the benefits of nuts.

* Proteins stay in the stomach longer and so keep you fuller longer and keep your meals small. Fish stays in the stomach the longest, but you shouldn't eat more than 3 servings of fish a week because of all of the heavy metals found in fish.

* Soluable fibers stay in the stomach longer and, as an added bonus, pull cholesterol out of the blood. Insoluable fibers are also filling and keep you regular. RAMP UP fiber intake though--natural selection needs to act on your GI cultures so that you are setup to process all of that fiber. This can take up to two weeks if you aren't used to that much fiber.

* The longer things stay in the stomach, the more calories you burn digesting them. You actually work out your body by eating proteins.

* The colder things are in the stomach, the more calories you burn processing them.

* The heavier your food utensils are, the fuller you'll feel.

* GREEN TEA is wonderful. If you didn't like one green tea you tried, try another type. There are as many varieties of green tea as there are of black tea. Don't group them all together. Try taking green tea supplements. Try to drink multiple cups of tea a day (maybe 4 or 5).

* MAKE YOUR LUNCHES IN THE MORNING: This forces you to eat them rather than going out. Plus, the additional activity in the morning wakes you up and increases your calorie burn.

* Increase physical activity: take the steps, walk, hold your arms at a right angle when carrying groceries rather than letting your arms hang, be as inefficient as possible in your locomotion, add instability to your locomotion, do chair lifts, do pushups in the morning (one set of 30 is a good goal)

* TAKE LOTS OF VITAMIN D. There are some weight/health benefits of dairy, but they come with increased cancer risk (because human beings are only marginally well adapted for cow's milk). Vitamin D has so many benefits and everyone needs more of it. Among those benefits, it will reduce the cancer risk of dairy intake. I take 1000 IU's 3 times a day, plus I try to spend at least 15 minutes in the sunlight. You probably don't want more than 15,0000-20,000 IU, but that's hard to do.

* MEN: Get lots of blueberries and lycopene. Lycopene is in most red fruits and vegetables, so focus on red fruits and vegetables (watermelon, TOMATOES, etc.).

* Cinnamon can be added to most everything, and it probably should be. It has lots of benefits. Among those, it will decrease diabetes risk.

* SPICEY THINGS increase meatabolic activity. Make your food spicey. Remember that vinegar is a great thing to have in the diet, so try hot sauces that use vinegar.

* EAT WHEN HUNGRY. It's okay to eat often. Eat things that stay in your stomach longer (add grapefruit juice or vinegar before the meal to help increase this time). Just try to eat smart when you eat. Eat until full and STOP. Make sure you're actually hungry. Very often you're THIRSTY, so keep a bottle of watter nearby. **TEA** (like green tea) will do wonders in keeping you feeling full.

* COFFEE can be great (caffeine isn't necessarily bad). However, be sure you don't add much to it. Also consider skim milk options if you must have milk. Don't drink as much coffee as tea, but don't be afraid of coffee. It's much better than pop.


Some meal ideas from my schedule:

* Breakfast: **POST** Raisin Bran (Post's has no high-fructose corn syrup and has 8g of fiber, 4g soluable and 4g insoluable) with 2g ground flaxseed added. I also add frozen strawberries, cherries, blueberries, blackberries, and raspberries as well as 25g of protein powder (and as of recently 1 heaping tsp of fiber sure, which gives 5g of soluable fiber)

* Between Breakfast and Lunch 1: 1 fiber choice chewable tablet (2g soluable fiber) (this is recent; I don't like the sugar content of these though)

* Lunch 1 (around noon): Slim-Rite Ultimate (Kroger version of Slim-Fast Optima; Target has a cheaper version that is just as good) shake and a red delicious (produce #4015) apple (lots of soluable fiber in the apple keeps you full; if you need more, try a #4016 apple).

* Between Lunch 1 and Lunch 2: 1 fiber choice chewable tablet (2g soluable fiber) (this is recent; I don't like the sugar content of these though)

* Lunch 2 (around 3pm): 1 cup of Dannon Light and Fit yogurt (any flavor) mixed with 2g ground flaxseed and initially frozen (they melt during the day in the refrigerator) strawberries, cherries, blueberries, blackberries, and raspberries. I also add a handful of almonds. Recently I've added 1 heaping tsp of fiber sure as well.

* Dinner (around 6pm): Something hearty. Good protein. Lots of vegetables. Try to get 3 servings of fish per week.


I haven't figured out how to work exercise into my schedule yet. Optimally, exercise is great for the body. However, if you can just EAT better, you'll do wonders for yourself. (I don't mention it here, but I also focus on healthy nutrients that have nothing to do with weight loss directly--you should find out what nutrients are best for you and adust your own diet accordingly)

Bounding Boxes and EPS to PDF Conversion (in LaTeX)

Another development: More bounding box related issues are discussed in this CTT thread. It turns out that dvips -E basically guesses RANDOMLY at what the bounding box should be, and so its answers can be inconsistent. GhostScript (gs) has a bbox driver that circumscribes your EPS with a rectangle and uses the rectangular dimensions as the bounding box. The epstool command can use this GhostScript calculation to update your EPS. So you can imagine doing things like...
latex file.tex
dvips -E file.tex -o tmp.eps
epstool --bbox --copy --ouput file.eps tmp.eps
epstopdf file.eps
The epspdf script has similar functionality (when you are converting from EPS to PDF) and will be included in TeXLive 2008.

Related post: LaTeX generated figures: Using preview instead of pst-eps

Follow-up: See another interesting option (pst-pdf) in this follow-up.

Update: Another interesting option is purifyeps, which requires pstoedit and Perl. See below.

None of the following is too special. This is all well-known stuff. However, it's not the easiest to find with a Google search, so I'm going to post it here.

Pretty often, I have to generate an EPS file with MATLAB. That EPS figure will go into a LaTeX document. To generate a PDF document from my LaTeX source, I will probably use PDFLaTeX/PDFTeX. However, that means I need to convert that MATLAB EPS figure to PDF. Most EPS-to-PDF distillers I use will mess up the bounding box information and the result of the conversion will be a FULL PAGE PDF rather than the nice tiny EPS figure.

Keep this scenario in mind and consider these notes:
(*) ps2pdf command: To convert EPS to PDF and maintain the proper bounding box, try including the "EPSCrop" GhostScript (GS) option:
ps2pdf -dEPSCrop blah.eps blah.pdf
Without the -dEPSCrop option, I get the full-page PDF from a MATLAB EPS. However, with the -dEPSCrop option, things work fine.

(*) epstopdf command: ALTERNATIVELY, try this line instead:
epstopdf blah.eps
This works for me. If it doesn't, try this (on Windows with MiKTeX 2.6):
epstopdf --gsopt=-dEPSCrop blah.eps
That also works for me.

(*) epstopdf LaTeX package: You may be interested in the epstopdf package which comes with the oberdiek bundle. It should be included in your LaTeX distribution. If not, install the oberdiek bundle. You can find information (and download) about these here:
From that last link, you'll find this epstopdf usage (this will work for the graphics package as well):
\usepackage[pdftex]{graphicx}
\usepackage{epstopdf}
Then you can include graphics two different ways:
% Way 1: Includes blah.eps. Will ALWAYS generate 
% blah.pdf regardless of whether it already exists.
\includegraphics{blah.eps}

% Way 2: Includes blah.eps. If blah.pdf DOES NOT EXIST,
% it will automatically be generated.
\includegraphics{blah}
There are configuration options too. Consider the following:
% The default eps to pdf rule
\DeclareGraphicsRule{.eps}{pdf}{.pdf}{`epstopdf #1}

% Alternative eps to pdf rule
\DeclareGraphicsRule{.eps}{pdf}{.pdf}
{`ps2pdf -dEPSCrop #1}

% A rule for converting gif to png using ImageMagick
% NOTE: The placement of the % signs IS important
\DeclareGraphicsRule{.gif}{png}{.png}{%
`convert #1 `basename #1 .gif`.png%
}

% The same gif-to-png rule for Windows
% (i.e., without basename support)
\makeatletter
\DeclareGraphicsRule{.gif}{png}{.png}{%
`convert #1 \noexpand\Gin@base.png%
}
\makeatother
FINALLY, if you want to add .gif to the list of extensions that the package graphicx (or graphics package) searches if the file extension is not given in \includegraphics, you can either use the command \GraphicsExtensions OR doing something like:
\makeatletter
\g@addto@macro\Gin@extensions{,.gif}
\makeatother
Leaving the file extension off of the \includegraphics macro makes a lot of sense; however, remember that epstopdf will only be run the first time latex or pdflatex gets run. If you want it to convert all of your graphics every run, be sure to leave the extensions on.

(*) purifyeps command: There is also purifyeps, which requires pstoedit and Perl. Taken from purifyeps's CTAN page:
While pdfLaTeX has a number of nice features, its primary shortcoming relative to standard LaTeX+dvips is that it is unable to read ordinary Encapsulated PostScript (EPS) files, the most common graphics format in the LaTeX world. purifyeps converts EPS files into a "purified" form that can be read by *both* LaTeX+dvips and pdfLaTeX. The trick is that the standard LaTeX2e graphics packages can parse MetaPost-produced EPS directly. Hence, purifyeps need only convert an arbitrary EPS file into the same stylized format that MetaPost outputs.
I haven't actually played with this at all. I recommend reading purifyeps.pdf for more information about why you want a "purified" EPS rather than some other format. I assume that the bounding box problem shouldn't be an issue here, but I have no idea.

(*) pstoedit command:
MPS files can be used DIRECTLY by BOTH latex and pdflatex (pdflatex does MPS-to-PDF conversion on-the-fly). You can easily convert EPS files to MPS files yourself as long as you have psttoedit (download and install it from the pstoedit page). Take a look at section 5.4 (MetaPost) of epslatex.pdf for information on that. From the instructions there:
pstoedit -f mpost graphic.eps graphic.mp
mpost graphic.mp
rename graphic.1 graphic.mps
That is, run psttoedit to convert to MP and then use mpost to create the MPS from the MP. Simple, huh? Now, does it fix the bounding box problem? As with the last bullet, I have no idea. Maybe someday I'll try this.

Hopefully some of that will be useful to someone; it will at least be a good reference for me. :)

Saturday, June 23, 2007

A LaTeX Bulletin Board

Every once in a while I get an urge to create a topic blog. Those blogs receive the most traffic and probably do the most practical good in the world, right? I have trouble coming up with a topic though... If I had to chose one, I would probably make a LaTeX blog. Certainly I don't have the background in TeX to be a TeXpert, but I do pretty well among my peers with my LaTeX.

Well, I'm not ready for that yet. However, I just found a LaTeX bulletin board that I think might be more useful than comp.text.tex (a USENET newsgroup) for the young LaTeX user.

http://www.latex-community.org/

I don't know how long that's been around. Give it a look if you need some LaTeX help. Search through the archives for some useful tips and solutions.

Thursday, June 21, 2007

authorindex bug fix on Windows (API error and PATH separator)

This is from a USENET news thread. I repost it here so that it gets indexed by more search engines.
This is a summary of the bug and resolution listed in MiKTeX bug #1739147:

This bug is not limited to MiKTeX. It is a general authorindex problem that can occur on any Windows machine.


When authorindex runs on a NETWORK drive (and other times?) this error occurs:

=====
bibtex: Windows API error 161: The specified path is invalid.
BibTeX error. Aborting leaving all temporary files _autidx_.*
=====

This error is a Windows specific problem in the "authorindex" Perl script. The resolution, by Christian Schenk:

=====
Date: 2007-06-21 13:26
Sender: csc (Christian Schenk)
Logged In: YES
user_id=67066
Originator: NO

Thank you. The bug is in the authorindex.pl script on lines 215 and 276:
the Unix path separator (:) is used when the environment variable
BSTINPIUTS/BIBINPUTS is set. This does not work under Windows. Please
replace ".:" with ".;" on both lines.
=====

In MiKTeX, this script is located at:

\Program Files\MiKTeX 2.6\scripts\perl\authorindex\authorindex.pl


Eventually, authorindex will need to be modified so that ";" is used as the PATH separator for Windows and ":" in UNIX. Meanwhile, those getting the error above should manually make this change.

--Ted

Tuesday, June 19, 2007

Response to "NPR Wedding Music"

A response to NPR Wedding Music, sent to me via e-mail, reposted anonymously here:
I was in town yesterday shipping a package and saw that my mom and my sister were at the UPS store at the same time. I walk up to my mom's car only to find her crying. Turns out she has been reading the "Martha Stewart Book of Weddings." She said she was fine reading the chapter on wedding cakes (she likes cake), but once she got to the one about wedding songs, she lost it (in a good way)....

NPR Wedding Music

Stephen Thompson is one of the music experts on NPR. I like him a lot. One day I sent NPR a note saying that I liked him a lot, and he sent me his "Best of" CD's for 2003, 2004, and 2005. Evidently he was having a rough move to DC away from his own midwestern family, and it was nice to hear the good words.

Anyway, today's piece:

Wedding Day Blues: In Search of the Perfect Mix CD by Stephen Thompson

He was asked to put together a mix CD for his niece's wedding. After a lot of deliberation and realization that there are really few happy songs about marriage, he came up with:
1. Clem Snide, "Forever, Now and Then"
2. Old 97's, "Question"
3. Josh Rouse, "Nothing Gives Me Pleasure"
4. Death Cab for Cutie, "Passenger Seat"
5. Jimmy Scott, "When Did You Leave Heaven?"
6. The Lemonheads, "Into Your Arms"
7. Ron Sexsmith, "Moonlight Becomes You"
8. Nick Drake, "From the Morning"
9. Norah Jones, "Come Away with Me"
10. Sade, "By Your Side"
11. Matthew Sweet, "I've Been Waiting"
12. Radney Foster & Abra Moore, "I'm In"
13. Neil Young, "Harvest Moon"
14. Chet Baker, "Embraceable You"
15. Iron & Wine, "Ab's Song"
16. Low, "The Plan"
17. Johnny Cash & June Carter Cash, "As Long As the Grass Shall Grow"
18. Clem Snide, "Find Love"
I recommend actually reading the article. The text sounds like something straight out of the mouth of a grown-up version of one of the characters in High Fidelity (book, movie, soundtrack). Additionally, you can listen to at least six of the songs from the mix directly from the story.

For more NPR music stuff, see:

NPR : Music

"Song of the Day" is a particularly good segment to catch each day (contributed to by a number of NPR music fans):

NPR : Song of the Day

Of course, there are NPR RSS Feeds for all of these and more.

Friday, June 15, 2007

Thesis, Defense, and Source Available

I packaged it all up, documented it, and made it available on-line. Hopefully having a whole LaTeX thesis source on-line will be helpful to someone. This thesis has multiple indices (people and topic), glossaries, and all sorts of PDF hyperlinking and referencing. It uses packages like authorindex, hyperref, index, and natbib. I hope it serves as a good example for putting together a digital book.

Archives are also stored in the source directory. The defense presentation is best viewed in latest Adobe Acrobat as it makes use of a number of very modern PDF features. The presentation is built with LaTeX using powerdot.

The source directory also includes a modified osudissert96-mods.sty and the standard osudissert96.cls file, which is part of the osudissert96 (info, source) package. The modifications:

  • Force title to uppercase to match updated submission rules.

  • Additional hyperref support: If phantomsection defined, will add phantomsection in dedication page.

  • Additional hyperref support: alphanumeric page numbers on title page to prevent page name conflicts.
Just so everyone knows, the two acceptable graduate unit names for the OSU ECE department are

  • Graduate Program in Electrical & Computer Engineering

  • Electrical & Computer Engineering Graduate Program

Wednesday, June 13, 2007

German Condom Dispenser

Men's Health suggests that guys get this imported German condom dispenser to make them ready to hop into bed at any time without having condoms sitting out in plain view. The idea is that this will make the guy seem less creepy... but having a condom DISPENSER makes me think the guy would be a little MORE creepy. . .

They also suggest the Durex vibrating ring 6-pack.

Thursday, June 07, 2007

Wireless Power Transmission

Farewell, wires? Power beamed through air
‘WiTricity’ can light up lamps and laptops; system touted as safe, efficient

Power cables and even batteries might become a thing of the past using a new technique that can transmit power wirelessly to cell phones, laptops, MP3 players, household robots and other electronics.

Scientists lit a 60-watt light bulb from a power source 7 feet (2 meters) away with their new technique, with no physical connection between the source and the appliance. The researchers have dubbed their concept "WiTricity," as in "wireless electricity."

Soljacic and his colleagues devised WiTricity based off the notion of resonance. One well-known example of resonance can be seen when an opera singer hits the right note to cause a champagne glass to resonate and shatter. Two objects resonating at the same frequency tend to exchange energy efficiently, while interacting weakly with objects not resonating at the same frequency.

Instead of sound, the MIT physicists focused on magnetic fields. Most common materials interact only very weakly with magnetic fields, so little power would get wasted on unintended targets. "The fact that magnetic fields interact so weakly with biological organisms is also important for safety considerations," said Soljacic's colleague, MIT physicist Andre Kurs.

Saturday, June 02, 2007

Overheard at the coffee shop...

Walking into the coffee shop, I see three empty tables by the door next to a table with a young man and woman chatting.
Woman: Okay, enough about my quirks. This isn't fair.
Man: Oh, you want to hear about my quirks?
Both: (laughter)

I realized why no one was sitting at these three tables even though the rest of the shop was nearly packed; these two were on a first date, and it would just be awkward to be in earshot of it.

Why is first date banter so predictable? More importantly, why are people going into first dates so worried about what is going to happen? I suppose there's still a lot that is unpredictable... After all, the typical first date banter could *NOT* happen, and that might be pretty scarey if you expected the standard stuff.

Anyway, it was kinda fun.