Tables do not align side by side
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 (belowpos
,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.
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}
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}