4

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

4
  • 1
    A general remark about your code: Never encase a figure or table float in a center environment`.
    – Mico
    Nov 7, 2021 at 7:08
  • 1
    @NodeJS how did you manage the extra spacing in between the sentences -- No fixed-point loop. (extra spacing here)Visit has to evaluate only once
    – js bibra
    Nov 7, 2021 at 7:55
  • @jsbibra I'm not sure how to solve that
    – Node.JS
    Nov 7, 2021 at 9:29
  • Unrelated, but never use \pagenumbering{gobble}.
    – egreg
    Nov 7, 2021 at 11:33

3 Answers 3

6

\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

6
  • Thank you so much for the answe. Is it common to have an upside-down question mark?
    – Node.JS
    Nov 7, 2021 at 0:54
  • 1
    @Node.JS Ignore that. I had a wrong symbol in my editor (copy and paste mistake). Nov 7, 2021 at 0:55
  • Awesome. Thank you so much.
    – Node.JS
    Nov 7, 2021 at 0:55
  • @Node.JS I go offline now. Good luck (tables are no fun in LaTeX, I know the pain). Nov 7, 2021 at 0:57
  • 1
    Actually the center environment does not center the table environment`; it may only add vertical space somewhere.
    – egreg
    Nov 7, 2021 at 11:34
4

You could use \centering in the cells of the first row, with the caveat that you need \tabularnewline in order to end it.

Don't enclose table inside center: you'd only get vertical space somewhere, not necessarily around the table.

I also add a different rendering of the table, without vertical rules and with less repetitions.

\documentclass{article}
\usepackage[a4paper, total={6in, 8in}]{geometry}

\usepackage{booktabs} % for the second rendering

\begin{document}

\begin{table}[htp]
\centering

\begin{tabular}{|p{0.4\linewidth} | p{0.5\linewidth}|}
\hline
\centering Visit Type & \centering Fixed-Point Loop? \tabularnewline
\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}

\begin{table}[htp]
\centering

\begin{tabular}{@{} l p{0.6\linewidth} @{}}
\toprule
Visit Type & \centering Fixed-Point Loop? \tabularnewline
\midrule
Circular in circular &
  No fixed-point loop. Since the parent visit repeats the evaluation,
  its loop includes the child visit as well. \\
\addlinespace
Non-circular in circular &
  No fixed-point loop. Visit has to evaluate only once. \\
\addlinespace
Non-circular in non-circular &
  No fixed-point loop. Visit has to evaluate only once. \\
\addlinespace
Circular in non-circular &
  Needs fixed-point loop. \\
\bottomrule
\end{tabular}

\caption{Case-by-case analysis of loop requirement in CRAG visit sequence evaluator}

\end{table}

\end{document}

enter image description here

2

You may try to use tabularray package. Use it is simple to define styles of the first row (containing columns headers) and lines styles. Below are two examples /similar as is in the @egreg answer (+1)/:

\documentclass{article}
\usepackage[a4paper, total={6in, 8in}]{geometry}
\usepackage{tabularray} 

\begin{document}

    \begin{table}[htp]
    \centering
\begin{tblr}{hline{1,Z}=1pt, hline{2}=0.6pt, hline{3-Y}={solid},   
             vlines,
             colspec={Q[j,t, wd=0.4\linewidth] Q[j,t, wd=0.5\linewidth]},
             row{1} = {font=\bfseries, c}% content of cells in the first row 
                                         % are horizontal centered
             }
Visit Type  &   Fixed-Point Loop? \\
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. \\
Non-circular visit in circular visit 
            &   No fixed-point loop. Visit has to evaluate only once. \\
Non-circular visit in non-circular visit 
            &   No fixed-point loop. Visit has to evaluate only once. \\
Circular visit in non-circular visit 
            &   Needs fixed-point loop. \\
\end{tblr}
    \caption{Case-by-case analysis of loop requirement in CRAG visit sequence evaluator}
    \label{tab:?}
    \end{table}

    \begin{table}[htp]
    \centering
\begin{tblr}{hline{1,Z}=1pt, hline{2}=0.6pt, 
             colspec={@{} Q[j,t, wd=0.4\linewidth] Q[j,t, wd=0.5\linewidth] @{}},
             row{1} = {font=\bfseries, c},
             row{2-Y} = {belowsep+=3pt}
             }
Visit Type  &   Fixed-Point Loop? \\
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. \\
Non-circular visit in circular visit
            &   No fixed-point loop. Visit has to evaluate only once. \\
Non-circular visit in non-circular visit
            &   No fixed-point loop. Visit has to evaluate only once. \\
Circular visit in non-circular visit
            &   Needs fixed-point loop. \\
\end{tblr}
    \caption{Case-by-case analysis of loop requirement in CRAG visit sequence evaluator}
    \label{tab:??}
    \end{table}
\end{document}

enter image description here

BTW, captions for tables are usual above table.

You must log in to answer this question.

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