Quarto beamer presentation number sections

362 Views Asked by At

I am building a document in quarto where I am using version 1.3.340. I have installed a LaTeX distribution based on TeX Live tinytex::install_tinytex() where I am using version 0.45.

My document with the YAML is as follows:

---
title: "Title"
format: 
  beamer:
    pdf-engine: xelatex
    number-sections: true
    number-depth: 3
editor: visual
---

## Section

This is the content of the section

### Subsection

This is the content of the subsection

However the sections are not numbered where I am getting the following result:

enter image description here

enter image description here

How can I number the section headings? Is there any mistakes in the code?

2

There are 2 best solutions below

0
luifrancgom On BEST ANSWER

The issue was fixed by Christophe Dervieux (quarto developer) via https://github.com/quarto-dev/quarto-cli/pull/6958. Now you can obtain the desire result.

0
samcarter_is_at_topanswers.xyz On

What you call section and subsection are not a section or subsection. Section is the top level sectioning level in beamer and in quarto you get it with

# section name

If you use lower level headings, e.g. ## or ### in quarto, you get beamer frame titles or block titles. If you are really determined, you can make the frametitle and block title numbered:

---
title: "Title"
format: 
  beamer:
    pdf-engine: xelatex
editor: visual
header-includes: |
  \setbeamertemplate{section in toc}[sections numbered]
  \newcounter{block}
  \makeatletter
  \setbeamertemplate{block begin}{%
    \addtocounter{block}{1}%
    \par\vskip\medskipamount%
    \begin{beamercolorbox}[colsep*=.75ex]{block title}
      \usebeamerfont*{block title}\theblock{} \insertblocktitle%
    \end{beamercolorbox}%
    {\parskip0pt\par}%
    \ifbeamercolorempty[bg]{block title}
    {}
    {\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}%
    \usebeamerfont{block body}%
    \begin{beamercolorbox}[colsep*=.75ex,vmode]{block body}%
      \ifbeamercolorempty[bg]{block body}{\vskip-.25ex}{\vskip-.75ex}\vbox{}%
  }
  \setbeamertemplate{frametitle}{%
    \ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}%
    \@tempdima=\textwidth%
    \advance\@tempdima by\beamer@leftmargin%
    \advance\@tempdima by\beamer@rightmargin%
    \begin{beamercolorbox}[sep=0.3cm,wd=\the\@tempdima]{frametitle}
      \usebeamerfont{frametitle}%
      \vbox{}\vskip-1ex%
      \if@tempswa\else\csname beamer@fteleft\endcsname\fi%
      \strut\insertframenumber{} \insertframetitle\strut\par%
      {%
        \ifx\insertframesubtitle\@empty%
        \else%
        {\usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}\strut\insertframesubtitle\strut\par}%
        \fi
      }%
      \vskip-1ex%
      \if@tempswa\else\vskip-.3cm\fi% set inside beamercolorbox... evil here...
    \end{beamercolorbox}%
  }
  \makeatother
---

# Section

## frametitle

This is the content of the section

### block

This is the content of the subsection

enter image description here