9

I'd like to typeset a table listing some equations, something like

Euler's formula  &    e^{i\phi} &= \cos\phi + i\sin\phi
Euler's identity & 1 + e^{i\pi} &= 0

Putting this in a \begin{tabular}{l|rl} environment, all formulas would need to be surrounded by $'s, while by using array the text has to be put into a \text{...}. Is there any way to define that one contain by default is text while another is in mathmode?

2 Answers 2

10
\documentclass{article}
\usepackage{array}
\begin{document}

\begin{tabular}{@{} l >{$}r<{$} @{\kern1.4pt} >{$}l<{$} @{}}
Euler's formula  &    e^{i\phi} &= \cos\phi + i\sin\phi \\
Euler's identity & 1 + e^{i\pi} &= 0\\
\end{tabular}

\end{document}

enter image description here

The default tabular header is the definition for

-----------col 1---------- ------------col 2 ---------- ---------- col 3---------
\tabcolsep TEXT \tabcolsep \tabcolsep $MATH$ \tabcolsep \tabcolsep $MATH$ \tabcolsep

With @{...} I can replace the default length \tabcolsep where @{} ignores this additional horizontal space. Is it between two columns then it replaces both \tabcolsep

3
  • That was quick, thanks! What's the @ doing? Spacing for the =? edit Ah yes, it does Commented Apr 3, 2013 at 12:39
  • see my edited answer
    – user2478
    Commented Apr 3, 2013 at 12:46
  • 1
    You can avoid the \kern command (and guessing the correct value) by >{$}r<{$}@{}>{${}}l<{$}; this adds an empty subformula before the = symbol, providing the right spacing on both sides.
    – egreg
    Commented Apr 3, 2013 at 20:14
1

Fur future reference, the tabu package makes this rather easy:

\documentclass[a4paper, 12 pt]{scrartcl}

\usepackage[utf8]{inputenx}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{amsmath}
\usepackage{tabu}

\begin{document}

\section{Another possibility}

\begin{tabu} to 0.75\textwidth{X[l] X[r, $] X[l, $]}
Euler's formula  &    e^{i\phi} &= \cos\phi + i\sin\phi \\
Euler's identity & 1 + e^{i\pi} &= 0
\end{tabu}

\end{document}

So just by adding a $ in the definition of the column, its entire content is processed in math mode. This is what it looks like on screen: What it looks like on screen

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .