Tables – Fix Table Center Alignment and Missing Borders

tables

This table has a few issues.

  • I used the \centering command to center align the first row of the table but it doesn't work and everything is left aligned

  • border on the top-right hand side of the table is missing some parts

  • Is there a way to minimize empty spaces between the rows?

Code:

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage[a4paper, total={6in, 8in}]{geometry}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{amsmath,amssymb}
\usepackage{amsthm}
\usepackage{mathrsfs}
\usepackage{cleveref}

\usepackage{tikz}
\usetikzlibrary{positioning,calc,arrows.meta}%arrows is deprecated

\usepackage{float}
\usepackage{framed}
\usepackage{blindtext}
\newfloat{infobox}{htbp}{lop}

\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]

\pagenumbering{gobble}
\begin{document}



\begin{center}
\begin{table}
\centering
\begin{tabular}{|p{0.4\linewidth} | p{0.5\linewidth}|}
\hline
Visit Type & Fixed-Point Loop?   \\ \\ 
\hline\hline
Circular visit inside of circular visit & No fixed-point loop. Since the parent visit repeats the evaluation, its loop includes the child visit as well.\\ \hline
Non-circular visit in circular visit & No fixed-point loop. Visit has to evaluate only once. \\ \hline
Non-circular visit in non-circular visit & No fixed-point loop. Visit has to evaluate only once. \\ \hline
Circular visit in non-circular visit & Needs fixed-point loop. \\ \hline
\end{tabular}\caption{case-by-case analysis of loop requirement in CRAG visit sequence evaluator}
\end{table}
\end{center}



\end{document}

enter image description here

Best Answer


\documentclass{article}
%\usepackage[utf8]{inputenc}

\begin{document}

\begin{table}
\centering
\begin{tabular}{|p{0.4\linewidth} | p{0.5\linewidth}|}
\hline
% https://tex.stackexchange.com/questions/33486
\multicolumn{1}{|c|}{Visit Type} & \multicolumn{1}{c|}{Fixed-Point Loop?}   \\ 
\hline\hline
Circular visit inside of circular visit & No fixed-point loop. Since the parent visit repeats the evaluation, its loop includes the child visit as well.\\ \hline
Non-circular visit in circular visit & No fixed-point loop. Visit has to evaluate only once. \\ \hline
Non-circular visit in non-circular visit & No fixed-point loop. Visit has to evaluate only once. \\ \hline
Circular visit in non-circular visit & Needs fixed-point loop. \\ \hline
\end{tabular}\caption{case-by-case analysis of loop requirement in CRAG visit sequence evaluator}
\end{table}

\end{document}

enter image description here