2

I'm getting trouble trying to make a table in my beamer. The following is my code:

\section{ANÁLISE DE PERFOMANCE DE PORTFÓLIO}
\begin{frame} 
\frametitle{Comportamento dos Mercados}

\hspace{7mm}Quanto maior a volatilidade, maiores ganhos podem ser auferidos agentes especulati-vos, pois, ativos com risco garantem um prêmio.\vspace{0.3cm}

\hspace{7mm}Utilizando a hipótese do random walk e o teste do ADF é possível verificar se um mercado, na hipótese fraca, é eficiente. \vspace{0.3cm}


\begin{tabular}{c | c}
Estatísticas & Valores
\hline \hline
Tau (Observed value) & -2,073
Tau (Critical value) & -0,863
p-value (one-tailed) & 0,563
alpha & 0,05
\end{tabular}


\end{frame}

"misplaced \noalign. \hline ->\noalign {\ifnum 0=`}\fi \hrule \@height \arrayrulewidth \futurelet... l.257 \end{frame}"

It's appering this message. What's wrong with my code?

  • The problem are the two \hline without a `\\` ending the line above them. – Skillmon Jul 9 '17 at 16:50
2

You did not end the rows of your tabular correctly:

\documentclass[]{beamer}

\begin{document}
\begin{frame}
\begin{tabular}{c | c}
Estatísticas & Valores\\
\hline \hline
Tau (Observed value) & -2,073\\
Tau (Critical value) & -0,863\\
p-value (one-tailed) & 0,563\\
alpha & 0,05 % no \\ in the last row
\end{tabular}
\end{frame}
\end{document}

You have to put \\ at the end of each line.

This results in:

enter image description here

You could enhance the table visually. Don't use vertical lines if it's not absolutely necessary. Also you might use the booktabs package and use the commands \toprule, \midrule and \bottomrule. Another enhancement could be the siunitx package which provides very useful tools for displaying numbers (also in tables).

\documentclass[]{beamer}
\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}
\begin{frame}
\begin{tabular}{l S[table-format=-1.3]}
    \toprule
    Estatísticas & {Valores}\\% enclose cells which are not numbers with {...}
    \midrule
    Tau (Observed value) & -2,073\\
    Tau (Critical value) & -0,863\\
    p-value (one-tailed) & 0,563\\
    alpha & 0,05\\ % \\ in the last row because of the \bottomrule
    \bottomrule
\end{tabular}
\end{frame}
\end{document}

This results in:

enter image description here

  • Perfetc. It's working now. I would like to centralize the table, is that possible? – Arduin Jul 9 '17 at 17:32
  • @Arduin Put a \centering after \begin{frame} to horizontally centre the contents of the frame. To centre the tabular environment vertically (if it's the only content of the frame) put a \vfill before and one after it. – Skillmon Jul 9 '17 at 17:39

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.