3

I have several tables I'd like to align, but it comes out messed up. I'm using revtex4 for my general layout (two column), and I have this:

\begin{tabular}{|c||@{\hspace{12pt}} c @{\hspace{12pt}}|@{\hspace{13.95pt}} c @{\hspace{13.95pt}}|@{\hspace{13.95pt}} c @{\hspace{13.95pt}}|}   \hline
                    &$V(x)=x^2$&$V(x)=x^4$&$V(x)=x^8$\\ \hline
\textbf{\em $E_0$}  & 0.707103 & 0.667981 & 0.704039    \\ \hline
\textbf{\em $E_1$}  & 2.121301 & 2.393603 & 2.731454    \\ \hline 
\textbf{\em $E_2$}  & 3.535485 & 4.696656 & 5.883874    \\ \hline 
\textbf{\em $E_3$}  & 4.949665 & 7.335404 & 9.960179    \\ \hline 
\textbf{\em $E_4$}  & 6.363920 & 10.243682 & 14.821645  \\ \hline 
\textbf{\em $E_5$}  & 7.778728 & 13.378278 & 20.384956  \\ \hline 
\end{tabular}

\begin{tabular}{|c||@{\hspace{10pt}} c @{\hspace{10pt}}|@{\hspace{10pt}} c @{\hspace{10pt}}|@{\hspace{10pt}} c @{\hspace{10pt}}|}   \hline
                    &$V(x)=x^{20}$&$V(x)=x^{126}$&$V(x)=x^{150}$\\ \hline
\textbf{\em $E_0$}  & 0.830976 & 1.090953 & 1.107245    \\ \hline
\textbf{\em $E_1$}  & 3.311759 & 4.363576 & 4.428776    \\ \hline 
\textbf{\em $E_2$}  & 7.408376 & 9.817155 & 9.963977    \\ \hline 
\textbf{\em $E_3$}  & 13.071500 & 17.450506 & 17.711824 \\ \hline 
\textbf{\em $E_4$}  & 20.244628 & 27.261978 & 27.670885 \\ \hline 
\textbf{\em $E_5$}  & 28.871374 & 39.249456 & 39.839327 \\ \hline 
\end{tabular}

\begin{tabular}{|c||@{\hspace{10pt}} c @{\hspace{10pt}}|}   \hline
                    &$V(x)=x^{2p},p\to\infty$\\ \hline
\textbf{\em $E_0$}  & 1.233700  \\ \hline
\textbf{\em $E_1$}  & 4.934787  \\ \hline 
\textbf{\em $E_2$}  & 11.103227 \\ \hline 
\textbf{\em $E_3$}  & 19.738961 \\ \hline 
\textbf{\em $E_4$}  & 30.841909 \\ \hline 
\textbf{\em $E_5$}  & 44.411966 \\ \hline 
\end{tabular}\

which produces this:

tables1

And I have this:

\begin{tabular}{|@{\hspace{22pt}} c @{\hspace{22pt}}||@{\hspace{12pt}} c @{\hspace{12pt}}|@{\hspace{12pt}} c @{\hspace{12pt}}|} \hline
$V(x)=x^2$          & Numerički& Analitički\\ \hline
\textbf{\em $E_0$}  & 0.707103 & 0.5 \\ \hline
\textbf{\em $E_1$}  & 2.121301 & 1.5 \\ \hline 
\textbf{\em $E_2$}  & 3.535485 & 2.5 \\ \hline 
\textbf{\em $E_3$}  & 4.949665 & 3.5 \\ \hline 
\textbf{\em $E_4$}  & 6.363920 & 4.5\\ \hline 
\textbf{\em $E_5$}  & 7.778728 & 5.5\\ \hline 
\end{tabular}

\begin{tabular}{|c||@{\hspace{12pt}} c @{\hspace{12pt}}|@{\hspace{12pt}} c @{\hspace{12pt}}|}   \hline
$V(x)=x^{2p},p\to\infty$& Numerički& Analitički\\ \hline
\textbf{\em $E_0$}  & 1.233700  & 1.233700 \\ \hline
\textbf{\em $E_1$}  & 4.934787  & 4.934802 \\ \hline 
\textbf{\em $E_2$}  & 11.103227 & 11.103304 \\ \hline 
\textbf{\em $E_3$}  & 19.738961 & 19.739208 \\ \hline 
\textbf{\em $E_4$}  & 30.841909 & 30.842513 \\  \hline 
\textbf{\em $E_5$}  & 44.411966 & 44.413219 \\ \hline 
\end{tabular}\

Which gives me this:

tables2

I'd like to have aligned vertical lines. I tried putting the same values after {tabular}{...} but the text will overwrite this and stretch it : Any advice how to make this happen? I'd like it to be neat and to fit in one column...

lockstep
  • 250,273
dingo_d
  • 2,976
  • @dingo_d: As you want to correct the (horizontal!) alignment of vertical lines, the correct tag is {horizontal-alignment}. – lockstep Apr 23 '11 at 13:00
  • I'm kinda puzzled as to how can you horizontally align vertical lines O.o - I need || <- these kind of lines to be aligned... not --- this kind... I hope I'm clear on this :\ – dingo_d Apr 23 '11 at 13:14
  • @dingo: Yes, and you want to correct the horizontal position of these lines. – lockstep Apr 23 '11 at 13:16
  • As a complement to all this, you might want to follow the lead of many eminent typographers, and eliminate the vertical lines altogether... – Brent.Longborough Apr 23 '11 at 13:56
  • @ Brent.Longborough: Well I could do that, but it's a table for a seminar on quantum mechanics, I doubt that typography is that important there :D But I'll keep that in mind :D – dingo_d Apr 23 '11 at 15:51
  • 1
    @dingo_d: The little guy with obsessive-compulsive disorder who lives in the north-east corner of my brain tells me that "typography is important everywhere". Keep smiling... – Brent.Longborough Apr 23 '11 at 19:34

1 Answers1

4

For multiple tables with matching alignment, I'd rather use fixed-width columns. The standard p-columns are justified; see this question for details about centered p-columns (called y in my example).

\documentclass{revtex4}

\usepackage[utf8]{inputenc}

\usepackage{array}
\newcolumntype{y}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\renewcommand*{\arraystretch}{1.2}

\begin{document}

\begin{tabular}{|y{85pt}||y{65pt}|y{65pt}|} \hline
$V(x)=x^2$          & Numerički& Analitički\\ \hline
\textbf{\em $E_0$}  & 0.707103 & 0.5 \\ \hline
\textbf{\em $E_1$}  & 2.121301 & 1.5 \\ \hline 
\textbf{\em $E_2$}  & 3.535485 & 2.5 \\ \hline 
\textbf{\em $E_3$}  & 4.949665 & 3.5 \\ \hline 
\textbf{\em $E_4$}  & 6.363920 & 4.5\\ \hline 
\textbf{\em $E_5$}  & 7.778728 & 5.5\\ \hline 
\end{tabular}

\begin{tabular}{|y{85pt}||y{65pt}|y{65pt}|}   \hline
$V(x)=x^{2p},p\to\infty$& Numerički& Analitički\\ \hline
\textbf{\em $E_0$}  & 1.233700  & 1.233700 \\ \hline
\textbf{\em $E_1$}  & 4.934787  & 4.934802 \\ \hline 
\textbf{\em $E_2$}  & 11.103227 & 11.103304 \\ \hline 
\textbf{\em $E_3$}  & 19.738961 & 19.739208 \\ \hline 
\textbf{\em $E_4$}  & 30.841909 & 30.842513 \\  \hline 
\textbf{\em $E_5$}  & 44.411966 & 44.413219 \\ \hline 
\end{tabular}

\end{document}

enter image description here

lockstep
  • 250,273