Tagged with “latex”

Four ways to underline text in LaTeX

Because I’m old-fashioned, I still write printed documents in LaTeX, and I still think hyperlinks should be underlined. In general, I’m glad that underlines as a form of emphasis have gone away (boldface or italics are much nicer) — but I have yet to be convinced to drop underlines on hyperlinks.

Sometimes I have to write printed documents that contain hyperlinks, which begs the question: how do you write underlines in LaTeX? Finding an underline I like has proven surprisingly hard — in this post, I’ll show you the different ways I’ve tried to underline text.

Using the \underline command

Without installing any packages, you can just use the \underline command. Here’s an example:

I visited \underline{Berlin} in \underline{Germany}.

and the rendered output:

The underline on “Berlin” is nice and tight — but notice how the underline on “Germany” is lower than “Berlin”. That’s to accommodate the descender on the “y”. (A descender is any part of a letter that extends below the baseline of the text. For example, “p”, “y” and “j” all have descenders, but “a”, “i” and “x” don’t.)

The inconsistency is what I don’t like about this approach. It’s fine for one-off underlines, but in a larger document, the inconsistency gets very obvious, and I don’t like how it looks.

Read more →

Getting plaintext <span class="latex">L<sup>a</sup>T<sub>e</sub>X</span> from Wolfram Alpha

Although I don’t write numerical equations very often, I couldn’t help but smile at this post by Dr. Drang. Building on a post by Eddie Smith which shows how to use WolframAlpha to evaluate a LaTeX expression for a numerical answer, he shows off a way to automate getting the equation from BBEdit, to save a tedious copy/paste step. Read their posts before you carry on.

Dr. Drang’s script gets the LaTeX equation out of BBEdit and loads Wolfram Alpha, but you still need to click the “Copyable plaintext” link. He ended the post as follows:

What I’d really like is to automate the copying and pasting of the answer. Wolfram’s page structure doesn’t make that easy, but it’s something I want to explore.

I tried to parse the Wolfram Alpha page structure in the past, and it was a bit of a mess. It’s much easier to use the Wolfram Alpha Developer API, which provides this very easily. I think I can use this to get the final piece.

Read more →