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.

I have drawn a table of 2 columns and 5 rows. but because of 2nd row, 2nd column content is long,,, Only half of the table displays. other part is not displayed.. Please help me.....I tried many times but i couldnt find a solution.

This is the code.

\begin{table}[h]
\caption {Methods Of Validation }

\begin{tabular}{| l | l | }
\hline
Validation Example & Explanation \\ \hline
Unit Testing & The testing of a single program\\ \hline
Integration Testing  &  The testing of related Program or units of code. Validates that multiple parts of  the system interact according to the system design. \\ \hline 
System Testing & The testing of an entire system \\ \hline
Acceptance Testing & The testing the mobile app to make sure it Works as what the system requirements indicate \\ \hline

\end{tabular}
\end{table}
share|improve this question
    
This might help stackoverflow.com/questions/790932/… –  Ma Ming Jun 7 at 9:19
    
Try \begin{tabular}{l p{4cm}} instead of {l l}. –  Thruston Jun 7 at 9:25
1  
As well as the answer linked above, you might like to read this online book about tables in LaTeX. –  Thruston Jun 7 at 9:27
    
Thank you very much Thruston. it worked. –  user54172 Jun 7 at 11:32
add comment

2 Answers 2

up vote 3 down vote accepted

You can use the tabularx environment to have multiline cells in the second column. I redefined the X type so as to have vertically centred cells, and used the caption package (correct vertical spacing between caption ans table) and the cellspace package (better vertical spacing betwwen cells):

\documentclass[a4paper, 11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{fourier}%
\usepackage{heuristica}
\usepackage{geometry}

\usepackage{array}
\usepackage{caption}

\usepackage{tabularx}
\renewcommand{\tabularxcolumn}[1]{m{#1}}%
\newcolumntype{C}{>{\centering\arraybackslash}X}

\usepackage{cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}
\addparagraphcolumntypes{X}

\begin{document}

\begin{table}[h]
\caption {Methods Of Validation }
\begin{tabularx}{\linewidth}{|l|S{X}|}
\hline
Validation Example & Explanation \\
\hline
Unit Testing & The testing of a single program\\
\hline
Integration Testing & The testing of related Program or units of code. Validates that multiple parts of the system interact according to the system design. \\
\hline
System Testing & The testing of an entire system \\
\hline
Acceptance Testing & The testing the mobile app to make sure it Works as what the system requirements indicate \\
\hline
\end{tabularx}
\end{table}

\end{document} 

enter image description here

share|improve this answer
    
Thank you very much for the help Bernard.But it had some problem with cellspace package. But without using packages i successfully could get the result. –  user54172 Jun 7 at 11:34
    
I happens that cellspace conflicts/doesn't work well with some other packages. My code alone should work (it does on my system). The makecell package can do almost the same thing, unfortunately, it seems to have a problem with tabularx. As a last resort you can use \renewcommand\arraystretch{1.25}, but lines of text are no more centred in the cell they belong to. –  Bernard Jun 7 at 11:55
add comment

Without any extra packages:

\documentclass{article}

\begin{document}

\begin{table}[h]
\caption {Methods Of Validation }
\begin{tabular}{|p{\dimexpr0.3\linewidth-2\tabcolsep-\arrayrulewidth\relax}|
                 p{\dimexpr0.7\linewidth-2\tabcolsep-2\arrayrulewidth\relax}|}
\hline
Validation Example & Explanation \\
\hline
Unit Testing & The testing of a single program\\
\hline
Integration Testing & The testing of related Program or units of code. Validates that multiple parts of the system interact according to the system design. \\
\hline
System Testing & The testing of an entire system \\
\hline
Acceptance Testing & The testing the mobile app to make sure it Works as what the system requirements indicate \\
\hline
\end{tabular}
\end{table}

\end{document}

enter image description here

share|improve this answer
    
Idea is to avoid using tabularx unless it is very necessary. –  Harish Kumar Jun 7 at 11:26
    
Thanks a lot Harish.. It worked.. –  user54172 Jun 7 at 11:35
add comment

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.