如何嵌套表格?

如何嵌套表格?

我想在另一个表中创建一个表,如下所示。不幸的是,它不起作用。它有什么问题?

\documentclass{minimal}
\usepackage{array,longtable,calc}

\begin{document}

\begin{longtable}{*{2}{m{0.5\linewidth}}}
%
\begin{longtable}%
{*{2}{m{0.5\linewidth}}}
A & B\tabularnewline
C & D\tabularnewline
\end{longtable}%
                                        & E \tabularnewline
F                                 & G \tabularnewline
\end{longtable}


\end{document}

编辑1

根据@Herbert的建议,使用tabular作为内表,这是我的修改。但是,规则没有出现。:-)

\documentclass{minimal}
\usepackage{array,longtable,calc}

\begin{document}

\begin{longtable}{|*{2}{m{0.5\linewidth}|}}
\hline%
\begin{tabular}%
{|*{2}{m{0.5\linewidth}|}}
\hline%
A & B\tabularnewline\hline
C & D\tabularnewline\hline
\end{tabular}%
                                        & E \tabularnewline\hline
F                                 & G \tabularnewline\hline
\end{longtable}


\end{document}

答案1

如果不使用该类minimal,则线条没有字体信息。但是,您不能对所有表格都使用垂直线,否则它们会被覆盖,有时会出现间隙。

\documentclass{article}
\usepackage{array,longtable,calc}

\begin{document}

\begin{longtable}{|@{}*{2}{m{0.5\linewidth}|}}\hline
\begin{tabular}{m{0.5\linewidth-\tabcolsep}|m{0.5\linewidth-\tabcolsep}@{}}
A & B\\\hline
C & D
\end{tabular}%
     & E \tabularnewline\hline
\hspace{\tabcolsep}F       & G \tabularnewline\hline
\end{longtable}

\end{document}

答案2

为了完整性:-)


替代文本


\documentclass[final,cmyk,table]{article}
\usepackage%
[%
a0paper,
margin=0cm%
]{geometry}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{array}
\usepackage{longtable}
\usepackage{calc}

\makeatletter
\newcommand\ratio[2]{%
  \strip@pt\dimexpr#1pt/#2\relax
}
\makeatother  


\setlength{\arrayrulewidth}{1pt}
\setlength{\tabcolsep}{5pt}
\arrayrulecolor{red}

\newcolumntype{S}[1]%
{%
    >{%
         \begin{minipage}%
         {%
            #1\linewidth-2\tabcolsep-2\arrayrulewidth%
         }%
         \vspace{\tabcolsep}%
    }%
    c%
    <{%
         \vspace{\tabcolsep}%
         \end{minipage}%
    }%
}%

\newcolumntype{O}[1]%
{%
    >{%
        \begin{minipage}%
        {%
             #1\linewidth-2\tabcolsep-1.5\arrayrulewidth%
        }%
        \vspace{\tabcolsep}%
    }%
    c%
    <{%
         \vspace{\tabcolsep}%
         \end{minipage}%
    }%
}%

\newcolumntype{I}[1]%
{%
    >{%
        \begin{minipage}%
        {%
            #1\linewidth-2\tabcolsep-\arrayrulewidth%
        }%
        \vspace{\tabcolsep}%
    }%
    c%
    <{%
        \vspace{\tabcolsep}%
        \end{minipage}%
    }%
}%



\newenvironment{MyCrazyTable}[3]%
{%    
    \begin{tabular}%
    {%
        |>{\centering}O{\ratio{#2}{#1}}%
        |>{\centering}O{\ratio{#3}{#1}}%
        |%
    }%
    \hline\ignorespaces%
}%
{%
    \end{tabular}%
}



\newcommand{\myrow}{%
\includegraphics[width=\linewidth]{newton}%
&%
\includegraphics[width=\linewidth]{newton}%
\tabularnewline\hline%
}




\begin{document}
\noindent%
\begin{longtable}{|S{1}|}
\hline
\begin{MyCrazyTable}{2}{1}{1}%
\begin{MyCrazyTable}{2}{1}{1}%
\begin{MyCrazyTable}{2}{1}{1}%
\begin{MyCrazyTable}{2}{1}{1}%
\begin{MyCrazyTable}{2}{1}{1}%
\begin{MyCrazyTable}{2}{1}{1}%
...                & F\tabularnewline\hline
\myrow
\end{MyCrazyTable} & F\tabularnewline\hline
\myrow
\end{MyCrazyTable} & F\tabularnewline\hline
\myrow
\end{MyCrazyTable} & F\tabularnewline\hline
\myrow
\end{MyCrazyTable} & F\tabularnewline\hline
\myrow
\end{MyCrazyTable} & F\tabularnewline\hline
\myrow
\end{MyCrazyTable}
\tabularnewline\hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{MyCrazyTable}{2}{1}{1}%
\begin{MyCrazyTable}{2}{1}{1}%
\begin{MyCrazyTable}{2}{1}{1}%
\begin{MyCrazyTable}{2}{1}{1}%
\begin{MyCrazyTable}{2}{1}{1}%
\begin{MyCrazyTable}{2}{1}{1}%
...                & F\tabularnewline\hline
\myrow
\end{MyCrazyTable} & F\tabularnewline\hline
\myrow
\end{MyCrazyTable} & F\tabularnewline\hline
\myrow
\end{MyCrazyTable} & F\tabularnewline\hline
\myrow
\end{MyCrazyTable} & F\tabularnewline\hline
\myrow
\end{MyCrazyTable} & F\tabularnewline\hline
\myrow
\end{MyCrazyTable}
\tabularnewline\hline
\end{longtable}
\end{document}

我使用了这个图像并将其重命名为 newton.jpg

替代文本

相关内容