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.

. . alt text

\usepackage{tabularx}
\usepackage{multicol}

\begin{table}[ht]
\begin{minipage}[b]{0.5\linewidth}%\centering
\begin{tabular}{|c|c|c|c|}
\hline
    & One & Twp & Three \\
 \hline
1 & Subject A: & Subject A & Subject  \\
2 & Subject B & Subject B& Subject  \\
3 & Subject C & Subject C & Subject   \\
4 & Subject D & Subject D & Subject  \\
4 & Subject E & Subject E & Subject   \\
5 &Subject F & Subject F & Subject  \\
6 & Subject G & Subject G & Subject  \\
7 &Subject H &Subject H &Subject   \\
\hline
\end{tabular}
\caption{Table 1}
\end{minipage}
\hspace{0.5cm}
\begin{minipage}[b]{0.5\linewidth}
\centering
\begin{tabular}{|c|c|c|c|}
\hline
    & One & Twp & Three \\
 \hline
1 & Subject A: & Subject A & Subject  \\
2 & Subject B & Subject B& Subject  \\
3 & Subject C & Subject C & Subject   \\
4 & Subject D & Subject D & Subject  \\
4 & Subject E & Subject E & Subject   \\
5 &Subject F & Subject F & Subject  \\
6 & Subject G & Subject G & Subject  \\
7 &Subject H &Subject H &Subject   \\
\hline
\end{tabular}
\caption{Table 2}
\end{minipage}
\end{table}

I am trying to create two tables side by side and in the PDF they do not appear aligned. Second table is slightly lower than the first one, I have no clue how to fix it. Any suggestion would be greatly appreciated. thanks Aku

share|improve this question

3 Answers 3

up vote 3 down vote accepted

Try this:

\documentclass{article}
\usepackage{tabularx}
\usepackage{multicol}

\begin{document}
\begin{table}[ht]
\begin{minipage}[b]{0.5\linewidth}%\centering
\begin{tabular}{|c|c|c|c|}
\hline
    & One & Twp & Three \\
\hline
1 & Subject A: & Subject A & Subject  \\
2 & Subject B & Subject B& Subject  \\
3 & Subject C & Subject C & Subject   \\
4 & Subject D & Subject D & Subject  \\
4 & Subject E & Subject E & Subject   \\
5 &Subject F & Subject F & Subject  \\
6 & Subject G & Subject G & Subject  \\
7 &Subject H &Subject H &Subject   \\
\hline
\end{tabular}
\caption{Table 1}
\end{minipage}
\hspace{0.5cm}
\begin{minipage}[b]{0.5\linewidth}
\centering
\begin{tabular}{|c|c|c|c|}
\hline
    & One & Twp & Three \\
 \hline
1 & Subject A: & Subject A & Subject  \\
2 & Subject B & Subject B& Subject  \\
3 & Subject C & Subject C & Subject   \\
4 & Subject D & Subject D & Subject  \\
4 & Subject E & Subject E & Subject   \\
5 &Subject F & Subject F & Subject  \\
6 & Subject G & Subject G & Subject  \\
7 &Subject H &Subject H &Subject   \\
\hline
\end{tabular}
\caption{Table 2}
\end{minipage}
\end{table}

\end{document}
share|improve this answer
2  
I just came across this question while retagging. Could you tell me what the difference between your solution and Aku's original code is? I can't find one (except for the added \documentclass and {document}). –  Caramdir Mar 3 '11 at 19:17
    
@Caramdir don't really remember if there was a marginal difference. Looking at TH's answer also it was just working code, so I probably just created the minimal or the OP edited the question? –  Yiannis Lazarides Mar 3 '11 at 19:46

Problems:

  • Your tables exceed the text width, because you use two times 0.5\linewidth plus \hspace{0.5cm}. This can cause alignment problems and is problematic in general.

  • You align minipages at the bottom, using [b], not at the top. I guess that's because of the caption, but this way you don't control the top.

I suggest:

  • Always take care of the line width resp. text width. Note: also line breaks or blanks between minipages count and require space. Insert % before an end of the line to prevent that.

  • Use the optional height argument of minipage or \parbox. You could use a fixed height, top alignment (below pos, inner-pos), perhaps \vfill to achieve alignment at top and bottom (captions).

    Syntax: \begin{minipage}[pos][height][inner-pos]{width}

  • Further tip: vertical lines are really distracting. For me, some horizontal lines are usually fine. I strongly recommend to use the booktabs package. Just look into good books to see for yourself that fine tables don't interrupt rows by vertical lines.

share|improve this answer
    
All good advice! –  TH. Dec 21 '10 at 14:47

This seems to work just fine.

\documentclass{article}
\usepackage{fullpage}
\begin{document}
\begin{table}
\noindent
\parbox{.5\textwidth}{%
\centering
\begin{tabular}{|c|c|c|c|}
\hline
    & One & Twp & Three \\
 \hline
1 & Subject A: & Subject A & Subject  \\
2 & Subject B & Subject B& Subject  \\
3 & Subject C & Subject C & Subject   \\
4 & Subject D & Subject D & Subject  \\
4 & Subject E & Subject E & Subject   \\
5 &Subject F & Subject F & Subject  \\
6 & Subject G & Subject G & Subject  \\
7 &Subject H &Subject H &Subject   \\
\hline
\end{tabular}
\caption{Table 1}
}%
\parbox{.5\textwidth}{%
\centering
\begin{tabular}{|c|c|c|c|}
\hline
    & One & Twp & Three \\
 \hline
1 & Subject A: & Subject A & Subject  \\
2 & Subject B & Subject B& Subject  \\
3 & Subject C & Subject C & Subject   \\
4 & Subject D & Subject D & Subject  \\
4 & Subject E & Subject E & Subject   \\
5 &Subject F & Subject F & Subject  \\
6 & Subject G & Subject G & Subject  \\
7 &Subject H &Subject H &Subject   \\
\hline
\end{tabular}
\caption{Table 2}
}%
\end{table}
\end{document}

This wasn't part of your question, but I think if you follow the advice given in the booktabs documentation, you can produce even better looking tables. Compare.

\documentclass{article}
\usepackage{fullpage}
\usepackage{booktabs}
\begin{document}
\begin{table}
\noindent
\parbox{.5\textwidth}{%
\centering
\begin{tabular}{rllll}
\toprule
    & \multicolumn{1}{c}{One}
    & \multicolumn{1}{c}{Two}
    & \multicolumn{1}{c}{Three} \\
\midrule
1 & Subject A: & Subject A & Subject  \\
2 & Subject B & Subject B& Subject  \\
3 & Subject C & Subject C & Subject   \\
4 & Subject D & Subject D & Subject  \\
4 & Subject E & Subject E & Subject   \\
5 &Subject F & Subject F & Subject  \\
6 & Subject G & Subject G & Subject  \\
7 &Subject H &Subject H &Subject   \\
\bottomrule
\end{tabular}
\caption{Table 1}
}%
\parbox{.5\textwidth}{%
\centering
\begin{tabular}{rllll}
\toprule
    & \multicolumn{1}{c}{One}
    & \multicolumn{1}{c}{Two}
    & \multicolumn{1}{c}{Three} \\
\midrule
1 & Subject A: & Subject A & Subject  \\
2 & Subject B & Subject B& Subject  \\
3 & Subject C & Subject C & Subject   \\
4 & Subject D & Subject D & Subject  \\
4 & Subject E & Subject E & Subject   \\
5 &Subject F & Subject F & Subject  \\
6 & Subject G & Subject G & Subject  \\
7 &Subject H &Subject H &Subject   \\
\bottomrule
\end{tabular}
\caption{Table 2}
}%
\end{table}
\end{document}
share|improve this answer

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.