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.

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

Result

any help would be appreciated

share|improve this question
    
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

2 Answers 2

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}

Result

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?

share|improve this answer
1  
+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:

enter image description here

\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}
share|improve this answer
1  
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

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.