2

Why don't these 2 tables have identical vertical lines?

\documentclass{article}

\usepackage{array}
\usepackage{booktabs}
\usepackage{pgfplotstable}
\usepackage{pgfplots}

\begin{document}

\begin{table*}[!ht]
\begin{center}
  \begin{tabular}{||l||l||}
  \hline 
  \multicolumn{1}{||c||}{\bf Col 1} & \multicolumn{1}{c||}{\bf Col 2}\\
  \hline\hline
  Red   & One   \\ \hline
  Green & Two   \\ \hline
  Blue  & Three \\ \hline
  \end{tabular}
\end{center}
\caption{Correct vertical lines for my document}
\end{table*}

\bigskip

\begin{table*}[!ht]
\begin{center}
\pgfplotstabletypeset
  [col sep=&,
  columns/Col 1/.style={
    string type,
    column name={\bf Col 1},
    column type=||l||},
  columns/Col 2/.style={
    string type,
    column name={\bf Col 2},
    column type=l||},
  every head row/.style={
    before row={\toprule},
    after row={\midrule},
  },
  every odd row/.style={after row=\midrule},
  every even row/.style={after row=\midrule},
  every last row/.style={after row=\bottomrule} % rule at bottom
  ]
  {
  Col 1 & Col 2
  Red   & One
  Green & Two
  Blue  & Three
  }
\end{center}
\caption{Incorrect vertical lines for my document}
\label{tab:code}
\end{table*}

\end{document}

I have also tried \renewcommand{\arraystretch}{0.8} and {\setlength{\extrarowheight}{10pt}% to fix the second table but with no luck.

3

The \hline is adjusted internally such that it meets the vertical lines when used with the vertical seperators.

booktabs tries to discourage the vertical lines and hence has no obligation to play nice with the vertical separators. But if you issue \hline within pgfplotstable then they become the same.

And the usual warning applies here : Will two-letter font style commands (\bf , \it , …) ever be resurrected in LaTeX?

\documentclass{article}

\usepackage{array}
\usepackage{booktabs}
\usepackage{pgfplotstable}
\usepackage{pgfplots}

\begin{document}

\begin{table*}[!ht]
\begin{center}
  \begin{tabular}{||l||l||}
  \hline 
  \multicolumn{1}{||c||}{\textbf{Col 1}} & \multicolumn{1}{c||}{\textbf{Col 2}}\\
  \hline\hline
  Red   & One   \\ \hline
  Green & Two   \\ \hline
  Blue  & Three \\ \hline
  \end{tabular}
\end{center}
\caption{Correct vertical lines for my document}
\end{table*}

\bigskip

\begin{table*}[!ht]
\begin{center}
\pgfplotstabletypeset
  [col sep=&,
  columns/Col 1/.style={
    string type,
    column name={\textbf{Col 1}},
    column type={||l||}},
  columns/Col 2/.style={
    string type,
    column name={\textbf{Col 2}},
    column type={l||}},
  every head row/.style={
    before row={\hline},
    after row={\hline\hline},
  },
  every odd row/.style={after row=\hline},
  every even row/.style={after row=\hline},
  every last row/.style={after row=\hline} % rule at bottom
  ]
  {
  Col 1 & Col 2
  Red   & One
  Green & Two
  Blue  & Three
  }
\end{center}
\caption{Incorrect vertical lines for my document}
\label{tab:code}
\end{table*}

\end{document}

enter image description here

  • Thank you for your answer and for fixing the two-letter font style commands in my code. – Rlearner Apr 13 '15 at 22:37

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.