2

So I used Excel2latex to convert the following table into latex code:

enter image description here

The code produced (along with the environment to make a MWE) is:

\documentclass[11pt,a4paper]{article}
\usepackage[a4paper,hmargin={2.54cm,2.54cm},vmargin={3.17cm,3.17cm}]{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{mathrsfs}
\usepackage{amsthm}
\usepackage{tikz}
\usepackage{bm}
\usepackage{booktabs}

\begin{document}
% Table generated by Excel2LaTeX from sheet 'Sheet2'
\begin{table}[htbp]
  \centering
  \caption{Add caption}
    \begin{tabular}{|r|r|r|}
    \toprule
    Date  & open  & high \\
    \midrule
    2016-07-11 & 650.3800 & 651.9800 \\
    \midrule
    2016-07-12 & 651.2500 & 675.5000 \\
    \midrule
    2016-07-13 & 666.2500 & 671.4500 \\
    \midrule
    2016-07-14 & 655.3000 & 663.9900 \\
    \midrule
    2016-07-15 & 661.4000 & 669.9800 \\
    \midrule
    2016-07-18 & 680.0000 & 684.9400 \\
    \midrule
    2016-07-19 & 675.5100 & 676.8700 \\
    \bottomrule
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%

\end{document}

The output is:

enter image description here

with the vertical lines discontinued at every intersection with horizontal lines.

What I want is a table with unbroken, continuous vertical lines. What should I do? Thanks!

  • 1
    if you read the booktabs documentation the author makes it very clear that he considers vertical lines to be evil and that breaking them in booktabs is by design. Do not load booktabs and use standard latex \hline not \midrule if you want continuous lines – David Carlisle May 14 '18 at 13:38
  • @DavidCarlisle Thanks. That was what I thought initially, but it seems that the \midrules were produced by Excel2latex by default and this is unconfigurable.. – Vim May 14 '18 at 13:40
  • @DavidCarlisle Nevermind, the bookstabs package actually can be turned off. Just found out. – Vim May 14 '18 at 13:43
  • I do prefer the tables produced by booktabs. The question would be why excel2latex produces booktab commands but not a booktab recommended table. – Teepeemm May 14 '18 at 14:01
  • @Teepeemm there is actually a booktabs package checkbox on the Excel2latex panel. When unchecked, it produces the traditional \hline fashioned vertical lines. – Vim May 14 '18 at 14:32
2

booktabs discourages many horizontal lines, and strongly discourages vertical lines, to such an extant that it doesn't guarantee that vertical lines will work properly. The approach recommended by booktabs would be

\documentclass{article}
\usepackage{booktabs}

\begin{document}
% Table generated by Excel2LaTeX from sheet 'Sheet2'
\begin{table}[htbp]
  \centering
  \caption{Add caption}
    \begin{tabular}{rrr}
    \toprule
    Date  & open  & high \\
    \midrule
    2016-07-11 & 650.3800 & 651.9800 \\
    2016-07-12 & 651.2500 & 675.5000 \\
    2016-07-13 & 666.2500 & 671.4500 \\
    2016-07-14 & 655.3000 & 663.9900 \\
    2016-07-15 & 661.4000 & 669.9800 \\
    2016-07-18 & 680.0000 & 684.9400 \\
    2016-07-19 & 675.5100 & 676.8700 \\
    \bottomrule
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%

\end{document}

table output

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.