1

I have made a table in LaTeX. The image of the table is given below:

The code of the table is as follows:

\begin{table}[!ht]
\begin{center}
    \caption{Actors vs Positional Dynamicity (based on Closeness Centrality) in Different LSNs} \label{pos1}
    \begin{tabular}{|c||c| c| c| c| c|}  
        \hline

        Actor\\ No. & LSN 1 & LSN 2 & LSN 3 & ...  & LSN 60   \\ [0.5ex] 
        \hline\hline
        1 &0.205602  &0.262515  & 0.247979  &... & 0.170467  \\ 
        \hline
        2 &0.00961852  &0.0200901  & 0.0207746  &... & 0.107013 \\
        \hline
        3 &0.1271  & 0.170967 &  0.199928  &... &0.173208  \\
        \hline
        4 & 0.00263733 & 0.00524802 & 0.00787202  &... &0.0100803  \\
        \hline
        5 & 0.00300429 &0.00597824  &  0.00673418  &... & 0.00706005 \\ 
        \hline
        ... & ... & ... & ...   &...  .  &...    \\
        \hline
        1899 &0.00994494  &0.00968842  & 0.0216411   &...&0.0610909  \\
        \hline 
    \end{tabular}
\end{center}
\end{table}

Is there any way to properly fit the width of the column separator (marked in red in the image)?

0
1

You can use makecell, which allows for line breaks in cells, and hhline to have nicer intersection double lines, or use some colour in the table. Here are aretwo solutions:

\documentclass{article}
\usepackage{hhline}
\usepackage{makecell, caption, booktabs}
\usepackage{siunitx}
\usepackage[table, svgnames]{xcolor}
\colorlet{tbgcolour}{Gainsboro!70!Lavender!50! white}
\captionsetup{font=small}

\begin{document}

\begin{table}[!htb]
\centering\sisetup{table-format=1.8, table-number-alignment=center}
\setlength{\extrarowheight}{2.5pt}
    \caption{Actors vs Positional Dynamicity (based on Closeness Centrality) in Different LSNs} \label{pos1}
    \begin{tabular}{|c||*{3}{S|} c|S|}
        \hhline{-||-----|}
        \makecell{Actor\\ No. } & {LSN 1} & {LSN 2} & {LSN 3} & ... & {LSN 60} \\ [0.5ex]
        \hhline{=::=====}
        1 &0.205602 &0.262515 & 0.247979 &... & 0.170467 \\
        \hhline{-||-----|}
        2 &0.00961852 &0.0200901 & 0.0207746 &... & 0.107013 \\
        \hhline{-||-----|}
        3 &0.1271 & 0.170967 & 0.199928 &... &0.173208 \\
        \hhline{-||-----|}
        4 & 0.00263733 & 0.00524802 & 0.00787202 &... &0.0100803 \\
        \hhline{-||-----|}
        5 & 0.00300429 &0.00597824 & 0.00673418 &... & 0.00706005 \\
        \hhline{-||-----|}
        ... & ... & ... & ... &... . &... \\
        \hhline{-||-----|}
        1899 &0.00994494 &0.00968842 & 0.0216411 &...&0.0610909 \\
        \hhline{-||-----|}
    \end{tabular}
\end{table}

\begin{table}[!htb]
\centering\sisetup{table-format=1.8, table-number-alignment=center}
    \caption{Actors vs Positional Dynamicity (based on Closeness Centrality) in Different LSNs} \label{pos1}
\arrayrulecolor{DarkOrange!50}
\setlength{\arrayrulewidth}{0.6pt}
\setlength{\extrarowheight}{2.5pt}
    \begin{tabular}{>{\columncolor{tbgcolour}[\tabcolsep][\tabcolsep]}c!{\hspace{0.5ex}}*{3}{|S}|c|S|}%
\rowcolor{tbgcolour} \multicolumn{1}{c!{\color{white}\vrule width 4.4pt}}{\makecell{Actor\\ No.}} & \multicolumn{1}{!{\color{tbgcolour}\vrule\hspace{-2\arrayrulewidth}}c}{LSN 1} & \multicolumn{1}{c}{LSN 2} & \multicolumn{1}{c}{LSN 3} & \multicolumn{1}{c}{...} & \multicolumn{1}{c}{LSN 60} \\
\addlinespace[1ex]
        \cline{2-6}
        1 & 0.205602 &0.262515 & 0.247979 &... & 0.170467 \\
        \cline{2-6}
        2 & 0.00961852 &0.0200901 & 0.0207746 &... & 0.107013 \\
        \cline{2-6}
        3 & 0.1271 & 0.170967 & 0.199928 &... &0.173208 \\
       \cline{2-6}
        4 & 0.00263733 & 0.00524802 & 0.00787202 &... &0.0100803 \\
        \cline{2-6}
        5 & 0.00300429 &0.00597824 & 0.00673418 &... & 0.00706005 \\
        \cline{2-6}
        ... & ... & ... & ... &... . &... \\
        \cline{2-6}
        1899 & 0.00994494 &0.00968842 & 0.0216411 &...&0.0610909 \\
        \cline{2-6}
    \end{tabular}
\end{table}

\end{document} 

enter image description here

0

Please always provide a complete (but minimal) .tex file when asking questions like these.

Here are two methods:

\documentclass{article}  
\begin{document}
\begin{table}[!ht]
\begin{center}
    \begin{tabular}{|c||c| c| c| c| c|}
        \hline
        Actor &&&&&\\
        No. & LSN 1 & LSN 2 & LSN 3 & ...  & LSN 60   \\
        \hline\hline
        \shortstack{Actor\\ No.} & LSN 1 & LSN 2 & LSN 3 & ...  & LSN 60
        \\ [0.5ex]
        \hline\hline
        1 &0.205602  &0.262515  & 0.247979  &... & 0.170467  \\
        \hline
        2 &0.00961852  &0.0200901  & 0.0207746  &... & 0.107013 \\
        \hline
        3 &0.1271  & 0.170967 &  0.199928  &... &0.173208  \\
        \hline
        4 & 0.00263733 & 0.00524802 & 0.00787202  &... &0.0100803  \\
        \hline
        5 & 0.00300429 &0.00597824  &  0.00673418  &... & 0.00706005 \\
        \hline
        ... & ... & ... & ...   &...  .  &...    \\
        \hline
        1899 &0.00994494  &0.00968842  & 0.0216411   &...&0.0610909  \\
        \hline
    \end{tabular}
\end{center}
\end{table}
\end{document}

Personally, I would avoid this whole style of table and use something like the one given in answer to your other, nearly identical question.

6
  • You should \centering, not the center environment, which adds unwanted vertical spacing.
    – Bernard
    Feb 26 '17 at 11:13
  • @Bernard -- True. I only wrote this answer to address the specific question asked. It is CW because I do not want ownership of tables designed in this fashion and because his earlier question already has an answer that shows how to design a professional table for IEEEtran, which is where this will end up. (+1 for your answer, but it is inappropriate, in my view, for sober scholarly work.)
    – jon
    Feb 26 '17 at 15:08
  • I had not seen it was for an IEEEtran paper. That said, I think the first table I propose is quite sober. I agree the second is more for a book, although changing the rules colour to the same gray as the background is acceptable.
    – Bernard
    Feb 26 '17 at 15:20
  • @Bernard -- True enough, hence the +1 (though I fear I've fallen for Fear's rules and tend to turn up my nose at vertical rules in tables more than maybe is strictly necessary). In the right context, I'm certainly not opposed to a little colour in tables, and the coloured table in your answer would be nice in the right kind of book.
    – jon
    Feb 26 '17 at 15:35
  • I mostly agree with ‘no vertical rules’ in general, but there are exceptions (I've given some examples with just one vertical and one horizontal rules). I prefer in general some subdued fanciness in conceiving tables, if the context makes it possible. B.t.w. , ‘Fear's rules’ are not strictly Fear's, I fear ;o)
    – Bernard
    Feb 26 '17 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.