如何在表格环境上方和下方插入垂直空白

如何在表格环境上方和下方插入垂直空白

tabular在文本中间使用了,但文本内部表格周围的(垂直)空间很小。如何增加此表格的边距(表格水平线与前后段落之间的距离)?

some text....

\centering
\begin {tabular} {| c  c   c  c |}
\hline
$\tilde {d}$ text & $ein \downarrow$ & $ dvc \uparrow $ \\
$\tilde {d}$ text & text & $ein \uparrow$ & $ dvc \downarrow $ \\
\hline
\end {tabular}

some text ....

答案1

这里,环境center是有意义的,因为它增加了空间:

\begin{center}
  \begin{tabular}{...}
  ...
  \end{tabular}
\end{center}

更精美的线条可用包装booktabs

\usepackage{booktabs}
...
\begin{center}
  \begin{tabular}{...}
    \toprule
    ...
    \bottomrule
  \end{tabular}
\end{center}

完整示例:

\documentclass{article}
\usepackage{booktabs}
\usepackage{lipsum}

\begin{document}
\lipsum[2]
\begin{center}
  \begin{tabular}{l}
    \toprule
     First tabular line\\
     Second tabular line\\
    \bottomrule
  \end{tabular}
\end{center}
\lipsum[3]
\end{document}

结果

答案2

我可以提出两个建议

  • 将环境嵌入到环境tabularcenter(并省略\centering指令),或

  • tabular将环境与指令一起嵌入到环境\centeringtable,注意添加[h!]定位说明符,以免环境“浮动”得太远。这种方法可能更可取,因为它可以直接指定\caption

在此处输入图片描述

\documentclass{article}

\newcommand\ein{ein} % dummy definitions to make the code compilable
\newcommand\dvc{dvc}

\begin{document}

some text\dots

\begin{center}
\begin {tabular} {|cccc|}
\hline
$\tilde {d}$ text & $\ein \downarrow$ & $ \dvc \uparrow $ & \\
$\tilde {d}$ text & text & $\ein \uparrow$ & $ \dvc \downarrow $ \\
\hline
\end {tabular}
\end{center}

some text \dots

\begin{table}[h!]
\centering
\begin {tabular} {| c  c   c  c |}
\hline
$\tilde {d}$ text & $\ein \downarrow$ & $ \dvc \uparrow $ & \\
$\tilde {d}$ text & text & $\ein \uparrow$ & $ \dvc \downarrow $ \\
\hline
\end {tabular}
\end{table}

some text \dots
\end{document}

答案3

cellspace包定义最小在带有以字母为前缀的说明符的列中,单元格顶部和底部的垂直填充S(或者C如果您使用siunitx):

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{array, cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}

\begin{document}

some text....

\begin{center}
  \begin {tabular} {|*{4}{Sc} |}
  \hline
  $\tilde {d}$ text & $ein \downarrow$ & $ dvc \uparrow $ & \\
  $\tilde {d}$ text & text & $ein \uparrow$ & $ dvc \downarrow $ \\
  \hline
  \end {tabular}
\end{center}
some text ..

\end{document} 

在此处输入图片描述

相关内容