3

I have some data tables and I want to add a force nested table, i.e. something like the following:

enter image description here

after reading the comments tex.stackexchange.com/a/5770, this solution is not suitable for my purposes : 1- I need to show in the caption Table instead of Figure on both sides. 2- the table doesn't show up, by using Figure tag.

enter image description here

code :

                \documentclass[a4paper,12pt]{article}
                \usepackage[margin=2cm]{geometry}
                \usepackage{adjustbox}
                \usepackage{multirow}
                \usepackage{graphicx}
                \usepackage{amsmath}
                \usepackage{algorithm}
                \usepackage[noend]{algpseudocode}
                \usepackage{array}
                \usepackage{makecell}
                        \usepackage[utf8]{inputenc}
                        \usepackage[T1]{fontenc}
                        \usepackage{lmodern}
                        \usepackage{graphicx}
                        \usepackage{caption}

                \begin{document}

                \begin{figure}
                    \centering
                    \begin{minipage}{0.45\textwidth}
                        \centering
                        \begin{table}
                        \begin{tabular}{|c|c|c|c|}
                            \hline
                            \multirow{2}{*}{\thead{Data \\ I}} & \multirow{2}{*}{P} &\multirow{2}{*}{\thead{A \\ 0T}} & \multirow{2}{*}{CT}\\
                             & & & \\ 
                            \hline
                            AAA&65.77&85.42&51.35\\
                            AAT&4.6&59.4&0.6\\
                            \hline
                            Mean&39.8&39.8&39.8\\
                            \hline
                            \end{tabular}
                        \end{table}
                        \caption{Table 1}
                    \end{minipage}\hfill
                    \begin{minipage}{0.45\textwidth}
                        \centering
                        \includegraphics[width=0.9\textwidth]{example-image-b} % second figure itself
                        \caption{second figure}
                    \end{minipage}
                \end{figure}

                \end{document}
  • Welcome to Tex.SX Could you please post an MWE – Thorbjørn E. K. Christensen Mar 12 '18 at 11:46
  • 2
    Hi, welcome. That is similar to tex.stackexchange.com/a/5770 (just replace figure with table, and add a tabular instead of \includegraphics). – Torbjørn T. Mar 12 '18 at 11:46
  • welcome to tex.se! what is the problem? where you stuck, when you try to write your table? – Zarko Mar 12 '18 at 11:47
  • Sir @TorbjørnT. I have tested that, but no good results – azdoud Mar 12 '18 at 11:54
  • 2
    Then can you show us what you have tried, and explain what is wrong with the result? – Torbjørn T. Mar 12 '18 at 11:55
3

Thanks to @Torbjørn T

The solution is :

    \documentclass[a4paper,12pt]{article}
    \usepackage[margin=2cm]{geometry}
    \usepackage{adjustbox}
    \usepackage{multirow}
    \usepackage{graphicx}
    \usepackage{amsmath}
    \usepackage{algorithm}
    \usepackage[noend]{algpseudocode}
    \usepackage{array}
    \usepackage{makecell}
            \usepackage[utf8]{inputenc}
            \usepackage[T1]{fontenc}
            \usepackage{lmodern}
            \usepackage{graphicx}
            \usepackage{caption}

    \begin{document}

    \begin{table}

        \centering
        \begin{minipage}{0.45\textwidth}
            \centering

            \begin{tabular}{|c|c|c|c|}
                \hline
                \multirow{2}{*}{\thead{Data \\ I}} & \multirow{2}{*}{P} &\multirow{2}{*}{\thead{A \\ 0T}} & \multirow{2}{*}{CT}\\
                 & & & \\ 
                \hline
                AAA&65.77&85.42&51.35\\
                AAT&4.6&59.4&0.6\\
                \hline
                Mean&39.8&39.8&39.8\\
                \hline
                \end{tabular}

            \caption{Average errors}
        \end{minipage}\hfill
        \begin{minipage}{0.45\textwidth}
            \centering
            \centering

            \begin{tabular}{|c|c|c|c|}
                \hline
                \multirow{2}{*}{\thead{Data \\ I}} & \multirow{2}{*}{P} &\multirow{2}{*}{\thead{A \\ 0T}} & \multirow{2}{*}{CT}\\
                 & & & \\ 
                \hline
                AAA&65.77&85.42&51.35\\
                AAT&4.6&59.4&0.6\\
                \hline
                Mean&39.8&39.8&39.8\\
                \hline
                \end{tabular}

            \caption{Average success}
        \end{minipage}

    \end{table}
    \end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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