“the j stands for Joust”
about me | blog | facebook profile | linkedin profile | twitter profile | stuff i've done | stuff i like | wordpress plugins

9 May, 2010

Vertical alignment of inline images in LaTeX

Filed under: LaTeX,Useful — Tags: , , , , , — John @ 12:05 pm

This is one of those things which isn’t so easy to find, so here’s my contribution.

The Problem

You’re using LaTeX, and have a small image which you want to display inline with the text (i.e. not a float). So, you use something like the following:

...indicate whether the phrase you've constructed is valid (\includegraphics{tick.png}) or not (\includegraphics{cross.png}}). To make things...

This works, but often the vertical alignment is not quite right, as shown in the images below:

Inline images, non-aligned

Zoomed (x600)

The Solution

After some searching and experimenting, I found the best solution to be using the \raisebox command with a negative value, like so:

...indicate whether the phrase you've constructed is valid (\raisebox{-1mm}{\includegraphics{tick.png}}) or not (\raisebox{-1mm}{\includegraphics{cross.png}}). To make things...

The additional code is minimal and it works perfectly (as far as I can tell). Results as below:

Inline images, properly aligned

Zoomed (x600)

3 May, 2010

Mendeley, BibTeX and citing Website URLs

Filed under: Academic,LaTeX — Tags: , , , , , , , — John @ 12:57 pm

The Problem

  1. Using Mendeley Desktop (<3) to manage all my dissertation references, which automatically writes a BibTeX (.bib) for me which I include in my LaTeX document. So far so good.
  2. When I manually create an entry in Mendeley for a website, it creates a BibTeX entry like the following:
    @misc{myKey,
    author = {Surname, Name},
    title = {{Website Name}},
    url = {http://my.url.com/},
    year = {2010}
    }
  3. That looks fair enough, but standard BibTeX/LaTeX simply ignores the url field in the entry… which makes the reference look rather stupid. So how can I handle websites properly?

What I hoped I would be able to find

  1. I wish Mendeley had some more advanced options which controlled how BibTeX files were created, this would have definitely been the most ideal option, but alas no such options exist. Editing the generated .bib yourself would be pointless since Mendeley will just overwrite the file each time.
  2. BibTeX itself could really do with an update in the website-citation department. I’ve seen lots of talk about new versions but can’t see where they are… Also I know there are alternative BibTeX packages which can be used, but this was something I wanted to avoid because sometimes you can’t tell what else it’s going to change in your references. For more information on the options, I recommend this link: URLs in BibTeX bibliographies

The Solution

  1. The best solution I could come up with so far, is to simply delete these references from Mendeley and put them in your own custom .bib file. Thus, you will have the Mendeley-generated bib file (which we’ll call mendeley.bib) and your own custom bib file for website entries (which we’ll call websites.bib)
  2. When writing your BibTeX website entries, be sure to use the howpublised field like so:
    @misc{myKey,
    author = {Surname, Name},
    title = {{Website Name}},
    howpublished = {\url{http://my.url.com/}},
    year = {2010}
    }
  3. This will get BibTeX to correctly show the URL in the bibliography entry.
  4. Finally in your LaTeX document be sure to include both bib files, like so: \bibliography{mendeley,websites}

An Alternative

Actually, what I ended up doing in my dissertation is listing these “one-off” website references as footnotes rather than actual citations, since they’re not exactly publications. Obviously you will have to see whether this is applicable or not to you.

22 September, 2009

LaTeX underlines in uneven positions?

Filed under: LaTeX — Tags: , , , , — John @ 1:10 pm

Just started using LaTeX, and it annoyed me how the vertical-alignment of the \underline{} tag is not always the same, depending on whether the text ‘dips downwards’ or not (don’t know the correct term).

Anyway I found a fix, basically use \usepackage[normalem]{ulem} in your preamble, and \uline{My Text} instead of \underline{} in your normal text.

via Getting to Grips with Latex – Formatting – Latex Tutorials by Andrew Roberts @ School of Computing, University of Leeds.

Powered by WordPress