Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to have a table which contains many tables. I want its caption also. MTab1 and 2 are single col and row matrix. length of Mtab1 and 2 should be equal to T1 and T2.It means Row of MTab1 = 7 rows of T1

enter image description here

\documentclass[pdftex,12pt,a4paper]{report}
\usepackage{lscape}    
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}    
\documentclass[pdftex,12pt,a4paper]{report}
\usepackage{lscape}
 \newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
  \begin{document}
   \begin{landscape} 
    \begin{tabular}{l l l} 
     MTab1 & \input{./Mat1_out.tex} & \input{./Mat2_out.tex}\\ MTab2 & \input{./Mat1_out.tex} & \input{./Mat2_out.tex}\\ 

   \caption{This table shows some data}
    \end{tabular}
     \end{landscape}
      \end{document}

% Content Mat1_out.text

\begin{tiny}\begin{tabular}{|l|c|c|c|c|}
\hline
&\textbf{col 1}&\textbf{col 2}&\textbf{col 3}&\textbf{col 4}\\\hline
\textbf{row 1}&0.55&0.24&0.35&0.75\\\hline
\textbf{row 2}&0.14&0.93&0.83&0.38\\\hline
\textbf{row 3}&0.15&0.35&0.59&0.57\\\hline
\textbf{row 4}&0.26&0.20&0.55&0.08\\\hline
\textbf{row 5}&0.84&0.25&0.92&0.05\\\hline
\textbf{row 6}&0.25&0.62&0.29&0.53\\\hline
\textbf{row 7}&0.81&0.47&0.76&0.78\\\hline
\end{tabular}
\end{tiny}

% Mat2_out.tex

\begin{tiny}\begin{tabular}{|l|c|c|c|c|}
\hline
&\textbf{col 1}&\textbf{col 2}&\textbf{col 3}&\textbf{col 4}\\\hline
\textbf{row 1}&0.93&0.79&0.69&0.83\\\hline
\textbf{row 2}&0.13&0.31&0.75&0.54\\\hline
\textbf{row 3}&0.57&0.53&0.45&1.00\\\hline
\textbf{row 4}&0.47&0.17&0.08&0.08\\\hline
\textbf{row 5}&0.01&0.60&0.23&0.44\\\hline
\textbf{row 6}&0.34&0.26&0.91&0.11\\\hline
\textbf{row 7}&0.16&0.65&0.15&0.96\\\hline
\end{tabular}
\end{tiny}

% latextable2.tex

\begin{table}
    \begin{tabular}{|l|}
        \hline
        MTab1\\ \hline
        Matb2 \\
        \hline
    \end{tabular}
\end{table}
share|improve this question
    
I am not sure exactly what you want, but does this output what you desire: \begin{tabular}{l l l} MTab1 & \input{./Mat1_out.tex} & \input{./Mat2_out.tex}\MTab2 & \input{./Mat1_out.tex} & \input{./Mat2_out.tex}\\end{tabular}? –  Peter Grill Dec 22 '12 at 20:06
    
@ Peter Grill thanx very much. I adopted your code. You can see edited version. Now only thing left is to make caption center and get main table (rectangle/frame)around all tables and there should no gap between colume 2&3. –  user31177 Dec 22 '12 at 20:19
add comment

1 Answer

up vote 4 down vote accepted

Here is a version discussed in the comments with a frame and caption added. Not sure I really like it but think it is what was asked for:

enter image description here

To eliminate the gap between columns 2 and 3, the @{} column specification was added to remove the \tabcolsep that gets added in between columns. This also necessitated the addition of a trailing % in the sub tables to eliminate the spurious space that would otherwise be introduced.

Code:

\documentclass[pdftex,12pt,a4paper]{report}
\usepackage{lscape}

\usepackage{filecontents}
\begin{filecontents*}{latextable2.tex}
\begin{table}
    \begin{tabular}{|l|}
        \hline
        MTab1\\ \hline
        Matb2 \\
        \hline
    \end{tabular}
\end{table}
\end{filecontents*}

\begin{filecontents*}{Mat1_out.tex}
\begin{tiny}\begin{tabular}{|l|c|c|c|c|}
\hline
&\textbf{col 1}&\textbf{col 2}&\textbf{col 3}&\textbf{col 4}\\\hline
\textbf{row 1}&0.55&0.24&0.35&0.75\\\hline
\textbf{row 2}&0.14&0.93&0.83&0.38\\\hline
\textbf{row 3}&0.15&0.35&0.59&0.57\\\hline
\textbf{row 4}&0.26&0.20&0.55&0.08\\\hline
\textbf{row 5}&0.84&0.25&0.92&0.05\\\hline
\textbf{row 6}&0.25&0.62&0.29&0.53\\\hline
\textbf{row 7}&0.81&0.47&0.76&0.78\\\hline
\end{tabular}%
\end{tiny}%
\end{filecontents*}

\begin{filecontents*}{Mat2_out.tex}
\begin{tiny}\begin{tabular}{|l|c|c|c|c|}
\hline
&\textbf{col 1}&\textbf{col 2}&\textbf{col 3}&\textbf{col 4}\\\hline
\textbf{row 1}&0.93&0.79&0.69&0.83\\\hline
\textbf{row 2}&0.13&0.31&0.75&0.54\\\hline
\textbf{row 3}&0.57&0.53&0.45&1.00\\\hline
\textbf{row 4}&0.47&0.17&0.08&0.08\\\hline
\textbf{row 5}&0.01&0.60&0.23&0.44\\\hline
\textbf{row 6}&0.34&0.26&0.91&0.11\\\hline
\textbf{row 7}&0.16&0.65&0.15&0.96\\\hline
\end{tabular}%
\end{tiny}%
\end{filecontents*}

\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}

\begin{document}
\begin{landscape}

\begin{table}
\centering\renewcommand{\arraystretch}{1.2}%
\begin{tabular}{| l@{} l@{} l@{}|}\hline
MTab1 & \input{./Mat1_out.tex} & \input{./Mat2_out.tex}\\
MTab2 & \input{./Mat1_out.tex} & \input{./Mat2_out.tex}\\\hline
\end{tabular}
\caption{Caption for main table}
\end{table}

\end{landscape}
\end{document}
share|improve this answer
    
+1 although I'd put the caption above the tabular :) –  cmhughes Dec 22 '12 at 23:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.