Browsed by
Category: LaTeX

LaTeX mathematical expectation shortcut

LaTeX mathematical expectation shortcut

I find it cumbersome to typeset {\mathbb E}[x], “the expectation of x”, in LaTeX. I’ve simplified the code a little.

First, include these lines in the header of your document:

\newcommand{\e}[1]{{\mathbb E}\left[ #1 \right]}

This calls on the necessary packages and makes a new function \e which takes one argument. The outcome is that argument within appropriately-sized square brackets and prefaced with the expectation sign.

For example, the code \e{x^2}=10 results in {\mathbb E}[x^2]=10.

Writing MCQs in LaTeX: the qanda class

Writing MCQs in LaTeX: the qanda class

I was writing a series of practice multi-choice questions for the class I teach when I decided I wanted to write a LaTeX function to automate the formatting. I wanted to include the answer as an argument of that function (possibly with room for an explanation) but not to display the answer until the end of the document. (This is a reasonably simple process. For a more hardcore setup, see the eqexam package.)

I hacked away at the endnotes package until I got what I wanted. Editing packages is a pain though, so I summarized the changes into a Questions and Answers class: qanda.cls.

This does the dirty work in the background and defines two new commands: \q and \qtf. The former takes six arguments: the question, four multi-choice options, and the answer. The latter takes four arguments: the question, two multi-choice options (e.g. true and false, thus the tf in command name), and the answer.

This makes writing multi-choice questions very easy. Here is some sample code.

\title{An Example of the qanda Class}
\author{Enda Hargaden}
This document is an example of the output of the qanda (``q and a'') class.

\q{Who wrote \textit{Animal Farm}?}{Hargaden}{Orwell}{Marx}{Huxley}{Orwell}
\qtf{There are subtle historical parallels in \textit{Animal Farm}.}{True}{False}{True; it is an allegory for the unfortunate route Communism took.}
\q{Who wrote \textit{Capital}?}{Hargaden}{Orwell}{Marx}{Huxley}{Marx}



This produces this nifty document.

To use the qanda class:

  1. Download qanda.cls
  2. Place it in the folder your .tex is in
  3. Start your document with \documentclass{qanda}

To produce the answers to your questions, simply include the \theendnotes command where you want them in your document. Preface this with \newpage if you want them on a new page.

Note that the qanda class is based on the scrartcl class, so you need that on your computer. You also will need to have installed the enumerate and setspace packages.


Latin phrases and Greek letters for economists

Latin phrases and Greek letters for economists

Latin phrases for economists
Phrase Translation
A priori Pre-supposed; your “priors beliefs”.
Ad infinitum To infinity; and so on.
Ad valorem Per value; a 10% tax is an ad valorem tax, whereas a duty per gallon of gasoline is not.
Ceteris paribus All else equal e.g. “We would expect, ceteris paribus, that an increase in price would lower quantity demanded.”
De facto For all practical purposes, but not officially.
De jure By law.
Ex ante Before the event; in anticipation.
Ex post After the event; in retrospect.
Per se Literally; by itself.
Prima facie In the first instance; at first glance.
QED As has been asked to be shown; done.
Ultra vires Beyond their power, e.g. the court ruled that Congress were acting ultra vires.
Greek letters for economists
Lower-case Upper-case Pronunciation Economic meaning
\alpha A Alpha Capital share of income
\beta B Beta Regression coefficient (econometrics), or rate of time discounting (economic theory)
\gamma \Gamma Gamma N/A
\delta \Delta Delta Depreciation
\epsilon E Epsilon Elasticity
\zeta Z Zeta N/A
\eta H Eta N/A
\theta \Theta Theta Type, e.g. \theta_H might represent a “high type”
\iota I Iota N/A
\kappa K Kappa N/A
\lambda \Lambda Lambda The Lagrange multiplier
\mu M Mu Mean
\nu N Nu N/A
\xi \Xi Xi N/A
o O Omicron N/A
\pi \Pi Pi Inflation, or profit (lower-case) or the product of a series (upper-case)
\rho R Rho The coefficient of autoregression
\sigma \Sigma Sigma Standard deviation (lower-case) or the sum of series (upper-case)
\tau T Tau Tax
\upsilon \Upsilon Upsilon N/A
\phi \Phi Fy N/A
\chi X Chi (rhymes with `guy’) Used in statistics
\psi \Psi Psi (like `Si’) N/A
\omega \Omega Omega N/A

Some Useful Latin and Greek (PDF)
Some Useful Latin and Greek (TeX)

A clarification on LaTeX

A clarification on LaTeX

Just in case you’ve googled me and wondered why I happily link to something called LaTeX, I should clarify that LaTeX (most commonly pronounced “Lay-tek”) is a computer language for typesetting documents.¬†(Well, it’s officially called \LaTeX and is a markup language rather than a standard computer language, but that’s splitting hairs.)

Most people use Microsoft Word to write documents. That’s fine. I prefer to use LaTeX, particularly if there is any mathematics in the document. The primary reason for this is ease. LaTeX can “read” math and I find it easier to type \sum x_i to obtain \sum x_i than to mess around with the equation editor.

LaTeX also produces remarkably beautiful documents. I appreciate that this sounds particularly nerdy, but it’s true: ask Dario for proof.¬†Moreover, its settings are defaulted to look just right, so there’s no messing around with fonts, margins, line-spacing, etc.

Andrew Roberts has a thorough outline of the benefits of LaTeX. Here’s my summary:

  1. Math(s) is much easier to write.
  2. Presentations (via beamer) are cooler.
  3. The documents look better.
  4. You don’t have to worry about how it looks, so you can focus on content.

I admit the name is unfortunate, though.