Thursday, December 25, 2008

BibTeX Bibliography Style File (BST) for Engineering Applications of Artificial Intelligence (EAAI)

The Elsevier journal Engineering Applications of Artificial Intelligence suggests that authors use the elsart-harv.bst BibTeX bibliography style (BST) file to match its Harvard-style author-year reference format. However, elsart-harv.bst does not match the conventions used in EAAI proofs. In particular,
  • EAAI proofs use "Thesis" (instead of "thesis")
  • EAAI proofs surround the volume of an "in proceedings" entry with commas (instead of periods)
  • EAAI proofs use "vol." (instead of "Vol.")
  • EAAI proofs don't put any space between abbreviated parts of author names (but they do keep the hyphens in hyphenated abbreviations)
So I modified elsart-harv.bst to match EAAI conventions. My modified form is: To use it, just download it, place it in the same directory as your compuscript, and change your
\bibliographystyle{elsart-harv}
line to
\bibliographystyle{elsart-harv-EAAI}
Of course, elsart-harv-EAAI.bst is still natbib compatible.

[ NOTE: More-advanced users may prefer my elsart-harv-EAAI.patch. ]

Tuesday, December 23, 2008

Our 2008 solstice photoset on Flickr

Check out our Solstice 2008 photoset on Flickr. There are a lot of nice shots of Fritz:
Isn't Fritz cute?
Including a video or two, like this one:
That's one cute dog.

Thursday, December 11, 2008

Making MacVim work with Vimperator's external editor feature

Because I'm a vim user, it's naturally for me to use vimperator on top of Firefox.

Today I posted a tip on vimperator.org that helps me use Vimperator on my MacOS system. I'm reposting that tip here.

To make a long story short, try an editor setting like
:set editor='bash -lc "mvim -f \$*" mvim '
or (if you prefer gvim)
:set editor='bash -lc "gvim -f \$*" gvim '
Then you should be able to hit CNTRL+I to launch an external editor for textareas. There are simpler solutions and explanations below.



Shelling out to external commands is hairier in OS X than it is on other platforms.

In my case, I use MacVim, which includes a script mvim that can be called as
mvim -f ...
so that the script will wait for the GUI to exit before it exits. This functionality is identical to the gvim found with other Vim distributions (including older Vim distros for OS X).

My mvim script is in /usr/local/bin. Unfortunately, the PATH environment variable that sits behind user processes has to be set in an special ~/.MacOSX/environment.plist file, and the default PATH does not include /usr/local/bin. If you don't believe me, try
:!env
As you can see, those environment variables are very different from the ones you'd expect in a "login shell." You could go add an appropriate environment.plist file to match your login shell, but then you'll have to keep it up-to-date after every change to your shell profile. As a consequence, it's probably a good idea to
:set shcf='-lc'
Then you'll notice that :!env gives you more expected results. However, Vimperator won't run the editor unless it can find it in what Firefox thinks is the PATH, and so shcf won't help you.

A simple solution is to
:set editor='/usr/local/bin/mvim -f'
For most people, this solution will be perfect. However, some will notice that their favorite utilities (e.g., /opt/local/bin/par or /sw/bin/aspell) will not be accessible in the editor (unless the environment.plist file is modified).

So the final solution is to use bash as your external editor, and have it operate as a login shell that calls your editor of choice.
:set editor='bash -lc "mvim -f \$*" mvim '
Here, bash calls mvim and passes "mvim" as $0 and everything following bash as $1, $2, and so on...

Make Vimperator's "Y"ank behave like Edit-Copy

Because I'm a vim user, it's natural for me to use vimperator on top of Firefox.

Today I posted a tip on vimperator.org that is derived from a suggestion someone else made on the vimperator mailing list. I'm reposting that tip here.

Vimperator has no choice but to copy selected text using the functions provided to JavaScript by Firefox. Unfortunately, these functions sometimes do not provide the expected behavior for certain types of lists, PRE environments, etc.

To make sure that "Y"anking results in the same thing as using Edit->Copy, add the following to your .vimperatorrc:
js <<EOF
mappings.addUserMap([modes.NORMAL], ["Y"],
"Yank the currently selected text",
function () {
buffer.getCurrentWord();
events.feedkeys("<C-v>" +
(/^Mac/.test(navigator.platform) ?
"<M-c>"
: "<C-c>"), true);
setTimeout( function () {
liberator.echo("Yanked "
+ util.readFromClipboard(),
commandline.FORCE_SINGLELINE);
}, 20 );
});
EOF
The code should work well on all platforms (even the Mac, with its "M" key). If it isn't working perfect for you, increase that final "20" until the behavior works how you'd like it.

Monday, December 08, 2008

My college roomate interviewed on Science Friday

My college roomate (George McWilliams) of SWRI was interviewed on NPR's Science Friday:
I'm a little jealous.

Thursday, October 16, 2008

Fixing bug in hyperref's autoref: amsmath-type equations under items get "item" label

Earlier this year, in a comp.text.tex posting, I discussed a bug I found in hyperref. That bug was then fixed in hyperref 6.77a, but there are still plenty of old packages hanging around that have this bug (for example, the hyperref from TeXLive 2007 on my system that I still haven't upgraded to TeXLive 2008).

The problem happens when
  • amsmath (or mathtools) is loaded.
  • An equation (or any other type of displayed-math environment) environment with labels occurs INSIDE an enumerated item.
  • You try to use \autoref to generate a reference to one of those equation labels later.
The \autoref macro will not properly return an "Equation" label (e.g., "Equation 1"). Instead, it will return an "item" label (e.g., "item 1").

To fix this problem, I use these lines of code just after I load hyperref in my preamble:
\makeatletter
\newcommand{\AMShreffix}[1]{%
    \expandafter\let\csname old#1\expandafter\endcsname%
        \csname #1\endcsname%
    \expandafter\renewcommand\csname #1\endcsname{%
        \@hyper@itemfalse\csname old#1\endcsname}}
\makeatother
\AMShreffix{equation}
\AMShreffix{align}
\AMShreffix{gather}
The \AMShreffix (i.e., AMS-href-fix) macro "fixes" the displayed-math environment that you pass it. This example fixes equation, align, and gather. If you want to fix alignat too, add a \AMShreffix{alignat} at the end of those lines. Make similar changes for your other displayed-math environments (e.g., flalign and multline too).

That fix changes all of the improper "item" labels back into proper "Equation" labels.

Monday, October 06, 2008

Big bug in the bathroom

A very large bug was spotted in the men's restroom...
Check out how huge those mandibles are! That thing could take out an eyeball!
For scale, I got this shot of it next to my shoe. The bug is about an inch long.
I didn't step on the bug, but after I noticed it, someone else did. That didn't kill the bug, but it made it less mobile. I couldn't get a shot of it near my shoe when it was more mobile because it kept walking toward my shoe, and I was afraid it would eat through my shoe and eventually eat through me...

Officemate's bee research on NPR

The graduate school research of my officemate (Kevin Schultz) was featured on NPR All Things Considered on Saturday during the "Science out of the Box" segment:

"Bees Follow Their Leaders"
When a swarm of bees takes flight, it can form a cloud as big as a school bus. But who's driving? And how do they know which way to go? Professor Thomas Seeley of Cornell University talks about how swarms of honeybees decide who's at the wheel and who's a backseat flier.
The audio story is streamable from the NPR link.

Professor Passino is our shared adviser, but my research has nothing to do with bee swarms. :) Professor Seeley is a collaborator of Passino/Schultz; he's from Cornell.

Saturday, October 04, 2008

Terra-Fi/Tera-Fi was my idea!

Someday they'll come out with terabit/s wireless networking (similar to 802.11... maybe 802.11t or something), and they'll need a name for it. It came to me this week that a great name would be "TeraFi" (or "TerraFi" or "Tera-Fi" or a similar spelling). That is, combine "terabit" and "wi-fi" to make a word that sounds like "terrify."

So that's my idea.

I wanted to put it out there before someone else did.

Tera-Fi. It's so fast it's scary.

Monday, September 29, 2008

My Brother Kenny on YouTube

A YouTube video of my brother Kenny and his family is now available. It is an interview segment with them for the MDA telethon held on Labor Day. My brother has ALS, which is also known as "Lou Gehrig's disease."

The MDA is one of many organizations fighting this disease, and yet the general public knows very little about it and researchers are having a hard time getting positive results from animal models to perform equally as well in human tests.

PLEASE help support my brother and ALS research in general by donating to my d'Feet ALS walk page.

Friday, September 26, 2008

Ben Folds and Regina Spektor together

Today's NPR Song of the Day: Ben Folds: Cynicism Meets Sweetness
  • Song: "You Don't Know Me"
  • Artist: Ben Folds (featuring Regina Spektor)
  • CD: Way to Normal
  • Genre: Pop-Rock
It's a good track. It's funny. It's witty. It's catchy. Oh, and its got some bitter realism mixed in there. Speaking of mixing, it's interesting combining Spektor and Folds. You can stream the track at the NPR page. The music video is embedded below...
The explicit lyrics go something like... (where Spektor's lyrics are in parentheses)
I wanna ask you —
Do you ever sit and wonder,
It's so strange
That we could be together for
So long, and never know, never care
What goes on in the other one's head?

Things I've felt but I've never said
You said things that I never said
So I'll say something that I should have said long ago:

(You don't know me)
You don't know me at all
(You don't know me)
You don't know me at all (at all)

You could have just propped me up on the table like a mannequin
Or a cardboard stand-up and paint me (paint me)
Any face that you wanted me
To be seen.
We're
Damned by the existential moment where
We saw the couple in the coma and
It was we were the cliché,
But we carried on anyway.

So, sure, I could just close my eyes.
Yeah, sure, trace and memorize,
But can you go back once you know

(You don't know me)
You don't know me at all
(You don't know me)
You don't know me at all (at all)

(You don't know me)
You don't know me at all
(You don't know me)
You don't know me

If I'm the person that you think I am (Ah ah ahh)
Clueless chump you seem to think I am (Ah ah ahhh)
So easily led astray,
An errant dog who occasionally escapes and needs a shorter leash, then
Why the fuck would you want me back?!

Maybe it's because

(You don't know me at all)

Ahhh ah
Ahhh ah

(You don't know me,
you don't know me.)

Ahhh ah
Ahhh ah

So, what I'm trying to say is
What (What?)
I'm trying to tell you
It's not gonna come out like I wanna say it cause I know you'll only change it.
(Say it.)

(You don't know me)
You don't know me at all
(You don't know me)
You don't know me at all (at all)

(You don't know me)
You don't know me at all
(You don't know me)
You don't know me at all (at all)

What?

(Mmmm, ohh oh
Ah ah ah ah ah
Aha ah ah ah
Ah-ah-ah-ah-ah
Oh-oh-oh-oh-oh
Aha ah
Ah ah
Ah-ah-ah-ah-ah-ah-ah-ah-ah
Oh-oh-oh-oh oh ohh)
What?

Tuesday, September 23, 2008

Fixing natbib: Adding tie between author and citation

Something that bugs me about natbib is that \citet puts a formal SPACE between the authors and the citation list, and so LaTeX like...
. . . as discussed by \citet{SK86}.
that shows up near the end of a typeset line can turn into
as discussed by Stephens and Krebs
[1].
Not only does this put a number at the beginning of a line, which is a typography no-no when you aren't starting a numerical item in a list, but it separates the citation list from its neighbors. If natbib would just us a TIE (~ in TeX) instead, then the "Krebs" in the example above would never get separated from the "[1]."

The best solution is to fix natbib so that this character is configurable. That would really help when using superscript references because you could get rid of the character all together (right now superscripts get a space before them, and that looks a little silly (especially when superscripts show up on the next line!)). However, that could take a while to get fixed (CTAN isn't quite SourceForge)... So I put together the following fix, which should work OK for \citet, \citet*, \Citet, and \Citet* regardless of how many optional arguments (0, 1, or 2) are present.

(note: the \makeatletter and \makeatother commands are not needed if these lines are put into a .sty file or in a natbib.cfg file (in the same directory as your TeX document source).
% Unfortunately, natbib does not TIE textual 
% references to their citations. So authors
% sometimes get separated from citations when
% they come at the end of the line. The following
% lines attempt to fix this problem.
%
% The lines below do the equivalent of . . .
%
% \renewcommand\citet[1]%
% {\citeauthor{#1}~\citep{#1}}
%
% but they handle the star and capitalization and
% optional argument cases too.
%
% (the \makeatletter and \makeatother are not needed if
% these lines are put into a .sty file or in a natbib.cfg
% file)
\makeatletter
%
%%% These lines test for star and number of arguments
%%% and call the workhorses below
%
% Test for star (mid-sentence and start-sentence forms)
\def\citet{\@ifstar{\citetstar}{\citetnostar}}
\def\Citet{\@ifstar{\Citetstar}{\Citetnostar}}
%
% No star found. Now test for argument count.
\def\citetnostar%
{\@ifnextchar[{\squarecitet}{\simplecitet}}
\def\squarecitet[#1]%
{\@ifnextchar[{\twocitet[#1]}{\onecitet[#1]}}
\def\Citetnostar%
{\@ifnextchar[{\squareCitet}{\simpleCitet}}
\def\squareCitet[#1]%
{\@ifnextchar[{\twoCitet[#1]}{\oneCitet[#1]}}
%
% Star found. Now test for argument count.
\def\citetstar%
{\@ifnextchar[{\squarecitetstar}{\simplecitetstar}}
\def\squarecitetstar[#1]%
{\@ifnextchar[{\twocitetstar[#1]}{\onecitetstar[#1]}}
\def\Citetstar%
{\@ifnextchar[{\squareCitetstar}{\simpleCitetstar}}
\def\squareCitetstar[#1]%
{\@ifnextchar[{\twoCitetstar[#1]}{\oneCitetstar[#1]}}
%
\makeatother
%
%%% The following actually do the \cite work
%
% The \citet cases (no arg, one arg, and two args)
\def\simplecitet#1%
{\citeauthor{#1}~\citep{#1}}
\def\onecitet[#1]#2%
{\citeauthor{#2}~\citep[#1]{#2}}
\def\twocitet[#1][#2]#3%
{\citeauthor{#3}~\citep[#1][#2]{#3}}
%
% The \citet* cases (no arg, one arg, and two args)
\def\simplecitetstar#1%
{\citeauthor*{#1}~\citep{#1}}
\def\onecitetstar[#1]#2%
{\citeauthor*{#2}~\citep[#1]{#2}}
\def\twocitetstar[#1][#2]#3%
{\citeauthor*{#3}~\citep[#1][#2]{#3}}
%
% The \Citet cases (no arg, one arg, and two args)
\def\simpleCitet#1%
{\Citeauthor{#1}~\citep{#1}}
\def\oneCitet[#1]#2%
{\Citeauthor{#2}~\citep[#1]{#2}}
\def\twoCitet[#1][#2]#3%
{\Citeauthor{#3}~\citep[#1][#2]{#3}}
%
% The \Citet* cases (no arg, one arg, and two args)
\def\simpleCitetstar#1%
{\Citeauthor*{#1}~\citep{#1}}
\def\oneCitetstar[#1]#2%
{\Citeauthor*{#2}~\citep[#1]{#2}}
\def\twoCitetstar[#1][#2]#3%
{\Citeauthor*{#3}~\citep[#1][#2]{#3}}
Even if this problem gets fixed within natbib, it still might serve as a good example of how to deal with TWO or more optional arguments in macros...

UPDATE: For author-year citations (i.e., "Harvard style citations"), you must replace the \citep with \citeyearpar. That is, replace the final section of the code above with this section:
%%% The following actually do the \cite work
%
% The \citet cases (no arg, one arg, and two args)
\def\simplecitet#1%
{\citeauthor{#1}~\citeyearpar{#1}}
\def\onecitet[#1]#2%
{\citeauthor{#2}~\citeyearpar[#1]{#2}}
\def\twocitet[#1][#2]#3%
{\citeauthor{#3}~\citeyearpar[#1][#2]{#3}}
%
% The \citet* cases (no arg, one arg, and two args)
\def\simplecitetstar#1%
{\citeauthor*{#1}~\citeyearpar{#1}}
\def\onecitetstar[#1]#2%
{\citeauthor*{#2}~\citeyearpar[#1]{#2}}
\def\twocitetstar[#1][#2]#3%
{\citeauthor*{#3}~\citeyearpar[#1][#2]{#3}}
%
% The \Citet cases (no arg, one arg, and two args)
\def\simpleCitet#1%
{\Citeauthor{#1}~\citeyearpar{#1}}
\def\oneCitet[#1]#2%
{\Citeauthor{#2}~\citeyearpar[#1]{#2}}
\def\twoCitet[#1][#2]#3%
{\Citeauthor{#3}~\citeyearpar[#1][#2]{#3}}
%
% The \Citet* cases (no arg, one arg, and two args)
\def\simpleCitetstar#1%
{\Citeauthor*{#1}~\citeyearpar{#1}}
\def\oneCitetstar[#1]#2%
{\Citeauthor*{#2}~\citeyearpar[#1]{#2}}
\def\twoCitetstar[#1][#2]#3%
{\Citeauthor*{#3}~\citeyearpar[#1][#2]{#3}}
Those lines seem to work for me.

Friday, September 19, 2008

Pretty analog docs

Lately, I've noticed more hits on my website for documents that I put together for some classes that I've taught. So I decided to collect all the substantial ones and list them in one place. I figured I'd do the same here...

My attempt at a "public domain" license declaration

Many lawyers will tell you that it is impossible for an author to explicitly release a new work into the public domain, but many authors would like to do such a thing. Normally the advice is to acknowledge retaining the copyright and then explicitly grant permission for public use of the work for every possible use.

So here's my attempt (taken from something I had to put into the public domain today:
Copyright (c) YEARS by AUTHORS
No rights reserved. All rights granted.

This work is licensed to the public domain. All persons
are permitted to use, copy, modify, distribute, and
publicly perform or display this work without restriction.

To view a copy of this license, visit
http://creativecommons.org/licenses/publicdomain/
or send a letter to Creative Commons, 171 Second Street,
Suite 300, San Francisco, California, 94105, USA.
I think much of that is redundant. You probably don't need that second half linking to CC's explanation of public domain. You probably don't need the "No rights reserved" and "All rights granted" crap either. Anyway, for the moment, I don't think they're doing any harm.

Yes, I realize I could just ask the civil law attorney in my family who handles this type of thing daily, but I'm afraid he'd just think I was being silly.

Thursday, September 18, 2008

"Six dollar footlong" just doesn't roll off the tongue the same way...

I was leaving The Mall at Tuttle Crossing the other day, and something at the food court caught my eye...
Tuttle Mall Subway
Don't see it? Let's zoom in a bit...
Six dollar footlong
WTF? Is that a "6" over top of the five-fingered hand that usually is holding a "5"?

It seems like they forgot to put up the right hand that's flipping you the sixth finger...

Monday, September 08, 2008

Blogger Labels: No more than 20, unless there are more than 20.

I think it's dumb that the "Labels for this post:" line at the bottom of this bottom of this editor only lets me enter in 20 labels, but if I go into the "Edit Posts" and check this post, I can add as many existing labels as I want one by one.

So I have posts that have more than 20 labels. When I EDIT them, I have to DELETE labels in order to SAVE, and then I have to re-add them using the "Edit Posts" manager.

It's also dumb that Blogger prompts me for label completion and then picks the first one in this list when I hit "," regardless of whether I actually entered the list. So when I type "tex," in the "Labels for this post", it changes it to "AUC TeX," because that label is higher in the list but appears to match. (yes, I can scroll down to "tex" and select it... but what if it DIDN'T EXIST? What if I wanted a new label? In that case I have to let it complete and then go back and modify what it entered WITHOUT hitting comma again and causing another auto-completion.

I wonder when web development started going so far down hill. I'm sure "certification" has something to do with it. You can promote people based on their "certification" and not on their merit... I guess. I suppose that's a subject for another post.

Visit TiVo.com to manage your account!

UPDATE 2: After calling back, waiting on hold, being transferred, and waiting on hold, I was given a Tivo Case number and told that this case was escalated to an account specialist. I was told that rarely do account specialists actually call the customer. Rather than expecting a call back, I should check my account over and over again for the next three to five business days. If I don't notice a change after five days, I should call back with my Tivo Case number handy.

There was an automated survey after I was finished with the representative. As you can imagine, I dialed "not satisfied" to every question.
UPDATE: TiVo's hold just hung up on me!!!
I'm on hold with TiVo customer service right now. When TiVo answered my call, I was told multiple times to visit TiVo.com to get a quicker response to my question. On hold, I'm told over and over to visit TiVo.com to manage my account. These reminders to visit TiVo.com are making me REALLY angry... The reason I'm calling TiVo is because of these messages from TiVo.com's account management:
Sorry, you are not the billing contact for this DVR, so you cannot view billing history for this DVR.
We're sorry, you are not the billing contact for this TiVo Service Number, so you cannot change the credit card. If you feel you have received this message in error, please call TiVo Customer Support 1-877-367-8486.
I'm the only person on the account, which makes a snarky message like this even more frustrating.

The support people don't know what's going on. Everyone's confused, and I'm stuck on the phone... not doing work...

It's going to be a good day!

How much is good coffee worth?

Today I decided to try getting McDonald's coffee on the way to work. The small black coffee that I purchased:
  • was $1.00 (I thought it would be $0.99 or less)
  • was burnt
  • was just slightly above tepid
  • had room for cream (even though I asked for no room).
  • had a fancy plastic lid that forced the coffee up into my lip rather than my mouth, which would have hurt me if the coffee was actually hot
Additionally, I had to wait in a line of cars to get said coffee.

If I had gone to Starbucks or Brennan's or one of many other coffee places that the media refers to as selling "$4 coffee," I could have had the same drink, but
  • It would have been $1.25.
  • It would have been fresh and tasty.
  • It would have been hot.
  • It would have been filled to the brim.
If the McD's coffee was $0.50, then I might have been able to overlook this... but for only $0.25 more, I think the "designer" coffee is much better.

You have to work HARD to buy $4 coffee at a place like Starbucks. Usually your drink has to involve milk and froth and lots of other ingredients that make it stop being a "coffee." That's why those drinks are NOT called "coffees." A coffee can be served to you in a few seconds, while a more exotic drink takes time to prepare. That's why those other drinks cost more.

So good coffee is a quarter more than bad coffee. Now that I know the value of good coffee, I hope I won't make the mistake of buying bad coffee again.

Saturday, September 06, 2008

Walk because you CAN

QUICK SUMMARY: SUPPORT ME in my walk to d'Feet ALS!

Later this month, I'll be walking in my 3rd Walk to d'Feet ALS. My brother Kenny has ALS (Lou Gehrig's disease). It's a fatal disease that few people know much about, and researchers are having a hard time even slowing its progression. Stephen Hawking has a mild form of ALS that has progressed slowly enough for him to live a relatively long life. The disease has put him in a wheelchair and taken away nearly all control of all of his muscles, but it has left his mind sharp. The same thing has happened to my bother, who is shown in a wheelchair here earlier in the disease's progression:
My brother Kenny and family
Now he still is in a wheelchair (or frequently his recliner), but it usually has a computer attached whose mouse is controlled by his eye movements (a camera captures them). He has a joystick to move him around. It's not too much unlike Stephen Hawking.

My brother's form of the disease is not genetic, but there are genetic forms that they use in the laboratory. Scientists don't understand the cause of ALS, and so they have to use the genetic form in the laboratory and hope they can make discoveries that help everyone. So far successes that they've had with mice models in the laboratory don't map well onto humans. There's so much more work that needs to be done.

Senate Republican Tom Coburn of Oklhaoma has put blocks on bills that would support ALS research. He uses them as leverage. Just weeks ago, a Republican filibuster prevented passage of the ALS registry act. You see, there's not even a nationwide registry of who gets ALS. My brother also had a strange case of shingles when he was younger, and maybe that has something to do with him developing ALS later on in life. If doctors could look for correlations among people with ALS, they could figure these things out, but they'd need a nationwide ALS registry for that. For the moment, Republicans are preventing that. (oh, and stem cell research (embryonic and otherwise) benefits ALS research too)

I can't vote against Tom Coburn (I'm registered to vote in Ohio). I can try to get Republicans out of office. More importantly and more quickly, I can participate in this walk. I can donate to the ALS association. I can spread the word. AND SO CAN YOU.

So come and support my walk with a donation or come and walk yourself. I'll appreciate it, and so will Kenny, and so will Stephen Hawking and many others who were surprised to find one day that they have some link to this sad disease.

Above all, walk because you can. As my brother recently said on the MDA telethon when they talked to him, ALS does not discriminate.

Friday, September 05, 2008

Graduate School Reflection

When looking for a good graduate program, most people focus on the adviser. After all, with as individual-driven as graduate school is, having an adviser who checks in every once in a while and cares is a nice thing to have. However, I don't think most people think about the department. That's probably because there's no help there. It's probably the case that wherever you go, the department doesn't care about you or its classes. The department will do its best to screw you over. The department will put you through hell... but maybe that's their job. Maybe everyone gets a good hazing as a rite of passage on the way to joining academia.

I suppose it could be worse. One thing I didn't realize as an undergrad is how much the department really really doesn't care about them. Undergrads are a little bit like the coppertops of The Matrix; they plug in and go about their lives not ever realizing that they're just there to generate revenue. There's no social good. There's no professional obligation to educate young professionals. It's all about the money.

One day I sat in on a meeting of large donors to The College. A marketing person from The College or The University gave a PowerPoint presentation on improving the ranking of The College. One major topic of discussion was about which pictures to put on the front of brochures that are mailed out to other Colleges who contribute to the rankings ("Ah, yes, but what type of people both become engineers AND become deans of engineering colleges? Maybe engineers prefer charts, but deans prefer pictures of people walking on grass!" (no joke)). Another topic was how many graduate students to accept in order to maximize one variable in a large formula that contributes to ranking. Too few graduate students and you have too few research dollars being spent, but too many and the professor-to-student ratio is all upset. No talk of "excellence" or anything like that. All about marketing and presentation. Oh... why was I there? I had to sit and be pretty so the old donors had some young people to talk to during the dinner.

Welcome to a research I university.

Thursday, September 04, 2008

Squirrels 1, Chipmunks 0

I just saw a squirrel carrying around a dead chipmunk in its mouth.

I guess campus squirrels get hungry when school has been out for a while...

Course web pages, LaTeX, and Mercurial — Oh, my!

I have been assigned to TA yet another different course for the Autumn 2008 quarter. That was a bummer for me because I have been taking instruction way too seriously, and it has been taking up way too much of my time. However, I've been pretty happy with the results. I've been getting flattering praise and very helpful feedback. More importantly for this post, I've been producing lots of revision-controlled content that can be used for reference or as examples.

The four course web pages that I've produced so far...I've tried to generate lots of reference material all with LaTeX, and I've tried to put the sites together so that everything can be build via standard Makefiles. I've put all of the source code (minus the exams/quizzes) at my public Mercurial repository home:In my latest adventure, ECE 209, I'm going to give my students extra credit if they use TeX for any assignments they hand in. So I've put getting-started information at those web pages, and they can use the Mercurial repositories for more working examples.

I'm really a lot more proud of this work than I thought I'd be. I'm actually looking forward to the new ECE 209 class. It's the youngest group of college students I've taught since a long time ago, and I think it will be interesting. Yesterday I went through and got the lab in order. I put up instructive signs about how to use oscilloscope probes and pin-outs of commonly-used ICs. I numbered all of the tables. I added notes to the function generators telling them how to set them for high impedance output termination. Earlier I went through and repaired all of the phase-shifter circuits (out of 16 circuits, only about 4 were working, but the other 12 could be easily repaired with a little solder and/or a new op-amp IC) and added a little instructive page on how they work. Now all that's left is the actual experience that will make me even more jaded and realize that all of that work was for nothing. :)

Meanwhile though... Lots of free LaTeX examples and circuit references. Yay!

iTerm AppleScript crashing fix

Lately, my officemate and I noticed that iTerm build 0.9.5.0902 crashes whenever AppleScript tries to talk to it. I was excited about some of the full screen fixes, but I couldn't do without my "Open iTerm Here" context menu item, and so I had to come up with a fix.

In my old scripts, I was doing things like this:
tell application "iTerm"
activate
set theTerm to make new terminal
tell theTerm
set theSession to make new session at the end of sessions
tell theSession to
exec command "/bin/bash -login"
write text "ls"
end tell
end tell
end tell
It appears like it's the make new session that's causing the problem. So I changed the set theSession... and tell theSession... lines to use a launch instead. The result:
tell application "iTerm"
activate
set theTerm to make new terminal
tell theTerm
launch session "Default Session"
tell the last session
exec command "/bin/bash -login"
write text "ls"
end tell
end tell
end tell
Not only does that not crash for me anymore, but it seems to be a bit faster (my imagination?).

Tuesday, August 19, 2008

Building MATLAB images from Makefiles

Recently I beefed up my LaTeX Makefiles to make image generation more automatic. These implicit rules have worked very well for me (note that the indentation is done with TABS — that's important).
%.pdf : %.eps
epstopdf $*.eps

%.eps : %.m
matlab -nosplash -nodesktop -r "$*;quit"

%.eps : %.png
convert -density $(RESOLUTION) $*.png $*.eps

%.eps : %.jpg
convert -density $(RESOLUTION) $*.jpg $*.eps

%.eps : %.dvi
dvips $* -D $(RESOLUTION) -E -o $*.eps

%.dvi : %.tex
latex -interaction=nonstopmode $*.tex
rm -f $*.log
rm -f $*.aux
That if, if I need a file called FILENAME.eps or FILENAME.pdf, the Makefile will look for FILENAME.m, FILENAME.png, FILENAME.jpg, or FILENAME.tex. Depending on which one it finds, it will run the appropriate command to generate the image I need. Note that I define RESOLUTION=1500 in the top of my Makefile.

I want to point out the MATLAB build line:
matlab -nosplash -nodesktop -r "$*;quit"
That handy line starts up as little of MATLAB as possible and runs a script that contains something like:
% First, generate a figure somehow

% Next, setup the figure's print proportions
set( gcf, 'PaperType', 'usletter', ...
'PaperOrientation', 'portrait', ...
'PaperPosition', [0.0 3.5 11 3.5] );

% Finally, save the figure as a (color) EPS
saveas( gcf, 'FILENAME.eps', 'epsc2' );
After the script finishes, MATLAB exits. It won't get started on any subsequent makes so long as the script file doesn't change or the image isn't deleted.

Getting back to the more general case, up high in my Makefile, I have something like
RESOLUTION=1500
BASETEXIMAGES=$(shell perl -ne \
'/\\includegraphics\s*(?:\[.*?\]|)\s*{\s*(.*?)\s*}/ \
&& do { print "$$1 " \
if (-e "$${1}.tex" || \
-e "$${1}.png" || \
-e "$${1}.jpg" || \
-e "$${1}.m"); };' *.tex)
TEXIMAGES=$(addsuffix .eps,$(BASETEXIMAGES))
and a little later I make $(TEXIMAGES) a dependency for my document (or something equivalent to that).

Those lines have saved me a lot of time, and I'm pretty happy about them.

Wednesday, August 13, 2008

"Don't Be Upset" by Jeffrey and Jack Lewis

Great lyrics and a fun little song...
i took my darling out to the aquarium
sea creatures stared at us and we stared back at them
my baby freaked when she peeked at that 8-legged blob with a beak
she was too scared to speak
i said don't be upset it's only an octopus
don't bother it and i'm sure it won't bother us
please don't be upset my darling, please don't get upset
my baby came riding to meet me one time
on the crowed last car of the downtown-bound 9
she was brave but she caved
when the train was delayed
it was just the last straw in her hard busy day
i said don't get upset 'cuz it's not a catastrophe
nothing will happen and soon you'll be back with me
please don't be upset my darling , please don't be upset
my gal's got a headhache, her ankle is hurting too
boots she bought gave her a rash & her winsdom tooth
is coming in and it's damp out and she's having cramps and she's so mad at me cuz i didn't shave
i said don't be upset i know you're feeling sensitive
i'll try to be kinder and be more attentive
please don't be upset my darling please don't get upset
darling i said, i'm gonna be 27 soon
i've only got rejection letters and a sense of impending doom
i think it's too late for me
all the comic companies hate me
and i try but it's always the same
i guess my art is just lame and it's strange but still somehow i'm
always not suiting their needs at this time
and she said ........don't be upset,
you know that you're wonderful
just keep on trying ...(actually what she really said was)
all you ever wanna talk about is your self and your comic books and your album and your tour
and everytime i see your friends they just ask me where you are again and it hurts
it makes me feel like dirt
i'm just gonna write where you are on my shirt
and i said don't be upset, don't be in a bad mood
let's just go to a show and hang out and feel good
come on please don't be upset my darling, please don't be upset, i'll do anything baby, just don't be upset

Monday, July 28, 2008

Adding section or subsection to every reference (but not label)

In the form topic, "Full context variable depth references to list labels?," someone wanted to force LaTeX to
  • use legal-format lists
  • reformat its references to prefix them with the full subsection number (e.g., "2.1-") when inside a subsection and section number (e.g., "2-") otherwise.
I suggested:
\usepackage{enumitem}
\newlist{legal}{enumerate}{10}
\makeatletter
\setlist[legal]{label*=\arabic*.,
ref=\csname
the\enit@prevlabel
\endcsname\arabic*.}
\newcommand\thesectionlabel{%
\ifnum\value{subsection}=0
\thesection
\else
\thesubsection
\fi}
\newcommand{\thelegal}{\thesectionlabel-}
\makeatother

\usepackage{varioref}
\labelformat{equation}%
{\thesectionlabel-\textup{(#1)}}
\labelformat{figure}{\thesectionlabel-#1}
\labelformat{table}{\thesectionlabel-#1}
I've wrapped lines (by inserting VERY important % characters in special places to make the snippet viewable in this thin blog. As you can see in the original thread, my suggestion looked shorter because the lines were unwrapped.

It seems to work well and is one of those solutions that TeXnicians would probably do on their own without a second thought and would never document, but it's something complicated-enough that everyone else would tear their hair out searching for it.

Saturday, June 28, 2008

pedagogical moment: LaTeX, TeX, environments, and csname

On the MiKTeX mailing list, a thread descended into a flame that someone bracketed with \flameon and \flameoff, which is a sort of Fantastic Four version of a LaTeX environment. The thread involved the differences between TeX, Plain TeX, and LaTeX, and so I took the opportunity to point a few things out. I received several positive responses, and so I decided to reproduce my post here.
\pedagogical

There's a TeX vs. LaTeX teachable moment here . . .

> > \flameon
...
> > \flameoff


     As an example, if you're using LaTeX, the proper code for a flame environment is:
\begin{flame}
\end{flame}
However, the \begin and \end macros do nothing more than call:
\flame
\endflame
and so bracketing an environment in these macros is (in principle) equivalent to using the \begin and \end environments.

     Further, a naive implementation of \begin and \end is:
\newcommand\begin[1]{\csname #1\endcsname}
\newcommand\end[1]{\csname end#1\endcsname}
which is equivalent to the "raw" TeX (which may also be used in LaTeX):
\def\begin#1{\csname #1\endcsname}
\def\end#1{\csname end#1\endcsname}
In other words, \newcommand and \def are basically the same beast. However, \newcommand is a macro (created with \def) that checks to make sure you haven't already \newcommand'd before. SIMILARLY, the REAL \begin and \end wrappers have extra sanity checks for safety.

     Finally, that leaves
\csname BLAH\endcsname
which is equivalent to
\BLAH
Notice that it looks like an environment. So I could also do:
\begin{csname}today\end{csname}
which actually gives me the same output as \today.

\endpedagogical

     --Ted
I should also note that the source code for LaTeX is listed in the source2e.pdf documentation that comes with nearly every LaTeX distribution (it does not appear to come with MiKTeX). Execute
texdoc source2e
to see the document on your system.

Friday, June 27, 2008

Interpolating for Zero-Crossing Detection in MATLAB

Today someone who read my post on sinc interpolation in MATLAB e-mailed me to ask about how to interpolate between data points in MATLAB to do accurate zero-crossing detection. Here, I summarize my response.

Detecting zero crossings of (nearly) square waves that are sampled is difficult to do accurately because it pushes the limits of the "band-limited" signal approximation we use when sampling. That being said, if you'd like to use sinc interpolation, you should decide *HOW* close you need to be to the zero crossing. For example, your original signal might have 50 picoseconds between samples, and so without interpolation, you can detect zero crossings accurate within 50 picoseconds (ps). Maybe you need a closer result. How close do you need to be? 10ps? 5ps? 1ps? Less than that?

Figure out how close you need to be and then generate the appropriate upsampled time vector:
uptime = 0:step_size:final_time;
where step_size is your tolerance (e.g., 5 ps) and final_time is the maximum value of your sampled time vector. It is a good idea to engineer your step_size and final_time so that length(uptime)/length(old_time) is an INTEGER. It's also a good idea to make sure that all of your old_time points (except maybe your last point) exist in your uptime vector (i.e., your uptime vector just has time ADDED between old_time points).

Then you can use any interpolation mechanism you'd like. If you want to use the sinc_interp function that I wrote, do something like:
new_values = sinc_interp( old_values, old_time, uptime );
If you use sinc_interp, make sure you use the VECTORIZED version, which is MUCH faster. Actually, MATLAB provides a MUCH faster function that does NEARLY the exact same thing — the interpft command. In that case, you do
new_values = interpft( old_values, length(uptime) )
Otherwise, you might have luck using the resample command in MATLAB (it does NOT do pure sinc interpolation; it's more sophisticated, and it may not match at every data point):
new_values = resample( old_values, P, Q );
where P/Q is the INTEGER representing length(new_time)/length(old_time) (again, engineer your step_size to make this possible). ALTERNATIVELY, interp works OK too:
new_values = interp( old_values, P/Q );
Try all three and see which one works best for you.

Once you have this new interpolated vector, use some mechanism to detect zero crossings. Off the top of my head, here's the fastest way I can think of to do the zero-detection. Assume that we have
  • y (column vector of data -- e.g., new_values)
  • t (column vector of time -- e.g., uptime)
Also assume that t is already sorted. Then... (note that union sorts too)
i = union( find(y==0), find(conv(sign(y),[1 1]) == 0) );
should give you the MATLAB indexes where y crosses zero.

To test, try...
plot( t, y );
hold on;
stem( t(i), max(y)*ones(size(i)) );
hold off;
The result should be a plot of your data with spikes added at each zero crossing. That example also demonstrates how you recover the particular zero-crossing times with
t(i)
For example, when I apply this algorithm to a sin(t) waveform, t(i) gives me 0, pi, 2*pi, and 3*pi out, as expected.

Thursday, June 26, 2008

sinc interpolation in MATLAB

UPDATE: The examples given here are meant to give mathematical insight into how sinc interpolation works by using a finite-time APPROXIMATION. Sinc interpolation necessarily involves a circular convolution, which is not a finite computation in the time domain. If you actually need to do sinc interpolation, use the interpft function. It does an FFT, pads the FFT with zeros, and does an IFFT. Consequently, it is VERY FAST. Moreover, using an FFT (or DFT, in general) is the only way to use a finite computation to do a sinc interpolation (or circular convolution in general). Just make sure that the resampled time vector you use has a length that is an integer multiple of your original time vector. Also make sure that it lands on the same points as your original time vector (i.e., it should only add new points between old points).

I've also created a interpftw that does the same job as interpft but allows you to reconstruct samples from different aliasing windows. Whereas interpft pads the end of the FFT with zeros, interpftw pads both the beginning and the end. In other words, the former is a low-pass filter and the latter is a bandpass filter.
If you search Google for sinc interpolation in MATLAB, many pages will reference the sinc_interp example from John Loomis. Unfortunately, I've found few sites that recognize that the function is not meant to do general purpose sinc interpolation. That is, it makes a few assumptions about the sampling rates that may not be evident to the average user.

So, I'm giving some of my students this example:
% Ideally "resamples" x vector from s to u by sinc interpolation
function y = sinc_interp(x,s,u)
    % Interpolates x sampled sampled at "s" instants
    % Output y is sampled at "u" instants ("u" for "upsampled")


    % Find the sampling period of the undersampled signal
    T = s(2)-s(1);

    for i=1:length(u)
        y( i ) = sum( x .* sinc( (1/T)*(u(i) - s) ) );
    end

    % Make sure y is same shape as u (row->row, col->col)
    y = reshape(y, size(u));
end
Here's a vectorized (i.e., MUCH FASTER) version:
% Ideally "resamples" x vector from s to u by sinc interpolation
function y = sinc_interp(x,s,u)
    % Interpolates x sampled at "s" uniformly spaced instants
    % Output y is sampled at "u" uniformly spaced instants
    % ("s" for "sampled" and "u" for "upsampled")
    % (consequently, length(x)=length(s))


    % Find the period of the undersampled signal
    T = s(2)-s(1);

    % The entries of this matrix are each u-s permutation.
    % It will be used to generate the sinc transform that will
    % be convolved below with the input signal to do the
    % interpolation.
    %
    % (recall that u(:) will be a column vector regardless
    % of the row-ness of u. So u(:) is a row, and s(:) is a
    % column)

    sincM = repmat( u(:), 1, length(s) ) ...
           - repmat( s(:)', length(u), 1 );

    % * Sinc is the inverse Fourier transform of the boxcar in
    % the frequency domain that was used to filter out the
    % ambiguous copies of the signal generated from sampling.
    % * That sinc, which is now sampled at length(u) instants,
    % is convolved with the input signal becuse the boxcar was
    % multipled with its Fourier transform.
    % So this multiplication (which is a matrix transformation
    % of the input vector x) is an implementation of a
    % convolution.
    % (reshape is used to ensure y has same shape as upsampled u)

    y = reshape( sinc( sincM/T )*x(:) , size(u) );
end
My function sinc_interp resamples the data in the x vector. The original time vector is given by the s vector and the new time vector is given by the u vector.

Alternatively, you can try this more advanced one that lets you pick which aliasing window you want to use to reconstruct (i.e., it's an ideal bandpass filter rather than just a low-pass filter).
% Ideally "resamples" x vector from s to u by sinc interpolation
function y = sinc_interp(x,s,u,N)
    % Interpolates x sampled sampled at "s" instants
    % Output y is sampled at "u" instants ("u" for "upsampled")
    % Optionally, uses the Nth sampling window where N=0 is DC
    %     (so non-baseband signals have N = 1,2,3,...)


    if nargin < 4
        N = 0;
    end

    % Find the period of the undersampled signal
    T = s(2)-s(1);

    for i=1:length(u)
        y( i ) = ...
            sum( x .* ...
                ( (N+1)*sinc( ((N+1)/T)*(u(i) - s) ) - ...
                  N*sinc( (N/T)*(u(i) - s) ) ) );
    end
end
Here's a vectorized (i.e., MUCH FASTER) version:
% Ideally "resamples" x vector from s to u by sinc interpolation
function y = sinc_interp(x,s,u,N)
    % Interpolates x sampled sampled at "s" instants
    % Output y is sampled at "u" instants ("u" for "upsampled")
    % Optionally, uses the Nth sampling window where N=0 is DC
    % (so non-baseband signals have N = 1,2,3,...)


    if nargin < 4
        N = 0;
    end

    % Find the period of the undersampled signal
    T = s(2)-s(1);

    % When generating this matrix, remember that "s" and "u" are
    % passed as ROW vectors and "y" is expected to also be a ROW
    % vector. If everything were column vectors, we'd do.
    %
    % sincM = repmat( u, 1, length(s) ) - repmat( s', length(u), 1 );
    %
    % So that the matrix would be longer than it is wide.
    % Here, we generate the transpose of that matrix.

    sincM = repmat( u, length(s), 1 ) - repmat( s', 1, length(u) );

    % Equivalent to column vector math:
    % y = sinc( sincM'(N+1)/T )*x';

    y = x*( (N+1)*sinc( sincM*(N+1)/T ) - N*sinc( sincM*N/T ) );
end

Tuesday, June 24, 2008

Wryness in song: The Girls Don't Care

"Eef Barzelay: A Blueprint for Finding Love" by Stephen Thompson
  • Song: "The Girls Don't Care"
  • Artist: Eef Barzelay
  • CD: Lose Big
  • Genre: Pop-Rock
As leader of the now-defunct Clem Snide, Eef Barzelay took flak from critics for weaving smart-alecky wordplay and pop-culture references into his keenly observational songs. But then, with the release of 2003's Soft Spot — a concept album about the unconditional love and sacrifice inherent in marriage and parenthood — he took yet more flak for singing straightforwardly sincere love songs.

Truth be told, Barzelay's work has always mixed wryness with unmistakable warmth, and he's never gotten enough credit for both the subtlety of the former and the sincerity of the latter. Ever since Soft Spot, and starting with the title track to 2005's End of Love, he's taken to occasionally needling those for whom expressions of love run counter to a painstakingly maintained ironic distance. "You're so sophisticated / Your mind's been liberated / You're the first to notice when a movement's come and gone," he sang in "End of Love," concluding, "No one will survive the end of love."

Since then, Barzelay has released a solo acoustic record (2006's Bitter Honey), recorded Clem Snide's swan song (the still-unreleased Hungry Bird), and made Lose Big, a smart and compact collection of rock 'n' roll conversation-starters. "The Girls Don't Care" in particular functions as an ideal sequel to "End of Love," as Barzelay gently advises against hipper-than-thou posturing: "The girls don't care that you ache to be free," he sings. "The girls just want a sweet melody."

Barzelay has never been afraid to turn a pop song into a mission statement: For proof, check out Clem Snide's masterful "I Love the Unknown," which Barzelay helpfully tacks on as a bonus track to Lose Big. In "The Girls Don't Care," he lays out a bona fide blueprint for how to find love: "Don't listen to Frank Zappa / play Coltrane, Faust, or Can / Just take that twisted heart of yours and lay it in her hand."
It's a pretty song too. Have a listen at the SotD link. Song lyrics are easy to find too.

Monday, June 23, 2008

Letter to Prospective Graduate Student

Now that all of my adviser's older graduate students have graduated, I have somehow become an international ambassador (completely against my will) for the university. I've been getting e-mails from students interested in getting their PhD in the area of control here at OSU. Here's a sample response, which may or may not be helpful to some random Googler out there.
> I am interested in Fuzzy controllers in Control Systems
> and have done some paper presentation on that in under
> Grad school. I plan to take the same for my PhD studies.

It's good to hear that you're considering advanced
studies in control systems. Keep in mind that state of the
art control research is not in fuzzy control. Modern control
uses a more rigorous mathematical approach. Recent interest
in nonlinear systems has made the mathematics of real
analysis an important tool for the control researcher.

That being said, Professors Passino and Yurkovich are
experts in fuzzy control (you can see their book on the
subject). Professor Passino's current research investigates
biological and psychological systems (in particular, how to
integrate engineering ideas into those fields and use
insights from those fields to inspire engineering
solutions). Professor Yurkovich is highly active in
automobile control system research (spanning everything from
the automobile itself to the manufacturing systems that make
it). Because Professor Yurkovich's research is a little more
conventional, it tends to be more easily funded.

Additionally, there are several other strong control
faculty members here at OSU. Professor Ozguner, for
example, is a leader in coordinated control (e.g.,
integration of multiple vehicles or systems with independent
controllers). Professor Serrani is an expert in nonlinear
dynamics (e.g., control of fluid flow through an
airbreathing supersonic jet). Check out OSU's ECE webpage
for more information on the other control faculty.

> 1. How do you find the course you are pursuing. That is
> about the quality of teaching, course material and other
> facilities at the university?

I think that the courses at OSU are very strong,
especially in control and *mathematics*. Keep in mind that
OSU's math department has a strong theoretical bias, which
actually makes it ideal for engineering disciplines
surrounding communication systems, signal processing, and
control systems (a focus on algebra for the first two and
real analysis for the latter). All of these courses are
taught by experienced faculty, and I have been very happy
with the level of instruction here at OSU.

That being said, some of our facilities are older.
Additionally, primarily due to lower undergraduate
enrollment in the ECE department, *internal* funding
opportunities for graduate students have been on the
decline.

> 2. Do I need to get in touch with any Professors before
> applying for admission?

*YES*, it would be a good idea to see
what space will be available. However, many will probably
tell you to get back in touch with them after you have been
admitted to the program. Still, you should contact them to
see if they'll be available to take on new students. It is
usually best to make first contact by e-mail (though,
depending on the professor, your mileage may vary). Make your
intentions clear in your e-mail's subject (e.g., "Considering
PhD Study in Control Systems Area at OSU").

Keep in mind that many professors will favor PhD
students over MS students (which shouldn't be an issue in
your case). Additionally, the OSU ECE department has
recently "modernized" its advanced degree program. Now there
is a 4 year (nominally) "direct to PhD" program that may (or
may not) be attractive to you. You might want to consult the
"ECE Graduate Handbook" (available on the ECE webpage in the
section for graduate students) to get more details about
those programs.

In the meantime, you should definitely be pursuing
outside funding options. Having outside funding will make
you more attractive to any university and will give you more
flexibility when doing your own research.

I hope that helps. Best wishes --
Ted
I'm leaving out many details that I bitch about frequently among friends. Maybe that's because I'm optimistic that the university (and the ECE department) will "change" for the "better," or maybe that's because I don't want to be the lone miserable schmuck.

Thursday, June 12, 2008

LaTeX generated figures: Using preview instead of pst-eps

I've been using the pst-eps package when I want to generate EPS versions of coded graphics (e.g., graphics produced with PSTricks or the standard picture environment). From the pst-eps description:
Pst-eps is a PSTricks (pstricks)-based package for exporting PSTricks images ‘on the fly’ to encapsulated PostScript (EPS) image files, which can then be read into a document in the usual way.
By wrapping lines in a TeXtoEPS environment, you setup LaTeX to produce an image of the enclosed content with a tight bounding box. It works well, but you must use dvips -E to generate your EPS files with the proper bounding box. If you want to then generate a PDF, you have to use something like epstopdf (possibly with the EPSCrop GhostScript option) to do it. Additionally, there's a lot of overhead within the actual TeX source. In other words, it's not quite easy to use.

A BETTER OPTION: Today, I discovered the preview package, which is described with:
The package is a free-standing part of the preview-latex bundle. The package provides the support preview-latex needs, when it chooses the matter it will preview. The output may reasonably be expected to have other uses, as in html translators, etc.
This package appears to be a much nicer solution. You can use standard latex or pdflatex to compile. If you need to use latex but still want EPS or PDF outputs, you can use dvips and ps2pdf without any special options. Otherwise, the introduced preview environment works very similar to the old TeXtoEPS environment, but it requires less work to use and seems to apply to a broader class of content.

Here's an example that should not require anything fancy to build. If you don't have the amsmath package (you should), you can omit it and get rid of the gather* environment:
\documentclass{article} 
\usepackage{amsmath} % for gather*
\usepackage[active, % Turns previewing on
tightpage, % Squeezes pages around previews
textmath, % Subjects textual math to a preview
displaymath, % Subjects math displays to preview
floats % Subjects floats to preview
]{preview}
% There is a ``graphics'' option too that subjects
% includegraphics to preview. If they are already in a
% float, the ``floats'' option is sufficient.
\begin{document}

This text will NOT get printed.

\begin{equation}
a = b
\end{equation}

The math following the colon gets printed: $x = 5$?

\begin{gather*}
c = d
\end{gather*}

More text not printed.

\begin{preview}
Page 2 is here (with tight border).
\end{preview}

You'll never see this text.

\begin{figure}
\fbox{\fbox{\fbox{A figure that is printed}}}
\end{figure}

\end{document}
If the active option of preview is commented out, the file builds as if preview didn't exist. However, with it turned on, only the sections in preview environments get printed, and they each get put on a separate page with tight borders. Options like displaymath, textmath, and floats cause those types of content to get automatically wrapped with a preview environment.

Related posts:

Tuesday, June 10, 2008

Safari Books On-line: Searchable TLC2

Check out Safari Books Online:It's pretty pricey to pay for a login, but requests that come from many universities (or libraries?) get a free login automatically. For example, from outside OSU, I can use my OSU login at:That is, I added ".proxy.lib.ohio-state.edu" to the end of the server name, which forces the request through the OSU library's proxy server.

There are lots of useful digital copies of reference books on-line. I think all of the O'Reilly books are available. More importantly (to me), you can find a digital (and searchable) copy of The LaTeX Companion (Second edition) by Mittelbach and Goossens. You can even copy and paste code samples directly out of the book!

Thursday, June 05, 2008

Trashy "untrash Ohio" campaign

UPDATE: I have received a response from the Executive Director of the campaign:
Hello Ted,

Thank you for your email. In this case, the apple core is the trash as it is waste out of place. The Trash Spoils Everything, Untrash Ohio campaign is specifically targeted at males ages 18-35. Research shows that the majority of littering is done by Caucasian males, aged 18 to 35-years-old. In fact, 71% of the litter found along streets and highways is caused by persons less than 35 years of age, according to the Institute for Applied Research. Most individuals litter because they have no sense of ownership or responsibility to the property they are trashing and assume someone else will pick-up what they have left behind. Of course, not all males in this age range litter and we know that.

This age group does use the environment for activities they enjoy but do not think about the trash they leave behind. The idea of the campaign is to show how one piece of trash spoils the environment for everyone and the activities that they enjoy. I understand your thoughts on the apple core but the idea is to get people to think about proper waste disposal and not just throwing their waste on the ground, whether it is biodegradable or not. No, apple trees are not littering when their fruit falls on the ground, but when people put it there it is litter. KOB is addressing litter in this campaign, not the issue of golf courses.

I hope that this answers some of your questions. Please let me know if I can be of further assistance.

Sincerely,

Kerry

Kerry Crossen
Executive Director

Keep Ohio Beautiful
P.O. Box 12776
Cincinnati, OH 45212-0776
614.604.2136
www.keepohiobeautiful.us

On Ohio roads, you can now find billboards for the new untrash Ohio campaign. One of them that I see daily is
Image of golf ball sitting on an apple core that looks like a golf tee.
It confuses me. Which one is the trash? Is it the biodegradable apple core that will rot away in a week? Or is it the golf ball that will sit in that spot forever until some animal chokes on it and dies?

What's worse? An apple tree dropping lots of apples or a golf course dropping lots of golf balls? Evidently untrash Ohio has something against apple trees.

I haven't done the leg work, but I bet that untrash Ohio is just a front for some shady collaboration between Microsoft and the NGCOA...

Pictures of Apple Snail ("Golden Mystery Snail") Laying Eggs

We have two apple snails (sold as an "ivory mystery snail" and a "golden mystery snail") in our small 6 gallon Eclipse tank. Evidently, the golden snail is a female and the ivory snail is a male, and so they mate all the time. In most tanks, this isn't a problem because the amphibious apple snails have to leave the water to lay their eggs and they can't do that when the tank has a lid on it. However, the Eclipse tank has a large dome-shaped lid so that everything (pump, filter, etc.) can be built into it. So, our female has been crawling up into the lid and laying eggs.

This morning, I couldn't find the female in the bottom part of the tank, and so I lifted the lid... and there she was! I've never seen pictures of an apple snail LAYING eggs, so I thought I'd take some. Unfortunately, they came out kinda blurry, but at least it's something!
You can see the egg sac she's laying right next to her. You can see that as she moves backward, the egg sac gets longer.

In the first picture, on another part of the lid, are some of the remnants of an old egg sac that has hatched (before we realized she was leaving the tank to lay her eggs).

Anyone have any ideas about how to prevent the snails from leaving the water? (note: throwing away the tank is not an option) We'd move the snails to our big tank that has a flat lid, but we're pretty sure our freshwater puffer would slowly dine on the snails until they died a long slow death.

Saturday, May 31, 2008

Alaska Grand Casino: Fake Check Scam

I got a fake check scam in the mail yesterday! Isn't that exciting? Check it out:In this particular scam, I was given a very real looking check for $4900.00. The scam claimed that I had won $100,000, and by some "sweepstakes act," I had to pay 3.9% of that money back (or $3900). So, I was supposed to cash this check and mail them $3900, leaving me $1000.

These fake checks are so realistic that banks can't tell the difference for a few days. So, if I would have cashed it, I would have gotten $4900, mailed them $3900 of it, and then the bank would have gone after *ME* for defrauding THEM of $4900.

This particular scam was from the Alaska Grand Casino. I had to contact the "Claims Attorney" in order to find out where to send the $3900. His information:
Allen Goodmann
1-647-219-5567
cnitelfin_sol@yahoo.com
If you'd like to contact this person, feel free! I'm sure he's lonely.

The check and letter were both signed by scanned-in signatures. I'm GUESSING that these signatures were taken from checks mailed to them from victims. Isn't that sad? Several (fake?) addresses and PO boxes were given on the letter and check. One of them listed both a PO box and a street address. The street address and city name were constructed from other state names, which I thought was cute.

The mail was sent from Canada. I've notified the Ohio Attorney General and the US Postal Inspection Service (USPIS). If you receive something similar, you should also notify your state attorney general and the USPIS.