# Text alignment in table's cell

MWE:

\documentclass[12pt,a4paper]{article}
\usepackage[centertags]{amsmath}
\usepackage[a4paper,bindingoffset=0.2in,left=0.5in,right=0.5in,top=0 .5in,bottom=0.5in,footskip=.25in]{geometry}
\usepackage{latexsym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{parskip}
\usepackage{array}
\usepackage{caption}
\usepackage{cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}
\usepackage{newlfont}
\usepackage{enumerate}
\usepackage{makeidx}
\begin{document}
\large
\hline
$x$ & $43$ & $44$ & $36$ & $38$ & $47$ & $40$ & $41$ & $54$ & $37$ & $46$\\ \hline
$y$ & $74$ & $76$ & $60$ & $68$ & $79$ & $70$ & $71$ & $94$ & $65$ & $78$\\ \hline
\end{tabular}
\end{document}


Question: How to adjust the text inside the cell of table in the center align.

I mean see the space above and below 43 and 74. How can i get equal space?

With tabularx package you can achieve the centred cell alignment. Also if the content of the whole column is in math mode, then is sensible, the whole column to be defined in this mode. Then you don't need to write in each cell $...$. So by using these dirty tricks

\documentclass[12pt,a4paper]{article}
\usepackage[centertags]{amsmath}
\usepackage[a4paper,bindingoffset=0.2in,left=0.5in,right=0.5in,top=0 .5in,bottom=0.5in,footskip=.25in]{geometry}
\usepackage{latexsym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{parskip}
\usepackage{array}
\usepackage{caption}
\usepackage{cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}
\usepackage{newlfont}
\usepackage{enumerate}
\usepackage{makeidx}
\usepackage{tabularx}
\renewcommand\tabularxcolumn[1]{m{#1}}
\newcolumntype{C}{>{\centering\arraybackslash $}X<{$}}
\begin{document}
\large
\begin{table}[h]
\renewcommand{\arraystretch}{3}
\setlength{\extrarowheight}{-2.5pt}
\begin{tabularx}{\textwidth}{ |C|C|C|C|C|C|C|C|C|C|C|}
\hline
x & 43 & 44 & 36 & 38 & 47 & 40 & 41 & 54 & 37 & 46\\ \hline
y & 74 & 76 & 60 & 68 & 79 & 70 & 71 & 94 & 65 & 78\\ \hline
\end{tabularx}
\end{table}
\end{document}


gives you

• It's working nice. But how can i modify the given codes using desirable output. – Maths4Sandy Aug 11 '18 at 7:21
• @snehal Updated my answer with your MWE. Let me know if its okay for you. – Raaja Aug 11 '18 at 7:28
• @snehal and what do you mean by " using desirable outputs"? – Raaja Aug 11 '18 at 7:38
• You answer is working perfectly for me. But in addition i am just asking that can we make some correction in my MWE for same solution? – Maths4Sandy Aug 11 '18 at 7:50
• @snehal yes of course we can, but, this is the possible way I know to do it ;) – Raaja Aug 11 '18 at 7:55

\documentclass[12pt,a4paper]{article}
\usepackage[a4paper,bindingoffset=0.2in,left=0.5in,right=0.5in,top=0 .5in,bottom=0.5in,footskip=.25in]{geometry}
\usepackage{array}
\usepackage{cellspace}
\setlength\cellspacetoplimit{7pt}
\setlength\cellspacebottomlimit{7pt}

\begin{document}
\begin{table}
\centering\large
\begin{tabular}{|c|              % <---
*{10}{S{>{$}c<{$}}|}} % <---
\hline
x & 43 & 44 & 36 & 38 & 47 & 40 & 41 & 54 & 37 & 46\\ \hline
y & 74 & 76 & 60 & 68 & 79 & 70 & 71 & 94 & 65 & 78\\ \hline
\end{tabular}
\end{table}
\end{document}


note: the preamble is minimized, i.e. all not to problem related packages are not considered in above mwe.