5

i need help formatting this slide:

enter image description here

As you can see, the text above the first table isnt in the same line as the text above the second table. How can i put them in the same line? Heres the code that generated it:

\documentclass[aspectratio=169]{beamer}
\usetheme{Warsaw}
\setbeamertemplate{headline}{}

\begin{document}
        % SLIDE 40
        \subsection{Sistema de 33 barras}
        \begin{frame}
            \frametitle{Resultados}
        \framesubtitle{Sistema de 33 barras (barras candidatas: 7, 8, 9 e 10) - Primeiro caso}
\begin{minipage}{.5\textwidth}
Resultado com $w_1 = 0$, $w_2 = 0$ e $w_3 = 1$:
\begin{table}[H]
\begin{center}
\label{primeiro_caso_trintaetres_barras}
\begin{tabular}{|c|c|c|}
\hline
Filtro & Ordem Harmônica & Barra \\ \hline
1      & 5ª                    & 7     \\ \hline
2      & 3ª                    & 10     \\ \hline
\end{tabular}
\end{center}
\end{table}
\end{minipage}%
\begin{minipage}{.5\textwidth}
Perdas totais de potências ativas e reativas:
\begin{table}[H]
\begin{center}
\label{primeiro_caso_dezessete_barras}
\begin{tabular}{lllll}
\cline{1-3}
\multicolumn{1}{|l|}{} & \multicolumn{1}{l|}{$Antes$} & \multicolumn{1}{l|}{$Depois$} &  &  \\ \cline{1-3}
\multicolumn{1}{|l|}{$\Delta P_{total} (kW)$} & \multicolumn{1}{l|}{1385,291} & \multicolumn{1}{l|}{1353,611} &  &  \\ \cline{1-3}
\multicolumn{1}{|l|}{$\Delta Q_{total} (kvar)$} & \multicolumn{1}{l|}{395,617} & \multicolumn{1}{l|}{387,007} &  &  \\ \cline{1-3}
                       &                       &                       &  & 
\end{tabular}
\end{center}
\end{table}
\end{minipage}
        \end{frame}
\end{document}
  • \begin{minipage}[t]{.5\textwidth}. Also, why 5 cols? – Sigur Jul 20 at 18:35
5

The right-hand tabular environment is defined to contain 5 columns, but it has only 3.; do get rid of the final two. Moreover, the right-hand tabular environment contains a lot of very clumsy and cluttery code which simply isn't needed. You should simplify it drastically, maybe along the lines shown in the code below.

enter image description here

\documentclass[aspectratio=169]{beamer}
\usetheme{Warsaw}
\setbeamertemplate{headline}{}
\usepackage[portuguese]{babel}
\usepackage{array,siunitx}
\sisetup{output-decimal-marker={\text{,}}}
\begin{document}
% SLIDE 40
\subsection{Sistema de 33 barras}
\begin{frame}
\frametitle{Resultados}
\framesubtitle{Sistema de 33 barras (barras candidatas: 7, 8, 9 e 10) -- Primeiro caso}

\setlength\extrarowheight{2pt} % for a more open "look"

\begin{minipage}[t]{.475\textwidth}
\centering
Resultado com $w_1 = 0$, $w_2 = 0$ e $w_3 = 1$:

\begin{tabular}{|c|c|c|}
\hline
Filtro & Ordem Harmônica & Barra  \\ \hline
1      & 5ª              & 7      \\ \hline
2      & 3ª              & 10     \\ \hline
\end{tabular}
\end{minipage}\hfill
\begin{minipage}[t]{.505\textwidth}
\centering
Perdas totais de potências ativas e reativas:

\begin{tabular}{|l|S[table-format=4.3]|S[table-format=4.3]|}
\hline
& {\textit{Antes}} & {\textit{Depois}} \\ 
\hline
$\Delta P_{\!total}$ (kW) & 1385,291 & 1353,611 \\ 
\hline
$\Delta Q_{total}$ (kvar) &  395,617 &  387,007 \\ 
\hline
\end{tabular}
\end{minipage}

\end{frame}
\end{document}
  • 2
    +1 too :-). Since OP use labels for table I bother with adding templates for caption ... – Zarko Jul 20 at 19:02
  • Great, i got it now... thanks for all the info everyone! – Murilo Araujo Souza Jul 20 at 19:20
6

you have many issues with your slide:

  • in beamer table environment is not a float, so it not need any positioning option (in your case H, which is ignored)
  • referencing tables without having captions has no sense
  • if you use \caption,referencing has sense if captions are numbered
  • use \multicolumns or each cell in the second table is superfluous
  • in second table you define 5 columns but use only three ...
  • I doubt that column headers in the second table have math variables, correct is use \textit{Antes} etc
  • for vertical align of your tables you can add option [t] to minipages or use tabularx as I do in the following MWE
  • I also suggest to use S columns type in the second table

Considering aforementioned i suggest the following rewriting of your slide:

\documentclass[aspectratio=169]{beamer}
\usetheme{Warsaw}
\setbeamertemplate{headline}{}
%----
    \setbeamertemplate{caption}[numbered]
    \setbeamerfont{caption}{size=\scriptsize}
%----

\usepackage{siunitx}
\usepackage{tabularx}

\begin{document}
        % SLIDE 40
        \subsection{Sistema de 33 barras}
\begin{frame}
    \frametitle{Resultados}
    \framesubtitle{Sistema de 33 barras (barras candidatas: 7, 8, 9 e 10) - Primeiro caso}
\begin{table}
\begin{tabularx}{\linewidth}{@{} *{2}{>{\centering\arraybackslash}X} @{}}
    \caption{Resultado com $w_1 = 0$, $w_2 = 0$ e $w_3 = 1$:}
    \label{primeiro_caso_trintaetres_barras}
\begin{tabular}{|c|c|c|}
    \hline
Filtro  & Ordem Harmônica   & Barra \\ \hline
1       & 5ª                & 7     \\ \hline
2       & 3ª                & 10    \\ \hline
\end{tabular}
&
    \caption{Perdas totais de potências ativas e reativas:}
    \label{primeiro_caso_dezessete_barras}
\begin{tabular}{|>{$}l<{$}|S|S|}
    \hline
    & {\textit{Antes}}  & {\textit{Depois}} \\ 
    \hline
\Delta P_{\mathrm{total}} (kW)
    &   1385,291        &   1353,611        \\ 
    \hline
\Delta Q_{\mathrm{total}} (kVAr)
    &   395,617         &   387,007         \\ 
    \hline
\end{tabular}
\end{tabularx}
    \end{table}
\end{frame}
\end{document}

enter image description here

  • 1
    +1. Maybe take the units (kW, kVAr) out of math mode? – Mico Jul 20 at 18:54
  • @Mico, you are right. units should be in upright font, corrected. – Zarko Jul 20 at 18:58

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.