没有table环境

没有table环境

我有一堆桌子排列如下: 在此处输入图片描述

\documentclass{article}

\begin{document}
\begin{table}
\begin{minipage}[c][1\totalheight][t]{0.45\textwidth}%
\begin{center}
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline 
a & b & c & d & e & f & g & h\\ 
\hline 
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
\hline 
a & b & c & d & e & f & g & h\\
\hline 
\end{tabular}
\par\end{center}
\caption{Table \#1}

\begin{center}
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline 
a & b & c & d & e & f & g & h\\ 
\hline 
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
\hline 
a & b & c & d & e & f & g & h\\
\hline 
\end{tabular}%
\par\end{center}
\caption{Table \#2}
\end{minipage}\hfill{}%
\begin{minipage}[c][1\totalheight][t]{0.45\textwidth}%

\begin{center}
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline 
a & b & c & d & e & f & g & h\\ 
\hline 
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
\hline 
a & b & c & d & e & f & g & h\\
\hline 
\end{tabular}
\par\end{center}
\caption{Table \#3}

\begin{center}
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline 
a & b & c & d & e & f & g & h\\ 
\hline 
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
\hline 
a & b & c & d & e & f & g & h\\
\hline 
\end{tabular}%
\par\end{center}
\caption{Table \#4}
\end{minipage}
\end{table}

\end{document}

我试图让大括号跨越多个表格,如下所示:


在此处输入图片描述


或者:


在此处输入图片描述


或者:


在此处输入图片描述


以下是一个例子我尝试过使用页边距的方法。它对常规文本很有效,但似乎对表格之类的对象无效:

\newcommand\BrText[2]{%
  \par\smallskip
   \noindent\makebox[\textwidth][r]{$\text{#1}\left\{
    \begin{minipage}{\textwidth}
    #2
    \end{minipage}
  \right.\nulldelimiterspace=0pt$}\par\smallskip
}    

我尝试了其他几种方法解决这个问题,但当时没有想到要保留那些不起作用的代码。无论如何,我记得在某处读到过这是可能的,但不确定在哪里。任何关于如何做到这一点的想法都将不胜感激。

答案1

在此处输入图片描述

\documentclass{article}

\begin{document}
\begin{table}
$\left\{
\begin{minipage}[c]{0.45\textwidth}%
\begin{center}
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline 
a & b & c & d & e & f & g & h\\ 
\hline 
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
\hline 
a & b & c & d & e & f & g & h\\
\hline 
\end{tabular}
\end{center}
\caption{Table \#1}

\begin{center}
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline 
a & b & c & d & e & f & g & h\\ 
\hline 
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
\hline 
a & b & c & d & e & f & g & h\\
\hline 
\end{tabular}%
\end{center}
\caption{Table \#2}
\end{minipage}
\begin{minipage}[c]{0.45\textwidth}%

\begin{center}
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline 
a & b & c & d & e & f & g & h\\ 
\hline 
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
\hline 
a & b & c & d & e & f & g & h\\
\hline 
\end{tabular}
\end{center}
\caption{Table \#3}

\begin{center}
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline 
a & b & c & d & e & f & g & h\\ 
\hline 
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
\hline 
a & b & c & d & e & f & g & h\\
\hline 
\end{tabular}%
\end{center}
\caption{Table \#4}
\end{minipage}
\right\}$
\end{table}

\end{document}

答案2

我提供了两种环境,mybraceleftmybraceright,用于方便地支撑水平材料。它们都生成所需大小的水平材料(您可以在段落中间使用它们)。

与 David 的解决方案相比,我的解决方案的一个显著特点是,它产生的水平材料可以紧密包裹环境tabular,或者您决定在它们的位置使用的任何内容(您不必猜测长度0.45\textwidth)。如果您减小这些元素的宽度,您会看到我的括号与\myhsep括号内容之间的距离保持可自定义,而 David 的解决方案并非如此(括号和内容之间的间隙会更大,因为minipage表格材料内部、左侧和右侧的空白会更多)。

在我设定的要求下,工作中比较棘手的部分是找到合适的宽度,以便将两个tabular环境和两个标题放在一起。为此,我使用了eqparbox包。这个包依赖于标签的正确使用(对于每个标签,它会找到最大宽度并允许您将其用作正常长度——这非常方便,很棒的包!)。注意源中的标签,它们以三个(为一个minipage紧紧包裹 tabular环境及其相关标题)。此过程至少需要编译两次文档。

没有table环境

在这个解决方案中,table不使用环境,因此没有任何东西浮动。这主要是装箱工作。\captionof来自caption包的用于产生标准表格标题的习惯外观。

\documentclass{article}
\usepackage[hscale=0.65]{geometry} % enlarge margins a little bit for the example
\usepackage{eqparbox}
\usepackage{caption}

\makeatletter

\newsavebox{\mybox}
\newlength{\myhsep} % Horizontal separation between brace and contents
\setlength{\myhsep}{0.7em}

\newenvironment{mybraceleft}{%
  \begin{lrbox}{\mybox}
  }{%
  \end{lrbox}%
  $\m@th \left\{ \kern\myhsep \vcenter{\hbox{\usebox{\mybox}}} \right.$%
  \kern-\nulldelimiterspace
  \ignorespacesafterend
}

\newenvironment{mybraceright}{%
  \begin{lrbox}{\mybox}
  }{%
  \end{lrbox}%
  \leavevmode
  \kern-\nulldelimiterspace
  $\m@th \left. \vcenter{\hbox{\usebox{\mybox}}} \kern\myhsep \right\}$%
  \ignorespacesafterend
}

\makeatother

\begin{document}

\noindent
\begin{mybraceleft}
  \begin{minipage}{\eqboxwidth{tag1}}
    \centering
    \begin{eqminipage}[c]{tag1}
    \begin{tabular}{@{}|c|c|c|c|c|c|c|c|@{}}
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
      1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
    \end{tabular}
    \end{eqminipage}%
    \captionof{table}{Table \#1}
    \bigskip

    \begin{eqminipage}[c]{tag1}
    \begin{tabular}{@{}|c|c|c|c|c|c|c|c|@{}}
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
      1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
    \end{tabular}
    \end{eqminipage}%
    \captionof{table}{Table \#2}
  \end{minipage}
\end{mybraceleft}% spaces would be ignored here anyway because of the
                 % \ignorespacesafterend we used
\hfill
\begin{mybraceleft}
  \begin{minipage}{\eqboxwidth{tag2}}
    \centering
    \begin{eqminipage}[c]{tag2}
    \begin{tabular}{@{}|c|c|c|c|c|c|c|c|@{}}
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
      1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
    \end{tabular}
    \end{eqminipage}%
    \captionof{table}{Table \#3}
    \bigskip

    \begin{eqminipage}[c]{tag2}
    \begin{tabular}{@{}|c|c|c|c|c|c|c|c|@{}}
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
      1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
    \end{tabular}
    \end{eqminipage}%
    \captionof{table}{Table \#4}
  \end{minipage}
\end{mybraceleft}

\vspace{2cm}
\noindent
\begin{mybraceleft}
  \begin{minipage}{\eqboxwidth{tag3}}
    \centering
    \begin{eqminipage}[c]{tag3}
    \begin{tabular}{@{}|c|c|c|c|c|c|c|c|@{}}
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
      1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
    \end{tabular}
    \end{eqminipage}%
    \captionof{table}{Table \#5}
    \bigskip

    \begin{eqminipage}[c]{tag3}
    \begin{tabular}{@{}|c|c|c|c|c|c|c|c|@{}}
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
      1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
    \end{tabular}
    \end{eqminipage}%
    \captionof{table}{Table \#6}
  \end{minipage}
\end{mybraceleft}% spaces would be ignored here anyway because of the
                 % \ignorespacesafterend we used
\hfill
\begin{mybraceright}
  \begin{minipage}{\eqboxwidth{tag4}}
    \centering
    \begin{eqminipage}[c]{tag4}
    \begin{tabular}{@{}|c|c|c|c|c|c|c|c|@{}}
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
      1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
    \end{tabular}
    \end{eqminipage}%
    \captionof{table}{Table \#7}
    \bigskip

    \begin{eqminipage}[c]{tag4}
    \begin{tabular}{@{}|c|c|c|c|c|c|c|c|@{}}
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
      1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
    \end{tabular}
    \end{eqminipage}%
    \captionof{table}{Table \#8}
  \end{minipage}
\end{mybraceright}

\end{document}

截屏

将支撑材料包裹在桌子内部

这与前面的示例很接近,唯一的区别是我们允许两个大块(每个包含四个tabular环境)浮动。因此,我们使用环境table,并且可以使用\caption而不是\captionof。在这种情况下不需要caption包。这与 David 所做的类似,除了输入语法(mybraceleftmybraceright此处)和括号周围的水平间距:我的括号与括号材料( )保持恒定的、可自定义的距离\myhsep

正如前面提到的,这需要两次编译运行才能eqparbox完成其工作。

\documentclass{article}
\usepackage[hscale=0.65]{geometry} % enlarge margins a little bit for the example
\usepackage{eqparbox}

\makeatletter

\newsavebox{\mybox}
\newlength{\myhsep} % Horizontal separation between brace and contents
\setlength{\myhsep}{0.7em}

\newenvironment{mybraceleft}{%
  \begin{lrbox}{\mybox}
  }{%
  \end{lrbox}%
  $\m@th \left\{ \kern\myhsep \vcenter{\hbox{\usebox{\mybox}}} \right.$%
  \kern-\nulldelimiterspace
  \ignorespacesafterend
}

\newenvironment{mybraceright}{%
  \begin{lrbox}{\mybox}
  }{%
  \end{lrbox}%
  \leavevmode
  \kern-\nulldelimiterspace
  $\m@th \left. \vcenter{\hbox{\usebox{\mybox}}} \kern\myhsep \right\}$%
  \ignorespacesafterend
}

\makeatother

\begin{document}

\begin{table}
\centering
\begin{mybraceleft}
  \begin{minipage}{\eqboxwidth{tag1}}
    \centering
    \begin{eqminipage}[c]{tag1}
    \begin{tabular}{@{}|c|c|c|c|c|c|c|c|@{}}
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
      1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
    \end{tabular}
    \end{eqminipage}%
    \caption{Table \#1}
    \bigskip

    \begin{eqminipage}[c]{tag1}
    \begin{tabular}{@{}|c|c|c|c|c|c|c|c|@{}}
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
      1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
    \end{tabular}
    \end{eqminipage}%
    \caption{Table \#2}
  \end{minipage}
\end{mybraceleft}% spaces would be ignored here anyway because of the
                 % \ignorespacesafterend we used
\hfill
\begin{mybraceleft}
  \begin{minipage}{\eqboxwidth{tag2}}
    \centering
    \begin{eqminipage}[c]{tag2}
    \begin{tabular}{@{}|c|c|c|c|c|c|c|c|@{}}
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
      1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
    \end{tabular}
    \end{eqminipage}%
    \caption{Table \#3}
    \bigskip

    \begin{eqminipage}[c]{tag2}
    \begin{tabular}{@{}|c|c|c|c|c|c|c|c|@{}}
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
      1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
    \end{tabular}
    \end{eqminipage}%
    \caption{Table \#4}
  \end{minipage}
\end{mybraceleft}
\end{table}

\begin{table}
\centering
\begin{mybraceleft}
  \begin{minipage}{\eqboxwidth{tag3}}
    \centering
    \begin{eqminipage}[c]{tag3}
    \begin{tabular}{@{}|c|c|c|c|c|c|c|c|@{}}
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
      1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
    \end{tabular}
    \end{eqminipage}%
    \caption{Table \#5}
    \bigskip

    \begin{eqminipage}[c]{tag3}
    \begin{tabular}{@{}|c|c|c|c|c|c|c|c|@{}}
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
      1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
    \end{tabular}
    \end{eqminipage}%
    \caption{Table \#6}
  \end{minipage}
\end{mybraceleft}% spaces would be ignored here anyway because of the
                 % \ignorespacesafterend we used
\hfill
\begin{mybraceright}
  \begin{minipage}{\eqboxwidth{tag4}}
    \centering
    \begin{eqminipage}[c]{tag4}
    \begin{tabular}{@{}|c|c|c|c|c|c|c|c|@{}}
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
      1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
    \end{tabular}
    \end{eqminipage}%
    \caption{Table \#7}
    \bigskip

    \begin{eqminipage}[c]{tag4}
    \begin{tabular}{@{}|c|c|c|c|c|c|c|c|@{}}
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
      1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
      \hline
      a & b & c & d & e & f & g & h\\
      \hline
    \end{tabular}
    \end{eqminipage}%
    \caption{Table \#8}
  \end{minipage}
\end{mybraceright}
\end{table}

\end{document}

截屏

相关内容