Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Possible Duplicate:
Using \frac within a table

I'm trying to do that within CodeCogs renderer, but it don't work:

\begin{tabular}{cc} \hline \frac{x}{2} & \frac{2}{x} \\ \hline \end{tabular}

How can I fix that? Thank you!

share|improve this question
4  
Fractions and other mathematical matter have to be in math mode: Enclose the \frac{}{} commands in dollar ($) signs to put them in math mode. See also the recent question tex.stackexchange.com/questions/21049/using-frac-within-a-table, of which this seems to be a duplicate. –  Jake Jun 20 '11 at 7:54
add comment

marked as duplicate by Jake, Andrew Stacey, egreg, TH., Caramdir Jun 20 '11 at 17:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

up vote 2 down vote accepted

Use $...$ or the tabular column definition

\documentclass[12pt]{article}
\usepackage{array,amsmath}
\def\xstrut{\rule[-2ex]{0pt}{5ex}}

\begin{document}

\begin{tabular}{ c >{\xstrut$}c<{$}} \hline 
 $\frac{x}{2}$ & \frac{2}{x} \\ \hline
 $\dfrac{x}{2}$ & \dfrac{2}{x} \\ \hline 
\end{tabular}

\end{document}

enter image description here

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.