# latex table layout problem

Hi Im having some trouble aligning the text in the second column of a two column table. The first column the text aligns the way i want but the seconds columns text is not positioning properly.

\begin{table}[h]
\begin{center}
\begin{tabular}{ |m{7cm}|m{6cm}|}\hline
PHP & Hypertext Preprocessor \\[2ex] \hline
MySQL & Structured Query Language \\[2ex] \hline
HTML & Hypertext Preprocessor \\[2ex] \hline
JQUERY & JavaScript library \\[2ex] \hline
AJAX & Asynchronous JavaScript and XML \\[2ex] \hline
GUI & Graphical user interface \\[2ex] \hline
JavaScript & Hypertext Preprocessor \\[2ex] \hline
URL & Uniform resource locator \\[2ex] \hline
API & Application programming interface \\[2ex] \hline

\end{tabular}
\end{center}
\end{table}\newpage


any help would be appreciated

-
 unrelated to your problem but using [h] on its own is essentially an input error: latex will change it to [ht] to give itself a chance but still disallowing p floats makes it much more likely that the float goes to the end of the document. – David Carlisle Dec 9 '12 at 18:17

I assume that your "not positioning properly" problem is that the text in the second column is not vertically centered in the cell. Perhaps this is the reason for using the m column type? Since in your case each cell is short enough to fit in a single line, there is no reason to use m type. I guess that what you are trying to do is to have more vertical space inside the cells.

If this is the case, you can get the desired effect by redefining \arraystretch. The following MWE shows you how.

\documentclass{article}
\usepackage{array}
\begin{document}
\begin{table}
\renewcommand{\arraystretch}{1.5}
\centering
\begin{tabular}{|l|l|}\hline
PHP & Hypertext Preprocessor \\\hline
MySQL & Structured Query Language \\\hline
HTML & Hypertext Preprocessor \\\hline
JQUERY & JavaScript library \\\hline
AJAX & Asynchronous JavaScript and XML \\\hline
GUI & Graphical user interface \\ \hline
JavaScript & Hypertext Preprocessor \\ \hline
URL & Uniform resource locator \\ \hline
API & Application programming interface \\ \hline
\end{tabular}
\end{table}
\end{document}


EDIT: As suggested by cmhughes in a comment, I also removed the center environment and used \centering command. More info at Should I use center or centering for figures and tables?

-
+1 but could you remove center and replace it with centering and link to Should I use center or centering for figures and tables? – cmhughes Dec 8 '12 at 16:41

The problem is the alignment. So what does @{}m{0pt}@{} stand for? @{} removes the empty space usually placed to separate the columns; hence having one on the right and left of m{0pt} creates non of those extra spaces. Notice that we do not have | after @{}m{0pt}@{} since we do not want the vertical rule of the column. Now the m{0pt} means that the column width is of zero length and thus non-existent. Essentially, what we have done is a phantom column just to help with the alignment.

The following should help in your ordeal:

\documentclass[letterpaper]{article}
\usepackage{array}
\begin{document}

\begin{table}[h]
\begin{center}
\begin{tabular}{|m{7cm}|m{6cm}|@{}m{0pt}@{}}
\hline
PHP & Hypertext Preprocessor & \\[2ex] \hline
MySQL & Structured Query Language & \\[2ex] \hline
HTML & Hypertext Preprocessor & \\[2ex] \hline
JQUERY & JavaScript library & \\[2ex] \hline
AJAX & Asynchronous JavaScript and XML & \\[2ex] \hline
GUI & Graphical user interface & \\[2ex] \hline
JavaScript & Hypertext Preprocessor & \\[2ex] \hline
URL & Uniform resource locator & \\[2ex] \hline
API & Application programming interface & \\[2ex] \hline
\end{tabular}
\end{center}
\end{table}

\end{document}

-
You should provide an explanation why this helps. The OP will never make progress if they have to rely on examples only. – Marc van Dongen Dec 9 '12 at 9:38
@MarcvanDongen updated answer for more clarification. – azetina Dec 9 '12 at 14:12
Thanks. I think it improved the answer. – Marc van Dongen Dec 9 '12 at 14:57
This looks like an array package bug to me – David Carlisle Dec 9 '12 at 18:14
@DavidCarlisle It does. Probably contacting Frank Mittelbach should do the trick :) – azetina Dec 9 '12 at 18:17