jgm / pandoc

Universal markup converter
https://pandoc.org
Other
33.94k stars 3.34k forks source link

number-sections not applying in beamer output #9099

Open cderv opened 11 months ago

cderv commented 11 months ago

It seems LaTeX template does not differentiate section numbering with Beamer or not

https://github.com/jgm/pandoc/blob/a19cd39a6fae3f5595c7935fbc83d4edc82300d8/data/templates/default.latex#L312-L316

This means that with this test.md file

---
title: "Title"
---

## Section

This is the content of the section

### Subsection

This is the content of the subsection

and using pandoc 3.1.8

pandoc.exe -f markdown -t beamer -o test.pdf --number-sections -s test.qmd

we get \setcounter{secnumdepth}{3} in the tex file but it seems to have no effect

image

There is no error of --number-sections not working with beamer, and though no numbering.

Not sure how to number section in beamer, so don't know if \setcounter{secnumdepth}{3} is really supposed to work.

jgm commented 11 months ago

Technically these are not sections but slides. (In the LaTeX source you have \begin{slide}, not \section.

cderv commented 11 months ago

Definitely more accurate. Thank you. Aim is to number slides' headers. Should I understand that --number-sections is expected to have no effect for beamer output then ?

I am just observing no specific message that it will have no effect, and from the default.latex template, the conditional with numbersections applies and insert \setcounter{secnumdepth} inside LaTeX source. I was surprised about this.

jgm commented 11 months ago

Check the beamer manual to see if there's a way to number slides?

samcarter commented 10 months ago

If you'd like to number the frame titles, you could redefine the frametitle template and include the frame number there:

\documentclass{beamer}

\makeatletter
\setbeamertemplate{frametitle}{%
  \ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}%
  \@tempdima=\textwidth%
  \advance\@tempdima by\beamer@leftmargin%
  \advance\@tempdima by\beamer@rightmargin%
  \begin{beamercolorbox}[sep=0.3cm,left,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

\begin{document}

\begin{frame}
\frametitle{Title}
test
\end{frame}

\end{document}