≡ Menu

Including eps figures into LaTeX

I have a folder for my images that I include in my LaTeX documents called “img”. My graphics package is set by (it used to be slightly different — see bug report below):

\usepackage{graphicx}
  \graphicspath{{img/}}

Pro-tip: If you turn an image 90 degrees, it’s height and width are defined by how it started. So, if you have a plot that you want to be the same width as your text:

\includegraphics[height=\textwidth,angle=-90]{figure12}}

Pro-tip 2: I did not include an ending on figure12 — the graphicx package is smart enough to find the .eps, convert it, name the converted file figure12-eps-converted-to.pdf and then include it into your document. It leaves your original .eps there, and future compilations of the document just uses the pdf version, no need to reconvert.

Bug Report

I discovered some weird behavior (probably a bug) by the LaTeX package graphicx.

I was including the graphics package and setting the graphics directory by including the following in the preamble:

\usepackage{graphicx}
  \graphicspath{{./../img/}}

Meaning that the folder with all my images was up a directory and down in a folder called “img”. What’s weird is that it was not automatically converting the figures that were encapsulated postscript (*.eps) files into .pdfs that could be included. I tried all manner of changing the path (./../img/), not including the path and specifying it from the \includegraphics command… nothing worked until I moved the img folder into the same directory as the tex source.

My guess: graphicx does not handle the “..” in the path name correctly.

{ 0 comments }

Getting Optimal Weight from a Spectrum

To derive the equation for the information one can get from a spectrum.

Doppler shift:

\displaystyle  \frac{\delta v}{c} = \frac{\delta \lambda}{\lambda}

Assuming that the Doppler shift is small compared to absorption line width, the observable intensity change at a given pixel:

\displaystyle  F \left ( i \right) -F_0 \left ( i \right) =  \frac{\partial F_0  \left ( i \right)}{\partial \lambda} \delta \lambda \left ( i \right)

\displaystyle  F \left ( i \right) -F_0 \left ( i \right) = \frac{\partial F_0  \left ( i \right)}{\partial \lambda}\frac{\delta v\left ( i \right)}{c} \lambda \left ( i \right)

Doppler shift restated:

\displaystyle  \frac{\delta v\left ( i \right)}{c} = \frac{F \left ( i \right) -F_0 \left ( i \right) }{\lambda\left ( i \right) \left [ \partial F_0 \left ( i \right) / \partial \lambda \left ( i \right)\right ]}

Add over available spectrum. Each pixel contributes according to the optimal weight:

\displaystyle  W\left ( i \right) = \frac{1}{\left (  \frac{\delta v_{RMS}\left ( i \right)}{c}\right)^2}

citation: http://adsabs.harvard.edu/abs/2007PhRvL..99w9001M

{ 0 comments }

A few more LaTeX tricks

Just happened to be a week where I figured out a lot of LaTeX things at once — and I wanted to get them down before they are lost forever.

I have wanted to know how to do an automatically variable height “evaluated at” symbol in LaTeX for a long time. Yesterday, I stopped waiting. First a couple of wrong ways:

\frac{x^2}{2} |_a^b
 
\frac{x^2}{2} \right |_a^b
 
\frac{x^2}{2} \Big |_a^b

The right way to do it is to use the \left \right tags — but I’d only used those when I had matching symbols, i.e.:

\left ( x^2 \right )

Turns out, you need both tags written like the following:

\left. \frac{x^2}{2} \right |_a^b

I found out how to do this by looking at someone else’s code, and curiously, they had a “\left.” — a “left” with a period after it — the period didn’t show up, so I didn’t know why, and my LaTeX compiled fine both including and removing the period. But the engine that typesets this page NEEDED “\left.” for it to parse properly!

 \displaystyle  \left. \frac{x^2}{2} \right |_a^b

{ 1 comment }

A few LaTeX tricks

I learned several neat LaTeX tricks in the past few days. The first is how to write LaTeX in my wordpress blog entry:

e^{\i \pi} + 1 = 0 or e^{\i \pi} + 1 = 0 syntax.

To write it, you enclose the mathtype you want like: [tag] e^{\i \pi} + 1 = 0 [/tag] (but replace tag with the word: latex).

e^{\i \pi} + 1 = 0 or e^{\i \pi} + 1 = 0 syntax.
Using the plugin: WP LaTeX

The second trick came from trying to set my paper in twocolumn mode and getting the figures to plot correctly. I used to scale by hand, when I was told that you can set the width using a multiple of textwidth (in the following example, one half of the textwidth):

\includegraphics[angle=-90,width=0.5\textwidth]{figvshiftu.eps}

The third and final thing I learned was that while adding a * to equations will keep them from being numbered, if you add it to figure, it breaks out of double column mode for that figure only.

\begin{figure*}
\end{figure*}

It even works (for emulateapj) with deluxetables.

{ 0 comments }