表格的线条和定位

表格的线条和定位

我需要创建这个表

在此处输入图片描述

这是我目前所做的

\begin{table}[h!]
  \begin{center}
    \begin{tabular}{|l|c|r|} % <-- Alignments: 1st column left, 2nd middle and 3rd right, with vertical lines in between
    \hline
      \textbf{Category} & \textbf{Tool}\\ \hline
      $ $ & Command & Description \\
      \hline
      Editor & emacs & Emacs extensible text editor\\
       & vi & Visual editor\\\hline
      Scripting & bash & GNU Bourne-Again SHell\\
       & perl & Practical Extraction and Report Language\\\hline
       Document & rcs & Revision Control System\\
       Management & \LaTeX & Document Typesetting Package\\
        & make & Managing Project Utility\\\hline
    \end{tabular}
     \caption{Some Unix Utilities}
    \label{tab:table1}
  \end{center}
\end{table}

但我不确定如何在表格中正确定位文本,以及如何使第一行的线条与图片中显示的一致。

答案1

就这样

\documentclass{article}
\usepackage{array}
\begin{document}
\begin{table}[h!]
  \centering
    \begin{tabular}{|l|>{\ttfamily}r|l|} % <-- Alignments: 1st column left, 2nd middle and 3rd right, with vertical lines in between
    % No, your alignments are wrong :)
    \hline
      Category & \multicolumn{2}{c|}{Tool}\\ \cline{2-3}
      & \normalfont Command & Description \\
      \hline
      Editor & emacs & Emacs extensible text editor\\
       & vi & Visual editor\\\hline
      Scripting & bash & GNU Bourne-Again SHell\\
       & perl & Practical Extraction and Report Language\\\hline
       Document & rcs & Revision Control System\\
       Management & \LaTeX & Document Typesetting Package\\
        & make & Managing Project Utility\\\hline
    \end{tabular}
     \caption{Some Unix Utilities}
    \label{tab:table1}
\end{table}
\end{document}

在此处输入图片描述

不过,我认为你应该使用booktabs包来获得更好看的表格。例如:

\documentclass{article}
\usepackage{array}
\usepackage{booktabs}
\begin{document}
\begin{table}[h!]
  \centering
    \begin{tabular}{@{}l@{}>{\ttfamily}rl@{}} 
    \toprule
      Category & \multicolumn{2}{c}{Tool}\\ \cmidrule{2-3}
      & \normalfont Command & Description \\
      \midrule
      Editor & emacs & Emacs extensible text editor\\
       & vi & Visual editor\\
      \midrule
      Scripting & bash & GNU Bourne-Again SHell\\
       & perl & Practical Extraction and Report Language\\
      \midrule
       Document & rcs & Revision Control System\\
       Management & \LaTeX & Document Typesetting Package\\
        & make & Managing Project Utility\\
      \bottomrule
    \end{tabular}
     \caption{Some Unix Utilities}
    \label{tab:table1}
\end{table}
\end{document}

在此处输入图片描述

相关内容