0

When I try to compile the following code in Texstudio I get error Undefined control sequence \begin{document}. I think it is related with caption. I tried everything, my texstudio is updated.

\documentclass{beamer}
\mode<presentation> {
\usetheme{Madrid}
\usefonttheme{professionalfonts}
}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{caption}
\usepackage[font={small,it}]{caption}
\title{Mathematics }
\subtitle{Progress report(Mini-presentation) }
\begin{document}
\section{Introduction}
\begin{columns}[T]
    \column{.3\textwidth}
    Stratification frequency is calculated by
    \begin{equation} N=\sqrt{-\frac{g}{\rho_a}\frac{d\rho_a}{dz}} \end{equation} 
    \column{.5\textwidth}
    \includegraphics[width=0.5\linewidth]{fig11}
     \captionof{figure}{Density}
\end{columns}
\section{Conclusion}
\end{document}

I need help on how to fix this error. enter image description here

8
  • 3
    Welcome to TeX.SE! Your document example (MWE: Minimal Work Example) works fine. No errors, no warnings! However, your MWE has some issues: you load caption twice, graphics is loaded by beamer, etc ...
    – Zarko
    Feb 23, 2020 at 22:01
  • I posted my result, Still getting the error message. Very strange!
    – Dereje
    Feb 23, 2020 at 22:11
  • When I take out the caption packages and the caption itself, it compiles with out error (Ofcourse with out the caption).
    – Dereje
    Feb 23, 2020 at 22:17
  • 1
    I overlooked, that you not use frame in your presentation. See my answer below.
    – Zarko
    Feb 23, 2020 at 22:19
  • note the undefined command is not \begin{document} unfortunately texstudio scrambles the error message, you need to look in the log file to see the real error message from Tex, which will show which command is undefined. Feb 23, 2020 at 22:40

1 Answer 1

3

Beamer provide own mechanism for image caption (which not work well with caption package). Its style you can define with \beamertemplate{caption}{...}, \beamerfont{caption}{...}.

I would rewrite your MWE as follows:

  • used is frame environment (it is basic building block of beamer presentations)
  • for image is used figure environment, but it has -- to my opinion -- sense only if you use numbered captions for images
\documentclass{beamer}
\mode<presentation> {
\usetheme{Madrid}
\usefonttheme{professionalfonts}
    \setbeamertemplate{caption}[numbered]
    \setbeamerfont{caption}{size=\scriptsize}
}

\usepackage{mathtools} % it also loads amsmath
\usepackage{amssymb}

\title{Mathematics }
\subtitle{Progress report(Mini-presentation) }

\begin{document}
\section{Introduction}
\begin{frame}
\begin{columns}[T]
    \column{.35\textwidth}
    \bigskip
    Stratification frequency is calculated by
    \begin{equation} 
    N=\sqrt{-\frac{g}{\rho_a}\frac{d\rho_a}{dz}} 
    \end{equation}
    \column{.45\textwidth}
        \begin{figure}
        \centering
    \includegraphics[width=0.5\linewidth]{example-image-duck}%{fig11}
     \caption{Density}
        \end{figure}
\end{columns}
\end{frame}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .