Search code examples
latexbeamer

citation, tables and equation exceed page width in beamer


I am using Latex for the first time and I am preparing a slide using 'beamer'. What happening is that some of my citations, tables and long equations are exceeding beyond the text width, though it wasn't the problem when the document class was 'article'. My tables aren't long, as one of them has only 3 rows and 6 columns.

The latex codes are

    \documentclass[9pt]{beamer}
\mode<presentation> {
\usefonttheme{serif}
\usetheme{Madrid}
\definecolor{BlueGreen}{cmyk}{0.85,0,0.33,0}
\colorlet{beamer@blendedblue}{BlueGreen!120}}

\usepackage{booktabs} 

\usepackage{caption}


\hypersetup{pdfnewwindow}
\setbeamertemplate{caption}[numbered]
\setbeamerfont{frametitle}{size=\footnotesize}
\setbeamertemplate{navigation symbols}{}
\setbeamercolor{postit}{bg=violet!110}
\usepackage{ragged2e}   %new code

\addtobeamertemplate{block begin}{}{\justifying} 



\usepackage{textpos}


\begin{document}

\begin{frame} \frametitle{\textbf{{\Large Objective}}}
    \begin{itemize}
        \justifying
            \item This package gives you easy access to the Lorem Ipsum dummy text; an option is available to separate the paragraphs of the dummy text. This text \cite{kumar2015method}.
        
        \item The long equation is: 
        \begin{equation} 
        A(\theta,\alpha) = \dfrac{ A*{-(\alpha*A)}\beta*{(\delta-1)} \left(A* \hspace{1mm}\hspace{1mm}C^{-A Z_{H}} \hspace{1mm}C^{-C^{-A *Z_{H}}} \prod_{i=1}^{m-1} \left( \dfrac{ A \hspace{1mm}C^{-A* Z_{u(i)}} C^{-C^{-A* Z_{u(i)}}}}{1- \frac{1}{C-1} (C^{1-C^{-A  Z_{u(i)}}}-1)}\right) \right) }{ \int_{0}^{\infty} C^{-(\alpha *A)}(A^{(\beta-1)} \left( A* \hspace{1mm}\hspace{1mm}C^{-A Z_{H}} \hspace{1mm}C^{-C^{-A Z_{H}}} \prod_{i=1}^{B-1} \left(\dfrac{ A \hspace{1mm}C^{-A Z_{u(i)}} C^{-C^{-A* Z_{u(i)}}}}{1- \frac{1}{C-1} (C^{1-C^{-A* Z_{u(i)}}}-1)}\right) \right) A}  .
        \end{equation}                          
    \end{itemize}
\end{frame}

\bibliography{ref}
\bibliographystyle{plainnat}

\end{document} 

And the contents of the .bib file is:

@article{kumar2015method,
    title={This is the title of the article},
    author={Kumar, Dinesh and others},
    journal={This is Journal},
    volume={2},
    number={3},
    pages={150-180},
    year={2015}
}

Solution

    • If you use the plainnat bib style, you should also load the natbib package. This will automatically allow line breaks

    enter image description here

    • you don't need the caption package, beamer provides it's own mechanism to customise captions

    • you must place the bibliography inside a frame

    • for the very large equation, I would suggest to replace the fraction with (...) \times (...)^{-1}, this way you can split it over multiple lines. In addition you'll probably want to use a smaller font size and maybe remove all the manual spaces.


    \documentclass[9pt]{beamer}
    \mode<presentation> {
    \usefonttheme{serif}
    \usetheme{Madrid}
    \definecolor{BlueGreen}{cmyk}{0.85,0,0.33,0}
    \makeatletter
    \colorlet{beamer@blendedblue}{BlueGreen!120}
    \makeatother
    }
    
    \usepackage{booktabs} 
    %\usepackage{caption}
    
    
    \hypersetup{pdfnewwindow}
    \setbeamertemplate{caption}[numbered]
    \setbeamerfont{frametitle}{size=\footnotesize}
    \setbeamertemplate{navigation symbols}{}
    \setbeamercolor{postit}{bg=violet!110}
    \usepackage{ragged2e}   %new code
    
    \addtobeamertemplate{block begin}{}{\justifying} 
    
    
    \usepackage{natbib}
    
    \usepackage{textpos}
    
    \begin{document}
    
    \begin{frame} \frametitle{\textbf{{\Large Objective}}}
        \begin{itemize}
            \justifying
                \item This package gives you easy access to the Lorem Ipsum dummy text; an option is available to separate the paragraphs of the dummy text. This text \cite{kumar2015method}.
            
            \item The long equation is:                        
        \end{itemize}
    \end{frame}
    
    \begin{frame}
    \bibliography{ref}
    \bibliographystyle{plainnat}
    \end{frame}
    
    \end{document}