1

I am using the below code for making a latex table. Unfortunately, when I compile the vertical line of last column is missing.

\documentclass{article}

\begin{document}
    \begin{table}[b!]
\centering
%\footnotesize
\caption{\label{tab:experiments_summary_1}
Summary of fiber experiments. }
\begin{tabular} {|c||c|c|c|*{1}{r@{\,}c@{\,}l|}}
\hline
Type & A
        & B
            & C
                & \multicolumn{3}{c|}{D} \\

\hline \hline
1 & 100 & 284198  & 1940876 & $7.6 \times 10^{-6}$ \\
\hline
2 & 100 & 265212  & 1882294 & $1.8 \times 10^{-6}$ \\
\hline
3 & 200 & 200194  & 1472625 & $7.1 \times 10^{-4}$ \\
\hline
4 & 200 & 40477  & 504115 & $4.6 \times 10^{-4}$ \\
\hline
5 & 300 & 36846  & 314694 & $7.2 \times 10^{-3}$ \\
\hline
6 & 315 & 359881  & 3852568 & $1.5 \times 10^{-3}$ \\
\hline
7 & 420 & 123026  & 1039820 & $5.8 \times 10^{-3}$ \\
\hline
\end{tabular}
\end{table}

    
\end{document}
8
  • you have not shown your source but presumably you omited the final | Oct 13, 2021 at 13:32
  • I have updated the question with code.
    – Subhani
    Oct 13, 2021 at 13:39
  • @Subhani It shows the last vertical line when I compiled it.
    – Imran
    Oct 13, 2021 at 13:43
  • 1
    I get this output but note that the table is too wide Overfull \hbox (63.88pt too wide) in paragraph at lines 9--34 you are perhaps just clipping the right edge of the table where it overflows the page. add \setlength\tabcolsep{2pt} after \footnotesize to squeeze it a bit Oct 13, 2021 at 13:43
  • 1
    that is why we always ask people to post a complete small document that is an example of the problem. Start from a copy of your full document, delete everything except the table, check the problem ocurs, then delete everything from the preamble that you can delete while still showing the error. Add the complete resulting document to your question. Oct 14, 2021 at 6:47

2 Answers 2

2

your D column is really implemented as three columns r@{\,}c@{\,}l (it isn't clear why?)

You only put your math data in the first of these columns so there is no | the final two columns are not used so the final | is never reached.

enter image description here

\documentclass{article}

\begin{document}
    \begin{table}[b!]
\centering
%\footnotesize
\caption{\label{tab:experiments_summary_1}
Summary of fiber experiments. }
\begin{tabular} {|c||c|c|c|c|}
\hline
Type & A
        & B
            & C
                & D \\

\hline \hline
1 & 100 & 284198  & 1940876 & $7.6 \times 10^{-6}$ \\
\hline
2 & 100 & 265212  & 1882294 & $1.8 \times 10^{-6}$ \\
\hline
3 & 200 & 200194  & 1472625 & $7.1 \times 10^{-4}$ \\
\hline
4 & 200 & 40477  & 504115 & $4.6 \times 10^{-4}$ \\
\hline
5 & 300 & 36846  & 314694 & $7.2 \times 10^{-3}$ \\
\hline
6 & 315 & 359881  & 3852568 & $1.5 \times 10^{-3}$ \\
\hline
7 & 420 & 123026  & 1039820 & $5.8 \times 10^{-3}$ \\
\hline
\end{tabular}
\end{table}

    
\end{document}
3
  • Thanks for the clarification. I was trying to align the contents of the last column with respect to "X" sign.
    – Subhani
    Oct 17, 2021 at 10:05
  • @Subhani so I guessed but then you would need input something like 5.8 & 10^{-3} and a two column preamble entry r@{$\times$}l| and use a \multicolumn{2} span for the D heading, that is, the number of cells in the body has to match the preamble Oct 17, 2021 at 10:08
  • Thanks, I did something more out of curiosity. I have tried to write the contents in columns B and C as multiples of 10^4 and 10^5. I used the same approach like you mentioned in the previous comment: \begin{tabular} {|c||c|*{3}{r@{$\times$}l|}}, and \multicolumn{2}{c|}{B}, \multicolumn{2}{c|}{C}. After compiling the elements in these columns are aligned to the left instead of being at the center.
    – Subhani
    Oct 17, 2021 at 12:58
0

Mostly off-topic suggestions (since your problem is solved by @DavidCarlise answer, +1):

I would use S column type in all column except the first, omit vertical lines and for table use (relative new) tabularray package.

\documentclass{article}
\usepackage[skip=1ex]{caption}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}
\ExplSyntaxOn
\NewChildSelector{eachtwo}
  {
    \int_step_inline:nnnn {2} {2} { \l_tblr_childs_total_tl }
      { \clist_put_right:Nn \l_tblr_childs_clist {##1} }
  }
\ExplSyntaxOff

\begin{document}
    \begin{table}[bt]
    \centering
    \caption{Summary of fiber experiments. }
    \label{tab:experiments_summary_1}
\begin{tblr}{hline{1,Z}=1pt, hline{2}=0.6pt, 
             colspec={c Q[c, si={table-format=3}] 
                        Q[c, si={table-format=6.0}]
                        Q[c, si={table-format=7.0}]
                        Q[c, si={table-format=1.1e2}]},
             row{2-Z}     = {rowsep=0pt},
             row{eachtwo} = {abovesep=5pt},
            } 
Type & {{{A}}}
        & {{{B}}}
            & {{{C}}}
                & {{{D}}} \\
% table body
1   & 100   & 284198    & 1940876   & 7.6e-6    \\
2   & 100   & 265212    & 1882294   & 1.8e-6    \\
3   & 200   & 200194    & 1472625   & 7.1e-4    \\
4   & 200   &  40477    &  504115   & 4.6e-4    \\
5   & 300   &  36846    &  314694   & 7.2e-3    \\
6   & 315   & 359881    & 3852568   & 1.5e-3    \\
7   & 420   & 123026    & 1039820   & 5.8e-3    \\
\end{tblr}
    \end{table}
\end{document}

Similar result can be get by use rules form booktabs package and use of standard tabular table:

\documentclass{article}
\usepackage[skip=1ex]{caption}
\usepackage{siunitx}
\usepackage{booktabs}

\begin{document}
    \begin{table}[bt]
    \centering
    \caption{Summary of fiber experiments. }
    \label{tab:experiments_summary_1}
\begin{tabular}{c S[table-format=3]
                  S[table-format=6.0]
                  S[table-format=7.0]
                  S[table-format=1.1e2]
                }
    \toprule
Type & {A}
        & {B}
            & {C}
                & {D} \\
    \midrule
% table body
1   & 100   & 284198    & 1940876   & 7.6e-6    \\
2   & 100   & 265212    & 1882294   & 1.8e-6    \\
    \addlinespace
3   & 200   & 200194    & 1472625   & 7.1e-4    \\
4   & 200   &  40477    &  504115   & 4.6e-4    \\
    \addlinespace
5   & 300   &  36846    &  314694   & 7.2e-3    \\
6   & 315   & 359881    & 3852568   & 1.5e-3    \\
    \addlinespace
7   & 420   & 123026    & 1039820   & 5.8e-3    \\
    \bottomrule
\end{tabular}
    \end{table}
\end{document}

Result of both example are almost the same:

enter image description here

3
  • Great, thank you :)
    – Subhani
    Oct 17, 2021 at 12:08
  • @Subhani, if answer is "great", than you can consider to upvote it :-)
    – Zarko
    Oct 17, 2021 at 12:34
  • I do not have enough reputation points to vote it. I will definitely do it in near future :)
    – Subhani
    Oct 17, 2021 at 12:59

You must log in to answer this question.

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