2

Problem 1: Extra vertical lines in the bottom of table with overlayarea. Tried solutions in Too long vertical lines in table, but changing |c|c| to cc is not okay for the looks of the table.

Problem 2: The table heading wobbles with overlayarea in slide 1 and 2.

MWE:

\documentclass{beamer}
\begin{document}
    \begin{frame}
    \frametitle{Title}
    \framesubtitle{Subtitle}
    \begin{overlayarea}{\textwidth}{2cm}
        \begin{table}
            \begin{tabular}{|c|c|c|}    
                \hline
                \only<1-3>{             
                    \textbf{Sl. No.}    &   \textbf{Heading1}   &   \textbf{Heading2}\\
                    \hline
                }
                \only<2-3>{
                    1                   &   Content1.1          &   Content1.2\\
                    \hline
                }
                \only<3>{
                    2                   &   Content2.1          &   Content2.2\\
                    \hline
                }
            \end{tabular}
        \end{table}
    \end{overlayarea}
\end{frame}
\end{document}

MWE (same as previous, but without any newline, tabs or space):

\documentclass{beamer}
\begin{document}
    \begin{frame}
    \frametitle{Title}
    \framesubtitle{Subtitle}
    \begin{overlayarea}{\textwidth}{2cm}
        \begin{table}\begin{tabular}{|c|c|c|}\hline\only<1-3>{\textbf{Sl. No.}&\textbf{Heading1}&\textbf{Heading2}\\\hline}\only<2-3>{1&Content1.1&Content1.2\\\hline}\only<3>{2&Content2.1&Content2.2\\\hline}\end{tabular}\end{table}
    \end{overlayarea}
\end{frame}
\end{document}

Output of MWE (excluding red markings)

2
\documentclass{beamer}
\begin{document}
    \begin{frame}
    \frametitle{Title}
    \framesubtitle{Subtitle}
    \begin{overlayarea}{\textwidth}{2cm}
        \begin{table}
            \begin{tabular}{|c|c|c|}    
                \hline
                \only<1-3>{%            
                    \textbf{Sl. No.}    &   \textbf{\ Heading1\ }   &   \textbf{\ Heading2\ }%
                }%
                \only<2-3>{%
                    \\\hline
                    1                   &   Content1.1          &   Content1.2%
                }%
                \only<3>{%
                   \\\hline
                    2                   &   Content2.1          &   Content2.2%
                }%
                \only<1-3>{\\\hline}%
            \end{tabular}
        \end{table}
    \end{overlayarea}
\end{frame}
\end{document}
  • Excellent. Worked for me. I still do not understand why my code did not work. The wobbling effect is bit tricky. If first column of second row has longer text than first column of first row, the overlayarea does not eliminate wobble effect. Though I solved it using |p{width of longest text in this column}|. I expected overlayarea to take care of it. – ItzMe Nov 16 '17 at 20:29
  • @Govinda you want to add your \only nodes in a "safe" place so not just after an \hline which is why I restructured to always add then inside the cell at the end of a row, you will note I added \ to your headings here to force them to be wider than the content (or as you say, you can use fixed width columns) – David Carlisle Nov 16 '17 at 20:36
  • I should be careful about "safe" place. I noticed \ now. Good option, did not know this. Thanks. – ItzMe Nov 16 '17 at 20:51

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.