在表格的行间插入文本

在表格的行间插入文本

我正在尝试实现以下效果:

+------------+---------+
| Col1  Col2 |         |
+------------+---------+
| Value 1    | Value 2 |
| Value 3    | Value 4 |

Text goes here...

| Value 5    | Value 6 |
+------------+---------+

换句话说,我想在表格中插入文本,然后表格照常运行。到目前为止,我一直不知道如何实现这一点。

例如:

\begin{table}[ht]
  \centering
  \begin{tabular}{|l|l|}
    \hline
    \textbf{Branch instruction address} & \textbf{Next instruction address} \\ \hline
    \texttt{0xd4f30d2C} & \texttt{0xd4f30d60} \\ \hline
    \texttt{0xd4f30d0f} & \texttt{0xd4f30ddd} \\ \hline

    <Text goes here>     

    \texttt{0xd4f30c4f} & \texttt{0xd4f30d6c} \\ \hline
  \end{tabular}
\end{table}

答案1

谢谢芭芭拉·比顿的建议,我想到了这个:

\begin{table}[ht]
  \centering
  \begin{tabular}{|c|c|}
    \hline
    \textbf{Branch instruction address} & \textbf{Next instruction address} \\ \hline
    \texttt{0xd4f30d2C} & \texttt{0xd4f30d60} \\ \hline
    \texttt{0xd4f30d0f} & \texttt{0xd4f30ddd} \\ \hline
    \multicolumn{1}{c}{\vdots} & \multicolumn{1}{c}{\vdots\vspace{0.2em}}\\ \hline
    \texttt{0xd4f30c4f} & \texttt{0xd4f30d6c} \\ \hline
  \end{tabular}
\end{table}

输出结果如下:

在此处输入图片描述

答案2

不太确定您想要什么:行间文本应该是全页宽度还是仅表格宽度?无论如何,这里有三种方法可以为这两种情况提供解决方案。请注意,使用命令的垂直填充\makegapedcells在环境makecell中不起作用blockarray,也不起作用\extrarowheight,我不得不更改值\arraystretch+ 一些手动更正:

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{array, blkarray, makecell}
\usepackage{tabularx}
\setcellgapes{6pt}
  \renewcommand\cellalign{lc}

\begin{document}

\begin{table}[!h]
  \centering\makegapedcells
  \begin{tabular}{|c|c| }
    \hline
    Column 1 & Column 2
    \\
    \hline
    Value 1 & Value 2 \\
    Value 3 & Value 4 \\
    \multicolumn{2}{@{}l}{\makecell{Some text there…\\
    Some more text here…}}\\
    Value 5 & Value 6 \\
    \hline
  \end{tabular}
\end{table}
\vskip 3ex

\begin{table}[!h]
  \centering\makegapedcells
  \begin{tabularx}{\linewidth}{X|c|c| X}
    \cline{2-3}
      & Column 1 & Column 2 &
    \\
    \cline{2-3}
      & Value 1 & Value 2 & \\
      & Value 3 & Value 4 & \\
    \multicolumn{4}{@{}p{\linewidth}@{}}{%
    Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi. Morbi auctor lorem non justo.
    Nam lacus libero, pretium at, lobortis vitae, ultricies et, tellus. Donec aliquet, tortor sed accumsan
    bibendum, erat ligula aliquet magna, vitae ornare odio metus a mi. Morbi ac orci et nisl hendrerit
    mollis.} \\%
      & Value 5 & Value 6 & \\
    \cline{2-3}
  \end{tabularx}
\end{table}
\vskip 3ex

\begin{table}[!h]
\centering\renewcommand\arraystretch{1.667}
\begin{blockarray}{|c|c|}
        \BAhline
        Column 1 & Column 2
        \\
        \BAhline
        Value 1 & Value 2 \\
        Value 3 & Value 4 \\
\begin{block}{\BAmulticolumn{2}{@{}l@{}}}
\noalign{\vskip1.5ex}
\makecell{Some text there…\\
 Some more text here…}\\[1.5ex]
 \end{block}
        Value 5 & Value 6 \\
        \BAhline
\end{blockarray}
    \end{table}
    \vfill\mbox{}

\end{document}

在此处输入图片描述

相关内容