Dear Lyx-list,

I am trying to use Command Sequences to come up with a simple way to
create frames in Beamer without resorting to the use of \lyxframe{} or
repeated copying-and-pasting. My goal is to use a minimal number of
keystrokes to create plain LaTeX \begin{frame}, \frametitle{} and
\end{frame} commands, so as to be able to collaborate with non-LyX
users.

I have tried using Command Sequences and have run into a couple of
problems. My approach was to create two commands:

C-[ would insert the latex code to begin the frame and create a
placeholder for the frame title:
\begin{frame} \frametitle{}

C-] would insert the latex code to end the frame:
\end{frame}

(The choice of [ and ] was arbitrary.)

I created the following Command Sequences in the
Tools-Preferences-Editing dialog box:

command-sequence ert-insert; self-insert \begin{frame}; inset-toggle;
ert-insert; self-insert \frametitle{}; inset-toggle;
This is assigned keyboard shortcut Crtl-[

and

command-sequence ert-insert; self-insert \end{frame}; inset-toggle;
This is assigned keyboard shortcut Ctrl-]

The second (end frame) works as expected. However, the first reverses
the order of the ERT boxes somehow, i.e. the resulting content is
\frametitle{} first followed by \begin{frame}.

Why is the order in which the commands appear reversed in this way?
This seems a little odd, although a simple workaround is to redefine
the sequence as

command-sequence ert-insert; self-insert \begin{frame}; inset-toggle;
ert-insert; self-insert \frametitle{}; inset-toggle;
(Again, assigned to Ctrl-[ )

That works pretty well, but there is one small complication. I was
expecting the resulting LaTex code to be simply
\begin{frame} \frametitle{}

However, initially something else is inserted (at least, visible in
the preview window):
\inputencoding{latin1}\begin{frame}\inputencoding{latin9}\foreignlanguage{english}{\frametitle{}}

Once I save the file, close and reopen, the content of the preview
window is as expected (i.e. all that extraneous stuff is gone), so
perhaps this is not a big deal. However, it leads me to think I am
doing something wrong and in any event it would be nice to have the
code right from the start.

Can anyone point out what I am doing wrong or should be doing differently?

There are a few refinements I would like to attempt eventually (adding
the begin and end frame code with just one command, having the cursor
appear in the frametitle field, having the resulting material in the
LyX document mimic more closely what you get when you import from
LaTex, etc.) and I would welcome any suggestions along these lines,
but I would like to get this basic, sufficient code right first.

Many thanks.

Reply via email to