# Add a beamer note to a section slide using pandoc and markdown

I am using pandoc to convert markdown to beamer slides. I am using the notes in beamer to make note slides. I have slide-level=3 so that the first two markdown headings are sections. I want the section title frames in the presentation, and I want to be able to add a note on section slides. However, pandoc seems to put the notes into a frame. So for instance:

# First Section
\note{I want a note here}

## First Subsection in First Section

::: notes

Using this also does not work

:::

### First Slide


produces the following LaTeX code from pandoc:

\hypertarget{first-section}{%
\section{First Section}\label{first-section}}

\begin{frame}{First Section}
\note{I want a note here}
\end{frame}

\hypertarget{first-subsection-in-first-section}{%
\subsection{First Subsection in First Section}\label{first-subsection-in-first-section}}
\begin{frame}{First Subsection in First Section}
\note{Using this also does not work}
\end{frame}

\begin{frame}{First slide}
\protect\hypertarget{first-slide}{}


This adds a blank slide after the section slides that then have the note. This is not what I want. If I go into the tex code and delete the frames, the output pdf is what I want (which means that beamer can handle notes in sections without a frame slide):

\hypertarget{first-section}{%
\section{First Section}\label{first-section}}

\note{I want a note here}

\hypertarget{first-subsection-in-first-section}{%
\subsection{First Subsection in First Section}\label{first-subsection-in-first-section}}

\note{Using this also does not work}

\begin{frame}{First slide}
\protect\hypertarget{first-slide}{}


Unfortunately the answers in this question only answer for that specific case, not that general question that was asked. The "hack" here also inserts a frame.

Is there a way to have something passed to into the LaTeX code without a frame?

EDIT: Apparently this is very similar to this question. But it is not the same, because I would like a general solution at any heading level above the slide level.

This was fixed for the single usage of speaker notes in pandoc for beamer in this issue and this commit.

I can confirm this is the exact same issue as pandoc-4317-forces-content-under-title-slides-to-be-included-in-a-frame-in-pand. I used a specific slide level in a mere attempt to simplify my request by anchoring ideas, but pandoc 2.7 onwards introduced the undesired change to satisfy the revealjs crowd. I find this absurd, if I please may, because the change is implemented for consistency sake (sic), but beamer is not meant to have 3D navigation of slides, quite the contrary, imho. It's designed to work with article mode, focusing on .pdf production, for which 3D slides makes zero sense. Fortunately, the offending commit is purely in the file LaTeX.hs, leading to an easy solution...

Since I finally gave up on this after sending multiple emails to JGM and the pandoc list... what is my solution? Maybe overkill, but I simply recompile pandoc!! Using the recommended stack, it's actually beyond smooth, easy, and fast in Windows or i would not recommend. I was totally surprised and not expecting it.

Just replace lines [233-241] in LaTeX.hs, commit f431f67b2f2f5071345fa5800658375afaf44c1b, with

    = return \$ Div (ident,"section":dclasses,dkvs) xs


This change produces a couple of warnings, so i am sure it can be improved, but ain't wasting any further time on this. The executable is produced in pandoc-x.x.x\.stack-work\install\d8f8683f\bin. I copy over to C:\Program Files\RStudio\bin\pandoc.
BINGO!
No more annoying unwanted slides... regardless your level. I can keep my pandoc version uptodate this way. Keen to hear if there's any improvement that can be made to this "hammer to kill the fly" approach.