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.

Here is the example:

\begin{tabularx}{\textwidth}{ |X|X|X|X|X| }
\hline
Equation & 2 & 3 & 5 & 7 \\
\hline
$y_0 = b^{t}$ & -483061 & 1 & -174089 & 793599 \\
\hline
$y_1 = y_0^{2}$ & -1 &  & 73782 & 77096 \\
\hline
\end{tabularx}

I tried \centerline between letters and \center after \textwidth, but it doesn't seem to work.

share|improve this question
    
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). –  egreg May 5 '13 at 18:12
    
Thank you for letting me know this! It's my first time here, so I don't have much experience here as I do in Math Stack Exchange. Hopefully, I won't forget. ;) –  NasuSama May 5 '13 at 18:15

1 Answer 1

up vote 3 down vote accepted

You should add >{\centering} before the relevant column, or more conveniently define a new column type as follows:

Sample output

\documentclass{article}

\usepackage{tabularx}

\newcolumntype{Z}{>{\centering\arraybackslash}X}

\begin{document}

\begin{tabularx}{\textwidth}{ |Z|Z|Z|Z|Z|Z| }
\hline
Equation & 2 & 3 & 5 & 7 \\
\hline
$y_0 = b^{t}$ & -483061 & 1 & -174089 & 793599 \\
\hline
$y_1 = y_0^{2}$ & -1 &  & 73782 & 77096 \\
\hline
\end{tabularx}

\end{document}
share|improve this answer
    
Good answer. ;) Thank you very much! –  NasuSama May 5 '13 at 18:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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