3

I am trying to create two tables and put them beside each other. Each table should shrink to the rectangle shown in green while maintaining the aspect ratio. However, it does not seem that this is the case. Replacing the table with a blind text seems to work well.

\documentclass[aspectratio=169, xcolor={x11names}]{beamer}

    \usecolortheme{seahorse}
    \useoutertheme{miniframes}
    \useinnertheme{inmargin}

    \usepackage{adjustbox}
    \usepackage{ragged2e}

    % ========== Table packages ==========
    \usepackage{booktabs}
    \usepackage{makecell}
    \usepackage{multirow}

    % ========== Equations and math packages ==========
    \usepackage{amsmath}
    \usepackage{amssymb, amsfonts}


    \usepackage[defaultmathsizes, subdued, italic, symbolre, symbolmisc]{mathastext}
% BEGIN_FOLD

\MTDeclareVersion[it]{charter}{T1}{bch}{m}{n}

\AtBeginDocument{\MTversion*{charter}}


% END_FOLD


    % Set margins
    \newlength{\widthTextMarginLeftPageWide}
    \setlength{\widthTextMarginLeftPageWide}{5mm}
    \newlength{\widthTextMarginRightPageWide}
    \setlength{\widthTextMarginRightPageWide}{5mm}

    % Command to change margins for a page wide
    \makeatletter
    \newcommand{\framePageWide}{
        \def\Gm@lmargin{\widthTextMarginLeftPageWide}%
        \def\Gm@rmargin{\widthTextMarginRightPageWide}%
        \textwidth=\dimexpr\paperwidth-\Gm@lmargin-\Gm@rmargin\relax
        \hsize\textwidth
        \columnwidth\textwidth
        \hoffset=\dimexpr-\beamer@leftsidebar+\Gm@lmargin-\widthTextMarginLeftPageWide\relax
    }
    \makeatother

\begin{document}

\newcolumntype{q}[1]{>{\raggedright \arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{w}[1]{>{\centering \arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{e}[1]{>{\raggedleft \arraybackslash\hspace{0pt}}m{#1}}

{\framePageWide

\begin{frame}{Results}

    \begin{adjustbox}{minipage={0.45\textwidth}, max totalsize={0.45\textwidth}{!}, cframe=SpringGreen3 0.3mm}

        \begin{tabular}{w{2cm} @{\extracolsep{1mm}}|w{1.5cm} w{1.5cm} w{1.5cm}}

            \toprule

            \multirow{3}{=}{\centering System Size} & \multicolumn{3}{c}{Time Needed With Our Approach}
            \\

            & \multicolumn{3}{c}{(Extended Brown's Method)}
            \\
            \Xcline{2-4}{0.25mm}

            & min & mean & max
            \\
            \Xhline{0.25mm}

            200-bus & $3\times10^{-6}$ & $4.3\times10^{-6}$ & $5\times10^{-6}$
            \\

            2383-bus & $3\times10^{-6}$ & $3.8\times10^{-6}$ & $6\times10^{-6}$
            \\

            3120-bus & $3\times10^{-6}$ & $3.2\times10^{-6}$ & $4\times10^{-6}$
            \\

            \bottomrule

        \end{tabular}

    \end{adjustbox}
    \hfill
    \begin{adjustbox}{minipage={0.45\textwidth}, max totalsize={0.45\textwidth}{!}, cframe=SpringGreen3 0.3mm}

        \begin{tabular}{w{2cm} @{\extracolsep{1mm}}|w{1.5cm} w{1.5cm} w{1.5cm}}

            \toprule

            \multirow{3}{=}{\centering System Size} & \multicolumn{3}{c}{Time Needed With}
            \\

            & \multicolumn{3}{c}{Conventional Brown's Method}
            \\
            \Xcline{2-4}{0.25mm}

            & min & mean & max
            \\
            \Xhline{0.25mm}

            200-bus & $0.089$ & $0.092$ & $0.1000$
            \\

            2383-bus & $163.8$ & $166.2$ & $172.5$
            \\

            3120-bus & $387.2$ & $398.8$ & $415.6$
            \\

            \bottomrule

        \end{tabular}

    \end{adjustbox}

\end{frame}

}



\end{document}
  • 3
    Shrinking elements that contain text is really not a good idea. Use a smaller font size or change the layout of your table to make it fit in the available space. See https://tex.stackexchange.com/questions/425453/why-not-scale-elements-that-contain-text for more information – samcarter_is_at_topanswers.xyz Mar 21 '19 at 10:32
  • 1
    For example you could save some space by using shorter column headers – samcarter_is_at_topanswers.xyz Mar 21 '19 at 10:34
  • @samcarter I know but if the contents were scaled while maintaining aspect ratio, it would not be that hard to just zoom to the area of interest. Also, the idea here is not to rescale the table to be much smaller that the text is not readable but rather to force the table to fit exactly the specified size which helps create neater slides (e.g., preventing it from overlapping with adjacent contents) – Al-Motasem Aldaoudeyeh Mar 21 '19 at 11:07
  • 1
    Maintaining the same aspect ratio is not the point. The problem is that when you scale down the text, you will still get the letter shapes which are made for normal size. If you use a smaller font size instead, you will get other letter shapes that are made to be easily read at this size. – samcarter_is_at_topanswers.xyz Mar 21 '19 at 11:48
  • 1
    Do you really have to repeat the System Size column? Without it the table would most likely fit without the need to scale it. – leandriis Mar 21 '19 at 12:33
  • I am not repeating columns. These are two different tables placed on the same slide – Al-Motasem Aldaoudeyeh Mar 21 '19 at 12:35

2 Answers2

3

i would redesign your tables as follows:

  • remove first column in the second table
  • remove \hfill between tables
  • use S column type from siunitx package
  • for tables use tabularx

enter image description here

\documentclass[aspectratio=169, xcolor={x11names}]{beamer}
    \usecolortheme{seahorse}
    \useoutertheme{miniframes}
    \useinnertheme{inmargin}
\usepackage{siunitx}
\usepackage{ragged2e}
% ========== Table packages ==========
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{multirow}
\usepackage{tabularx}
    \newcommand\mcx[1]{\multicolumn{1}{>{\centering\arraybackslash}X}{#1}}
% ========== Equations and math packages ==========
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[defaultmathsizes, subdued, italic, symbolre, symbolmisc]{mathastext}
% BEGIN_FOLD
\MTDeclareVersion[it]{charter}{T1}{bch}{m}{n}
\AtBeginDocument{\MTversion*{charter}}

\begin{document}
\begin{frame}{Results}
    \small
    \begin{tabularx}{0.55\linewidth}{@{} p{3.8em}
                                        S[table-format=1.0e1]
                                        S[table-format=1.1e1]
                                        S[table-format=1.0e1]
                                    @{} }
    \toprule
\multirow{3}{=}{\centering System Size}
    & \multicolumn{3}{c}{\makecell{Time Needed\\
                                   With Our Approach\\
                                   (Extended Brown's Method)}}  \\
    \cmidrule(lr){2-4}
    & \mcx{min} & \mcx{mean} & \mcx{max}
            \\
    \midrule
 200-bus &  3e6  &   4.3e6    &   5e6   \\
2383-bus &  3e6  &   3.8e6    &   6e6   \\
3120-bus &  3e6  &   3.2e6    &   4e6   \\
    \bottomrule
    \end{tabularx}\begin{tabularx}{0.4\linewidth}{@{}
                                        S[table-format=3.3]
                                        S[table-format=3.3]
                                        S[table-format=3.3]
                                                @{} }
    \toprule
\multicolumn{3}{c}{\makecell{Time Needed\\
                             With Conventional\\
                             Brown's Method}} \\
    \cmidrule(lr){1-3}
\mcx{min} & \mcx{mean} & \mcx{max}
            \\
    \midrule
0.089   &   0.092   &   0.100   \\
163.8   &   166.2   &   172.5   \\
387.2   &   398.8   &   415.6   \\
    \bottomrule
    \end{tabularx}
\end{frame}
\end{document}
Zarko
  • 296,517
3

Here's another suggestion for combining the two tables into a single table. It uses a tabular* environment, with width set to \textwidth. The S column type of the siunitx package is employed to format and align the numeric cells. I'd also make the frame title a lot more descriptive.

enter image description here

\documentclass[aspectratio=169, xcolor={x11names}]{beamer}
    \usecolortheme{seahorse}
    \useoutertheme{miniframes}
    %\useinnertheme{inmargin}

\usepackage{ragged2e,booktabs,array}
\usepackage{amsmath,amssymb,siunitx}

\begin{document}

\begin{frame}{Times needed with extended and conventional Brown's methods}
\sisetup{exponent-product=\cdot}
\setlength\tabcolsep{0pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}
        l S[table-format=1e-1]
        S[table-format=1.1e-1]
        S[table-format=1e-1]
   *{3}{S[table-format=3.3]} }

\toprule
System Size  & \multicolumn{6}{c}{Times needed with \dots} \\
\cmidrule{2-7}
& \multicolumn{3}{c}{Ext.\ Brown's Method}
& \multicolumn{3}{c}{Conv.\ Brown's Method}\\
& \multicolumn{3}{c}{(Our Method)}\\
\cmidrule{2-4} \cmidrule{5-7}
& {min} & {mean} & {max} & {min} & {mean} & {max} \\
\midrule
\phantom{2}200-bus 
         & 3e-6 & 4.3e-6 & 5e-6 & 0.089 & 0.092 & 0.100 \\
2383-bus & 3e-6 & 3.8e-6 & 6e-6 & 163.8 & 166.2 & 172.5 \\
3120-bus & 3e-6 & 3.2e-6 & 4e-6 & 387.2 & 398.8 & 415.6 \\
\bottomrule
\end{tabular*}

\end{frame}
\end{document} 
Mico
  • 506,678