# Problems with # inside a verbatim that's inside a note

I'm trying to use a # character inside a verbatim that's inside a note :

\begin{frame}[fragile]

\note{\begin{verbatim}
#
\end{verbatim}
}

\end{frame}


This produces the following errror :

>   ! Illegal parameter number in definition of \beamer@todo.
>
>   l.5 }


How can I write the # character in a way that doesn't break the latex compilation ?

PS : This is related to the following problem in pandoc : https://github.com/jgm/pandoc/issues/3293

• Welcome to TeX.SX! This will not work at all, since you cannot use the verbatim environment as argument of a macro, here \note (at least it looks as if \note takes an argument). When parsing this argument, # signals a parameter number that has to follow. To solve your problem you have to untangle \note and verbatim environment. – gernot Dec 9 '16 at 15:43

I don't know how to get the particular layout you may desire (no info was given), but the verbatimbox package can be used to get the verbatim content into the \note.

\AtBeginDocument{\setbeameroption{show notes on second screen=left}}
\documentclass{beamer}
\usepackage{verbatimbox}
\usepackage{pgfpages}
\setbeamertemplate{note page}{\insertnote\par}
\begin{document}
\begin{frame}[fragile]
\begin{verbbox}
# verbatim
\material \$%here
\end{verbbox}
\note{\theverbbox}
Here is my slide
\end{frame}
\end{document}