如何在 LaTeX 中格式化没有垂直分隔线并且顶部带有标题的表格?

如何在 LaTeX 中格式化没有垂直分隔线并且顶部带有标题的表格?

对于我正在处理的课堂笔记,我喜欢将表格标题放在顶部而不是底部,并且表格输出没有分隔线。所需模型以图像形式附上。我处理了表格,但结果与所需的表格模型不匹配。

我将我的 LaTeX 代码和所需模型作为图像附上。

非常感谢您的帮助!谢谢!

\documentclass[11pt]{report}

\begin{document}

\begin{table}

\centering

\begin{tabular}{|c|p{6cm}|c|p{6cm}|}
\hline
& Transfer function approach & & State variable approach \\ \hline 
1. & The transfer function approach is also called the conventional approach or classical approach & 1. 
& The state variable approach is called the modern approach. \\ \hline
2. & It is based on the input-output relationship or transfer function. & 2. &
It is based on the description of a linear system of $n$ first-order differential equations which is
called as a state model.  \\ \hline
\end{tabular}
\caption{Transfer function approach versus the state variable approach}
\end{table}

\end{document}

所需的表格模型如下。

表模型

答案1

以下是一些建议(无特定顺序):

  • 如果您希望标题位于表格内容之前而不是之后,只需将\caption指令而不是tabular环境之后。

  • 如果您不想要垂直线,请不要|在表格环境的参数中使用粒子。

  • 为了保证表格材料适合文本块,请勿使用p固定宽度的列类型。相反,加载表格型打包并使用tabularx环境而不是tabular环境并将其所需宽度设置为\textwidth。(附言:X-type 列只不过是p-type 列,LaTeX 已为您完成了宽度参数的计算工作。)

  • >{\RaggedRight}X可选:通过使用而不是仅仅 来暂停第 2 列和第 4 列的完全对齐X

  • 可选:对于间距适当的水平线,不要使用\hline。相反,请加载书签包装并使用\toprule\midrule\bottomrule\addlinespace

在此处输入图片描述

\documentclass[11pt]{report}

\usepackage{tabularx} % for 'tabularx' env. and 'X' col. type
\usepackage{ragged2e} % for '\RaggedRight' macro
\newcolumntype{L}{>{\RaggedRight}X}
\usepackage{booktabs} % for well-spaced horizontal lines
\usepackage[skip=0.333\baselineskip]{caption} % optional

\begin{document}

\begin{table}
\caption{Transfer function approach versus state variable approach}
%% '@{}' particles suppress whitespace padding at both edges
\begin{tabularx}{\textwidth}{@{} *{2}{ r @{\hspace{6pt}} L } @{}}
\toprule
& \itshape Transfer function approach & & \itshape State variable approach \\ 
\midrule 
1. & The transfer function approach is also called the conventional approach or classical approach & 
1. & The state variable approach is called the modern approach. \\ 
\addlinespace
2. & It is based on the input-output relationship or transfer function. & 
2. & It is based on the description of a linear system of $n$ first-order differential equations which is called as a state model.  \\
\bottomrule
\end{tabularx}
\end{table}

\end{document}

相关内容