JeT
**Context**

To shoot a video, I will use a beamer presentation (hence my previous [question](https://topanswers.xyz/tex?q=2029) about half frames... the other half is for me).

I am asked to provide a script with what I'll say.

notes seem to be the correct tool for that.

However, I would also need (for subtitles) to provide a complete script.

**Where I need help**

I tried to export the content of each note to a \jobname-mynotes.tex file thanks to [newfile package](http://mirrors.ctan.org/macros/latex/contrib/newfile/newfile.pdf)

I am stuck on 3 points
1. a beamer \newcommand that mimic \notes<>{} but exports its contents
1. add the document \section and \subsection in the output document.
1. open and close the output after the dcument begins and before it ends. I suspect etoolbox to be involved, but I am lacking of practice on this package.

**What I've tried so far**

![QuestionExportNotesBeamer.png](/image?hash=633575ceff895ab3ed6684a80fdb37c1101ca26de0ac5bce8d41fcae3a8c9f8f)

MWE


\documentclass{beamer}
\usepackage{newfile}
\usepackage{lipsum}

\setbeameroption{show notes}
\setbeameroption{show notes on second screen=right}
%\setbeameroption{show only notes}

\newcommand<>{\mynote}[1]{
\note<#2->{%
#1 % I still want to display the text in beamer
\addtostream{mynotes}{#1} %and also want to export it
}
}

\begin{document}

%Open the stream
\newoutputstream{mynotes}
\openoutputfile{\jobname-mynotes.tex}{mynotes}

\section{First section}
\subsection{First subsection}

\begin{frame}
\begin{itemize}
\item<1-> talk about something
\item<2-> talk about other thing
\end{itemize}

\note<2>{Just some text, not command}

\end{frame}

\subsection{Second subsection}
%% I get an error when I try to use \mynote
%\begin{frame}
%	\begin{itemize}
%		\item<1-> talk about something
%		%\pause
%		\item<2-> talk about other thing
%	\end{itemize}
%
%	\mynote<1>{\lipsum[1]}
%	\mynote<2>{Just some text, not command}
%
%\end{frame}

\closeoutputstream{mynotes}
%close the stream

\end{document}




samcarter
> 1. a beamer \newcommand that mimic \notes<>{} but exports its contents

If you only use notes inside the frame environment, you could add the stream to \beamer@inframenote and then just use the normal \note macro

(patching \note is a bit tricky because it is defined differently depending on the context)

> 2. add the document \section and \subsection in the output document.

You could use




> 3. open and close the output after the document begins and before it ends. I suspect etoolbox to be involved, but I am lacking of practice on this package.

Indeed, etoolbox comes in handy for this:


\AtBeginDocument{\newoutputstream{mynotes}\openoutputfile{\jobname-mynotes.tex}{mynotes}}

\AtEndDocument{\closeoutputstream{mynotes}}


---


\documentclass{beamer}
\usepackage{newfile}
\usepackage{lipsum}

\setbeameroption{show notes}
\setbeameroption{show notes on second screen=right}
%\setbeameroption{show only notes}

\makeatletter
\renewcommand<>{\beamer@inframenote}[2][]{%
\ifbeamer@inlecture%
\only#3{%
\def\beamer@temp{#1}%
\ifx\beamer@temp\beamer@itemtext%
\expandafter\gdef\expandafter\beamer@noteitems%
\expandafter{\beamer@noteitems\item#2}%
\else
\expandafter\gdef\expandafter\beamer@notes%
\expandafter{\beamer@notes#2}%
\fi%
}%
\fi%
}
\makeatletter

\AtBeginDocument{
%Open the stream
\newoutputstream{mynotes}
\openoutputfile{\jobname-mynotes.tex}{mynotes}
}

\AtEndDocument{
\closeoutputstream{mynotes}
%close the stream
}

\begin{document}

\section{First section}
\subsection{First subsection}

\subsection{Second subsection}
%% I get an error when I try to use \mynote
\begin{frame}
\begin{itemize}
\item<1-> talk about something
%\pause
\item<2-> talk about other thing
\end{itemize}
%
\note<1>{\lipsum[1]}
\note<2>{Just some text, not command}
%
\end{frame}

\end{document}


Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.