0

I have suddenly faced the following problem: the top right part of the frame isn't closed. How can I fixed it? Here are screenshot and my tex code for the frame. If it is necessary I will provide extra info such as preamble and so on. Thanks in advance.

table frame

\begin{center}
\begin{tabular}{|p{6cm}|p{6cm}|}
  \hline
  \multicolumn{2}{|c|}{Numerical computer experiment results}\\
  \hline\\
  \centerline{$h_{0,\{2\}}^o=h_{1,\{2\}}^o=1/2$} & \centerline{$h_{0,\{2\}}=h_{1,\{2\}}=1/2$}\\
  \centerline{$h_{0,\{3\}}^o=1$} & \centerline{$h_{0,\{3\}}=1$}\\
  \centerline{$h_{0,\{4\}}^o=4$} & \centerline{$h_{0,\{4\}}=4$}\\
  \centerline{$h_{0,\{5\}}^o=25$} & \centerline{$h_{0,\{5\}}=25$}\\
  \centerline{$h_{0,\{2,2\}}^o=13$} & \centerline{$h_{0,\{2,2\}}=12$}\\
  \centerline{$h_{0,\{3,2\}}^o=487/2$} & \centerline{$h_{0,\{3,2\}}=216$}\\
  \centerline{$h_{0,\{4,2\}}^o=3080$} & \centerline{$h_{0,\{4,2\}}=2560$}\\
  \centerline{$h_{1,\{3\}}^o=9$} & \centerline{$h_{1,\{3\}}=9$}\\
  \centerline{$h_{1,\{4\}}^o=160$} & \centerline{$h_{1,\{4\}}=160$}\\
  \centerline{$h_{1,\{5\}}^o=3125$} & \centerline{$h_{1,\{5\}}=3125$}\\
  \centerline{$h_{1,\{2,2\}}^o=484$} & \centerline{$h_{1,\{2,2\}}=480$}\\
  \centerline{$h_{1,\{3,2\}}^o=53823/2$} & \centerline{$h_{1,\{3,2\}}=26460$}\\
  \hline
\end{tabular}
\end{center}
3
  • 2
    Remove the \\ after the second \hline May 29, 2017 at 15:06
  • @HerbSchulz, thanks, it fixed it. But now the top line (with data) is straight under the horizontal frame line. I want all lines (including upper and lower) have the same indent. How can I do it without \\?
    – Hasek
    May 29, 2017 at 15:13
  • 1
    You can try something like \rule{0pt}{12pt} plafed in the top item and adjust the 12pt so it looks correct to you. May 29, 2017 at 15:30

1 Answer 1

7

Even if they are empty you need to write all columns to get the vertical lines. That is, add & after the second \hline to get \hline&\\. That gives the start of your tabular as

\begin{tabular}{|p{6cm}|p{6cm}|}
  \hline
  \multicolumn{2}{|c|}{Numerical computer experiment results}\\
  \hline&\\
  \centerline{$h_{0,\{2\}}^o=h_{1,\{2\}}^o=1/2$} & \centerline{$h_{0,\{2\}}=h_{1,\{2\}}=1/2$}\\

However, since you are using mostly math you can insted use array, which is roughly a tabular in math mode. Then with the array package you can specify a p{} like column that is centered, in case for math mode. I also had to stretch the rows a bit using \arraystretch (in the question that was done by the \centerline).

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
 \newcolumntype{C}[1]{>{\centering\arraybackslash$}p{#1}<{$}}
\begin{document}
\begin{displaymath}
  \renewcommand{\arraystretch}{1.5}
  \begin{array}{|C{6cm}|C{6cm}|}
    \hline
    \multicolumn{2}{|c|}{\text{Numerical computer experiment results}}\\
    \hline
    h_{0,\{2\}}^o=h_{1,\{2\}}^o=1/2 & h_{0,\{2\}}=h_{1,\{2\}}=1/2\\
    h_{0,\{3\}}^o=1         & h_{0,\{3\}}=1\\
    h_{0,\{4\}}^o=4         & h_{0,\{4\}}=4\\
    h_{0,\{5\}}^o=25        & h_{0,\{5\}}=25\\
    h_{0,\{2,2\}}^o=13      & h_{0,\{2,2\}}=12\\
    h_{0,\{3,2\}}^o=487/2   & h_{0,\{3,2\}}=216\\
    h_{0,\{4,2\}}^o=3080    & h_{0,\{4,2\}}=2560\\
    h_{1,\{3\}}^o=9         & h_{1,\{3\}}=9\\
    h_{1,\{4\}}^o=160       & h_{1,\{4\}}=160\\
    h_{1,\{5\}}^o=3125      & h_{1,\{5\}}=3125\\
    h_{1,\{2,2\}}^o=484     & h_{1,\{2,2\}}=480\\
    h_{1,\{3,2\}}^o=53823/2 & h_{1,\{3,2\}}=26460\\
    \hline
  \end{array}
\end{displaymath}
\end{document}

enter image description here

As a final remark, it is often recommended to not use vertical lines and make use of the booktabs package for horisontal lines:

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
 \newcolumntype{C}[1]{>{\centering\arraybackslash$}p{#1}<{$}}
\usepackage{booktabs}
\begin{document}
\begin{displaymath}
  \renewcommand{\arraystretch}{1.5}
  \begin{array}{C{6cm}C{6cm}}
    \toprule
    \multicolumn{2}{c}{\text{Numerical computer experiment results}}\\
    \midrule
    h_{0,\{2\}}^o=h_{1,\{2\}}^o=1/2 & h_{0,\{2\}}=h_{1,\{2\}}=1/2\\
    h_{0,\{3\}}^o=1         & h_{0,\{3\}}=1\\
    h_{0,\{4\}}^o=4         & h_{0,\{4\}}=4\\
    h_{0,\{5\}}^o=25        & h_{0,\{5\}}=25\\
    h_{0,\{2,2\}}^o=13      & h_{0,\{2,2\}}=12\\
    h_{0,\{3,2\}}^o=487/2   & h_{0,\{3,2\}}=216\\
    h_{0,\{4,2\}}^o=3080    & h_{0,\{4,2\}}=2560\\
    h_{1,\{3\}}^o=9         & h_{1,\{3\}}=9\\
    h_{1,\{4\}}^o=160       & h_{1,\{4\}}=160\\
    h_{1,\{5\}}^o=3125      & h_{1,\{5\}}=3125\\
    h_{1,\{2,2\}}^o=484     & h_{1,\{2,2\}}=480\\
    h_{1,\{3,2\}}^o=53823/2 & h_{1,\{3,2\}}=26460\\
    \bottomrule
  \end{array}
\end{displaymath}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .