LaTeX 中的垂直线(表格与 pgfplotstabletypeset)

LaTeX 中的垂直线(表格与 pgfplotstabletypeset)

为什么这两个表没有相同的垂直线?

\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}

我也尝试过\renewcommand{\arraystretch}{0.8}修复{\setlength{\extrarowheight}{10pt}%第二张表,但是没有成功。

答案1

当与垂直分隔符一起使用时,会\hline进行内部调整,以便与垂直线相符。

booktabs 试图阻止垂直线,因此没有义务与垂直分隔符配合良好。但如果您\hline在其中发出pgfplotstable,则它们变得相同。

通常的警告也适用于此:双字母字体样式命令 (\bf,\it,...) 会在 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}

在此处输入图片描述

相关内容