4

The following latex code prints rows one at a time. However all the cells of the rows don't come out aligned. How can I fix it.

\documentclass{beamer}    
\usepackage{tabularx}  

\begin{document}

\begin{frame}{}
 \begin{tabularx}{3.50in}{lXX}
          \hline
          & Observation & Conclusion \\
          \hline  
          \uncover<2->{1.} & \uncover<2->{Observation 1 } & \uncover<2->{Conclusion 1} \\  
\uncover<3->{2.} & \uncover<3->{Observation 2} & \uncover<3->{Conclusion 2} \\  
        \end{tabularx}     
\end{frame}  
\end{document}

The output looks as follows :

enter image description here

As we can see cells in first column do not align with the rest of the rows. Will appreciate any input as to how to fix this.

  • Hi Sandeep- I removed the align tag as it's reserved for questions related to the environment provided by the amsmath package; I also removed the thanks and your signature, as it's always done automatically :) – cmhughes May 9 '12 at 20:36
  • This isn't really a fix, but if you use \begin{tabularx}{3.50in}{XXX} then the problem goes away... I don't know why this 'fixes' it though... – cmhughes May 9 '12 at 20:40
  • @cmhughes : Thanks for the prompt reply. Removing align is fine. I see that replacing l with X fixes the alignment. However now the width of the column becomes too big. Is there anyway to set the width of a column to some fixed value? – Sandeep May 9 '12 at 20:51
  • you could use \begin{tabularx}{3.50in}{p{1cm}XX} and change the 1cm to anything you like... – cmhughes May 9 '12 at 21:07
7

TeX is in a funny state at the start of table cells, it's best to avoid doing anything too clever there and beamer gradual reveals come in that category:-) \leavevmode gets you to a safer place.

enter image description here

\documentclass{beamer}    
\usepackage{times}    
\usepackage{amsmath,amsthm, amssymb, latexsym}   
\usepackage{exscale}  
\usepackage{booktabs, array}  
\usepackage{graphicx}  
\usepackage{setspace}   
\usepackage{tabularx}  
\usepackage{listliketab}  

\begin{document}

\begin{frame}{}
  \begin{listliketab}   
    \storestyleof{itemize}   
    \tiny  

        \begin{tabularx}{3.50in}{lXX}
          \hline
          & Observation & Conclusion \\
           \hline  
\leavevmode\uncover<2->{1.} & \leavevmode\uncover<2->{Observation 1 } & \leavevmode\uncover<2->{Conclusion 1} \\  
\leavevmode\uncover<3->{2.} & \leavevmode\uncover<3->{Observation 2} & \leavevmode\uncover<3->{Conclusion 2} \\  
        \end{tabularx}     
    \end{listliketab}  

\end{frame}  
\end{document}

For the first l column you're not leaving a mode at all (\relax would have done as well) you are just forcing TeX to stop looking for \multicolumn etc. In the X columns you need to stop the look-ahead for spanning columns but in addition you need to start the paragraph so the specials and any other nodes that beamer's magic drops at that position go at the start of the first line of the paragraph and not before the paragraph. You see the same with \color (which is why \textcolor starts with \leavevmode as does \mbox and most other latex commands of this sort.

  • +1 fantastic! Could you describe which modes we're leaving and entering? – cmhughes May 9 '12 at 21:20
  • @cmhughes, answer updated – David Carlisle May 9 '12 at 21:27

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.