# Using \frac within tabular [duplicate]

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!

-

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 ## 1 Answer 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