0

How do I add subsection numbers. It always starts from 1. but I want 1.1 and 1.2, etc. And then for subsubsections 1.2.1 etc.

 \documentclass{beamer}
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    \usepackage[mathscr]{eucal}
    \usepackage[utf8]{inputenc} 
    \usepackage[croatian]{babel}
    \usepackage{latexsym}
    \usepackage{tabularx,pstricks,pst-plot,amsfonts,amsmath,tensor,amssymb}
    \usepackage{etoolbox}
    \usepackage{xpatch}
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    \usetheme{Warsaw}
    \usecolortheme{seahorse}
    \usefonttheme{professionalfonts} % using non standard fonts for beamer
    \setbeamertemplate{section in head/foot}{\hfill\insertsectionheadnumber.~\insertsectionhead}
    \setbeamertemplate{section in head/foot shaded}{\color{structure!50}\hfill\insertsectionheadnumber.~\insertsectionhead}
    \setbeamertemplate{section in toc}{\inserttocsectionnumber.~\inserttocsection}

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \newcommand{\nN}{\mathbb{N}} % Oznaka za skup prirodnih brojeva
    \newcommand{\zZ}{\mathbb{Z}} % Oznaka za skup cijelih brojeva
    \newcommand{\rR}{\mathbb{R}} % Oznaka za skup realnih brojeva
    \newcommand{\qQ}{\mathbb{Q}} % Oznaka za skup racionalnih brojeva
    \newcommand{\iI}{\mathbb{I}} % Oznaka za skup iracionalnih brojeva
    \newcommand{\cC}{\mathbb{C}} % Oznaka za skup kompleksnih brojeva
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    \title{Fibonaccijevi brojevi i zlatni rez. Rekurzije. Fraktali}
    \author{Amar Bapić, Merjem Vikalo, Irma Zenunović}
    \date{}
    \institute{Univerzitet u Tuzli\\Prirodno - matematički fakultet\\ Odsjek Matematika}
    \setbeamertemplate{theorems}[numbered]
    \usepackage{multicol}
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    \AtBeginEnvironment{teorem}{%
        \setbeamercolor{block title}{fg=white,bg=red}
        \setbeamercolor{block body}{fg=black,bg=red!40}
    }
    \AtBeginEnvironment{definicija}{%
        \setbeamercolor{block title}{fg=white,bg=blue}
        \setbeamercolor{block body}{fg=black,bg=blue!40}
    }
    \AtBeginEnvironment{primjer}{%
        \setbeamercolor{block title}{fg=white,bg=purple}
        \setbeamercolor{block body}{fg=black,bg=purple!40}
    }

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    \newtheorem{teorem}{Teorem}[section]
    \newtheorem{definicija}{Definicija}[section]
    \newtheorem{lema}{Lema}[section]
    \newtheorem{primjer}{Primjer}[section]
    \newtheorem{conjecture}{Konjektura}[section]
    \renewcommand{\qedsymbol}{\ensuremath{\clubsuit}}
    \newenvironment{rjesenje}{
    \emph{\textbf{Rješenje:}}}{ 
     $\qed $
    }
    \newenvironment{dokaz}{
    \emph{\textbf{Dokaz:}}}{
     $\spadesuit $
    }

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    \begin{document}
    \makeatletter
    \patchcmd\beamer@@tmpl@frametitle{\insertframetitle}{\thesection.~\insertframetitle}{}{}
    \makeatother
    \begin{frame}[plain]
    \titlepage
    \end{frame}
    \section{Rekurzije}
    \begin{frame}{Rekurzije}
    \end{frame}
    \subsection{Podjela ravni pravima. Podjela prostora ravnima.}
    \begin{frame}{Podjela ravni pravima. Podjela prostora ravnima.}

    \end{frame}
    \subsection{Hanojski tornjevi}
    \begin{frame}{Hanojski tornjevi}

    \end{frame}

    \end{document} 
  • where do you want to add the numbers? – user36296 May 26 '16 at 14:46
  • The title that apears in the frame. – zermelovac May 26 '16 at 14:50
1

A bit ugly, but with three conditionals in the frametitle definition, it gives the desired numbers.

 \documentclass{beamer}

 \usepackage{etoolbox}
 \usepackage{xpatch}

 \usetheme{Warsaw}
 \usecolortheme{seahorse}

 \setbeamertemplate{section in head/foot}{\hfill\insertsectionheadnumber.~\insertsectionhead}
 \setbeamertemplate{section in head/foot shaded}{\color{structure!50}\hfill\insertsectionheadnumber.~\insertsectionhead}
 \setbeamertemplate{section in toc}{\inserttocsectionnumber.~\inserttocsection}


 \title{Fibonaccijevi brojevi i zlatni rez. Rekurzije. Fraktali}
 \author{Amar Bapić, Merjem Vikalo, Irma Zenunović}
 \date{}
 \institute{Univerzitet u Tuzli\\Prirodno - matematički fakultet\\ Odsjek Matematika}


    \makeatletter
    \patchcmd\beamer@@tmpl@frametitle{\insertframetitle}{%
        \ifnumgreater{\arabic{section}}{0}{%
            \thesection.%
                    \ifnumgreater{\arabic{subsection}}{0}{% 
                        \thesubsection.%
                                \ifnumgreater{\arabic{subsubsection}}{0}{%
                                    \thesubsubsection.%
                                }{}%
                    }{}%
        }{}%
        ~\insertframetitle{}{}%
    }%
    \makeatother

 \begin{document}

    \begin{frame}[plain]
        \titlepage
    \end{frame}
    \section{Rekurzije}
    \begin{frame}{Rekurzije}
    \end{frame}
    \subsection{Podjela ravni pravima. Podjela prostora ravnima.}
    \begin{frame}{Podjela ravni pravima. Podjela prostora ravnima.}

    \end{frame}
    \subsection{Hanojski tornjevi}
    \subsubsection{test}
    \begin{frame}{Hanojski tornjevi}

    \end{frame}

 \end{document} 

enter image description here

  • Thank you. Also, can you tell me how do I direct to a new page in beamer. All my text is in one frame. Can i generate automatic page break. – zermelovac May 26 '16 at 15:06
  • @zermelovac Yes, there is automatic frame breaking \begin{frame}[allowframebreaks], but be careful: in my opinion it causes more problems than it solves. Rather think about where you want to break your frames and place each content in its own \begin{frame}...\end{frame} – user36296 May 26 '16 at 15:10
  • my problem is that it clashes with my environment: \begin{frame} \begin{rjesenje} \end{frame} \begin{frame} \end{rjesenje} \end{frame} – zermelovac May 26 '16 at 15:14
  • @zermelovac That is the problem of your custom environment. Since it does not really complicate stuff, I would just insert the commands by hand so you can insert \end{frame} – user36296 May 26 '16 at 15:24

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.