Thoughts, etc. Results of a non-deterministic process

14Aug/120

Trouble with figure previews in TikZiT

I recently decided to give the open-source TikZiT a try for drawing TikZ-based figures. While the feature set TikZiT can handle is a relatively small subset of TikZ's capabilities, it seems to do what it does quite well. I'm running version 0.8.417 on Mac OS 10.6.8 (Snow Leopard), and have only encountered one significant issue so far. Out of the box, everything seemed to work as advertised except for the previewing function. When I asked for a PDF preview to be generated by pdflatex, I'd receive only the relatively unhelpful error message "AN ERROR HAS OCCURRED, PDFLATEX SAID:"

AN ERROR HAS OCCURRED, PDFLATEX SAID:

with no indication of what it may (or may not) have said. I have TeX Live 2011 installed (though I see 2012 was released last month), with pdflatex in my path. I did what I could to debug the problem, but a Google search for the error returned no results and the error itself didn't give much to go on. So, I contacted the developer of TikZiT, Aleks Kissinger, who got back to me with the solution within a few hours.

Apparently TikZiT doesn't necessarily use the actual path variable set in your operating environment, but rather searches the two files ~/.profile and ~/.bashrc to attempt to learn the location of pdflatex for itself. The very simple solution was to create or add to one of these files, with a line similar to

 export PATH=/usr/texbin:$PATH

in order to tell TikZiT to look in /usr/texbin for the pdflatex executable. Once I'd put that command into my newly created ~/.profile, I didn't even have to restart TikZiT to get a preview of my graph.

8Apr/120

Rooting Android… Finally!

I've had my Xperia X10 for quite awhile now. In fact, since the day they first became available in Canada. I've wanted to root practically since the beginning -- the supposed ability to do so was one of my primary drivers in choosing an Android smartphone. Nevertheless, finding a distinct lack of custom ROM support for the X10 combined with relatively few non-ROM-flashing reasons to root, I've put it off over and over.

This evening though I finally got fed up enough with the bloatware on my Sony Ericsson Xperia X10 (running the stock Android 2.3.3 from Rogers in Canada) that I decided to root it. This is a brief chronicle of my experience, primarily for my own future reference. If it turns out to be useful to you too, then all the better.

Even though it thankfully turned out not to be necessary, I have to point out that the first thing I did was perform a backup of everything I could, using the Backup and Restore program.

With that out of the way, I followed DooMLoRD's instructions on xda-developers, downloading version 4 of his zergRush-based rootkit along with starquake64's bash script for Mac OS. Since I already had the Android Debug Bridge installed as part of the Android SDK, and had my phone set to allow USB debugging and installs from unknown sources, the shell script just ran without issue.

So far I've managed to free up a bit of internal space by finally moving some unused bloatware (Timescape, Postnote, Facebook, to name a few) to a backup folder on my SD card, based on a list of removable software (xda-developers again) and a suggestion from  the unofficial Xperia X10 blog. My next step was to install Titanium Backup Pro, which is uploading about 400 MB to Dropbox as I type. After that I'll keep working my way through lifehacker's guide to Titanium Backup, then hopefully on to more rooty goodness.

Tagged as: , No Comments
10Nov/110

Separating figures from a LaTeX document

Once again, I've run into something that shouldn't be an issue with a submission to PRA, but which nevertheless is. I generated some plots in Mathematica, but decided to label them with LaTeX. I thought this would be standard, given that it allows for a consistent font throughout the document, but the editors have said that using "commands in the manuscript source file to include axis labeling or other such content to your figures is a problem for us". Whatever the reasons for this, you can't argue with it if you want your manuscript published.

So, can you quickly extract each figure, complete with added labels, into a set of graphics files to be re-included in place of the original figures? Indeed you can! The first step is to use the preview package:

\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}

When you compile with this package active, every instance of the PreviewEnvironment will be rendered on its own page, and anything not in that environment will be suppressed. The tightpage option makes each page of the resulting file just big enough to contain the bounding box of its contents.

One warning: LaTeX labels get lost here, since they generally occur outside of the environment being extracted. This is important if you are, for example, placing a sub-figure label on the image. The first time you compile with preview active everything will look all right because the aux files will still remember the labels from the previous compile. If you start noticing `??' where you expect `(a)', just deactivate the preview package, recompile until things look right, then reactivate it.

The next step is to split the resulting file into a sequence of files, one per page in the original. My first attempt was to split either the postscript or PDF file using a command like

(Not the solution) pdf2ps allfigs.pdf fig%02d.ps

to split allfigs.ps into fig01.ps, fig02.ps, .... Unfortunately, this rasterizes the text, without even antialiasing it, and the result just doesn't look quite right. I was hoping to simply switch to pdf2eps or pdf2pdf for better luck, but at least on my Mac OS X machine these don't exist.

Instead, I found a page detailing a quick solution using Automator that spits out each page of a PDF into its own new PDF. The final step was simply to replace all of my lovely TikZ code with simple \includegraphics commands.

UPDATE: It turns out that the Automator solution trims the images a little too closely, and parts of the output PDFs are missing around the edges. I tried several other scripts and online PDF splitters, but ran into one of two problems with each. Either (a) the "split" PDFs contained only the first page, regardless of the output range asked for, or (b) the resulting PDFs were ever so slightly cropped, as with the Automator script. Finally I downloaded a program, PDFsam (PDF split and merge) which did the trick.

Finally, it turns out that I had to convert each of the individual PDF files to EPS format for submission to PRA. I accomplished this quickly and easily with a nice little script that runs Ghostscript.

14Sep/100

Passing multiple arguments from a List in Mathematica

In Mathematica a List, L, can be turned into a Sequence with the command Sequence@@L. This allows, for example, the logical-AND of the elements of L to be computed via

And[Evaluate[Sequence@@L]]

If L={x,y,z}, this results in the evaluation of And[x,y,z], instead of And[{x,y,z}], which is what And[L] produces.

27Aug/100

Odd LaTeX error in Phys. Rev. A submission

So I'm in the process of getting an article published in PRA.  I first submitted it in mid-June, and got the referee's response the day before I left for a two-week holiday!  I thought my mad scramble to address the comments and resubmit before leaving for the airport was successful, but while waiting in the boarding area I received an email entitled "URGENT <reference id>" from the editors.  Apparently they were unable to compile my document from its LaTeX source code, and needed me to debug the problem and re-submit.  Unfortunately, it compiled without any errors on my system.  It did generate some warnings on their system when I uploaded it, but no actual errors.  I figured this might make it tricky to debug.  If you've seen TeX output you can imagine just how long the list of errors I had to deal with was, but the first relevant section turned out to be:

! Use of \caption@@settype doesn't match its definition.
\new@ifnextchar ...served@d = #1\def \reserved@a {
 #2}\def \reserved@b {#3}\f...

For reasons I still don't understand, the problem was in using the \subref command within the \caption command of a figure. In each case, the caption was that of the figure containing the subfigure being referenced; I don't know if this caused the problem, or if it still wouldn't have worked referencing the subfigures from another figure's caption.

Whatever inner workings of TeX resulted in this combination's causing a problem, the solution was straightforward.  Thanks to a post on miscellaneous.debris, I found that simply adding \protect before each \subref made the problem go away.