Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how can I replace half an environment by a command?

7 views
Skip to first unread message

pda

unread,
Aug 30, 2010, 3:27:12 PM8/30/10
to
When preparing slides for a talk I use beamer (of course).
I would like to write the slides as follows:

==== Title of first slide ====

content
content
content

==== Title of second slide ====

content
content
content

==== (a new slide with no title) ====

content
content
content

=============

This would make it very easy to produce my slides.
But how can I achieve this in pure (La)TeX?
I would need to define a command '==== #1 ===='
that expands to

\end{frame}\begin{frame}\frametitle{#1}

But of course this does not work, first of all the
equals sign is a delicate character to work with, and
secondly, if I define a command that expands to
\end{frame} this is expanded down to the definition
of the frame environment and gives an error.
Any idea on how to get this? I think this might be
very useful

Piero

Guenter Milde

unread,
Aug 31, 2010, 2:57:17 AM8/31/10
to
On 2010-08-30, pda wrote:
> When preparing slides for a talk I use beamer (of course).
> I would like to write the slides as follows:

>==== Title of first slide ====

> content
> content
> content

>==== Title of second slide ====

> content
> content
> content

>==== (a new slide with no title) ====

> content
> content
> content

>=============

> This would make it very easy to produce my slides.
> But how can I achieve this in pure (La)TeX?

Even if possible, it might not be worth the effort. I suggest either
to use "normal" LaTeX macros or a preprocessor, like the Docutils
beamer extension.

...

> if I define a command that expands to \end{frame} this is expanded down
> to the definition of the frame environment and gives an error. Any idea
> on how to get this?

The beamer layout for LyX (www.lyx.org) uses a command instead of an
environment to start a new slide, so you will find guidance by looking
at a LyX-produced LaTeX file:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
% this default might be overridden by plain title style
\newcommand\makebeamertitle{\frame{\maketitle}}%
\AtBeginDocument{
\let\origtableofcontents=\tableofcontents
\def\tableofcontents{\@ifnextchar[{\origtableofcontents}{\gobbletableofcontents}}
\def\gobbletableofcontents#1{\origtableofcontents}
}
\makeatletter
\long\def\lyxframe#1{\@lyxframe#1\@lyxframestop}%
\def\@lyxframe{\@ifnextchar<{\@@lyxframe}{\@@lyxframe<*>}}%
\def\@@lyxframe<#1>{\@ifnextchar[{\@@@lyxframe<#1>}{\@@@lyxframe<#1>[]}}
\def\@@@lyxframe<#1>[{\@ifnextchar<{\@@@@@lyxframe<#1>[}{\@@@@lyxframe<#1>[<*>][}}
\def\@@@@@lyxframe<#1>[#2]{\@ifnextchar[{\@@@@lyxframe<#1>[#2]}{\@@@@lyxframe<#1>[#2][]}}
\long\def\@@@@lyxframe<#1>[#2][#3]#4\@lyxframestop#5\lyxframeend{%
\frame<#1>[#2][#3]{\frametitle{#4}#5}}
\makeatother
\newenvironment{topcolumns}{\begin{columns}[t]}{\end{columns}}
\def\lyxframeend{} % In case there is a superfluous frame end


Günter

Marc van Dongen

unread,
Aug 31, 2010, 4:37:58 AM8/31/10
to
On Aug 31, 7:57 am, Guenter Milde <mi...@users.berlios.de> wrote:
> On 2010-08-30, pda wrote:

> Even if possible, it might not be worth the effort.

I agree. You can also use sed as a preprocessor.

sed -e 's/^ *==== *\([^ ].*[^ ]*\) *==== *$/\\end{slide}\
\\begin{slide}\
\\frametitle{\1}/' | sed -e 's/^ *==== *==== *$/\\end{slide}\
\\begin{slide}/'

Here I'm assuming the title is meaningful and contains at least two
non-space characters. Also you may have spaces before the first ====
and after the last ====.

Regards,


Marc van Dongen

0 new messages