# [t2t] Using templates to implement target LaTeX Beamer

Hi list,


LaTeX beamer is a special LaTeX class to build nice looking presentations. There have been discussion in the the list and on the tracker about adding this as a target for txt2tags. Some patches have also been proposed. Some people have also proposed a bank of pre/postproc rules to generate such files. (see on the tracker)


imho, it would be better to not have such a target in the core of txt2tags. Possible reasons are this is not KISS, as if we do that for the beamer class, why not doing that for other popular classes like report, book or whatever...


However, rules banks are difficult to write and to read. So I would like to introduce a way to get beamer presentations using the basic code for templates that I have just posted on the list.


Here is a non-intrusive and tweaking friendly way of getting the beamer target done. As a proof of concept, I have attached three files,
- beamer.conf.t2t: a config file to convert into the right markup
- beamer.tex : a template file with a basic theme
- talk.t2t: source code for the talk


To get the pdf, you have to do the following commands (with txt2tags patched with template.patch)
txt2tags -C beamer.conf.t2t -T beamer -t tex talk.t2t
pdflatex talk.tex
(I borrowed graphics from the artwork section of the website



In order to not introduce new markup, I have choosen to use the subsections as titles and delimiters for the slides. It has also the advantages that if you simply do a
txt2tags -t html talk
you also get a fairly readable HTML file.


Note that I am not expecting this choice (and others) I have made to satisfy all of you (if any :-) ). My point is more to convince you that, with template files, it is really easy to customize a beamer presentation your way.

Emmanuel

PS: If you intend to modify the template file, be aware that given the special meaning of % in both Latex and Python strings, you should be very cautious and always double the %s in your latex comments (otherwise you will get rather cryptic txt2tags errors: the template patch has to be improved in this regard)
% txt2tags proc for beamer

%% subsections define frame titles
%% dirty hack with <invisible> to close frames
%!postproc(tex): '\\subsection{(.*)}' '\\end{frame}\n\\subsection{\1}\\begin{frame}\n\\frametitle{\1}\n'
%% Carefull with verbatim
%!postproc(tex): '\\subsection\*{(.*)}' '\\end{frame}\n\\subsection{\1}\\begin{frame}[containsverbatim]\n\\frametitle{\1}\n'

% beamer is OK with default itemize
%!postproc(tex): '\\begin{compactitem}'	'\\begin{itemize}'
%!postproc(tex): '\\end{compactitem}'   '\\end{itemize}'
%% Enumerate yields animations
%!postproc(tex): '\\begin{compactenum}' '\\pause\\begin{enumerate}[<+->]'
%!postproc(tex): '\\end{compactenum}' '\\end{enumerate}'

%% Beamer specifics

% Description Lists are blocks
%!postproc(tex): '\\begin{compactdesc}'  '\\begin{block}<o...@0>{}'
%!postproc(tex): '\\item$(.*)$'	 '\\end{block}\n\\begin{block}{\1}'
%!postproc(tex): '\\end{compactdesc}'  	 '\\end{block}{}'

%!preproc(tex): PAUSE 'LATEXBEAMERP'
%!postproc(tex): LATEXBEAMERP '\\pause'
%!preproc(): PAUSE ''
% Correctly coloured tables
%!postproc(tex):'\\pause\} \\\\' '} \\pause\\\\'
%!postproc(tex):'\\pause \\\\' '\\pause\\\\'
%% Weird but necessary...
%!postproc(tex):'(\\end{tabular})' '\1\\begin{tabular}{c}\\end{tabular}'

\documentclass[table]{beamer}

\usepackage[%(ENCODING)s]{inputenc}  %% char encoding
\usepackage[T1]{fontenc}
\usepackage{lmodern}  %% Better PDF rendering with these fonts
\usepackage{graphicx} %% For graphics
%%\usepackage{paralist} %% no need for compact lists
\usepackage[normalem]{ulem} %% needed by strike
\usepackage{%(STYLE)s}  %% user defined

%% Beamer parameters

\institute{INSTITUTE}
\date{\today}
\pgfdeclareimage{logo}{logo}
\logo{\pgfuseimage{logo}}

\begin{document}
\rowcolors[]{1}{blue!20}{blue!10}
\frame[plain]{\titlepage}
\begin{frame}
\frametitle{Outline}
\tableofcontents[hideallsubsections]
\end{frame}

\begin{frame}<dummy>
%(BODY)s

\end{frame}
\end{document}

The Title
The Sub-title
Author

% The date will be automatically computed by LaTeX
% It can be overidden by a postproc
%!postproc(tex): "\\today" "Mar. 8, 2010"

% Another field: Institute
%!postproc: INSTITUTE "the institute"

% Another field: Logo
%!postproc: LOGO t2tpowered-white

%% Demo special macro
%!postproc: "P A U S E" "PAUSE"

+ Introduction +

++ This is a Slide ++

And the content can be typeset with **regular** txt2tags markup.

You can also use bullet list:
- Oh
- Bullets
- Are //so//
- Nice
- as
- are
- sub-bullets

++ Easy Animations ++

With enumerated lists comes //animations//

+ one
+ two
+ three

PAUSE
The keyword P A U S E  can also be used to explicitly PAUSE
pause...

++ Description Lists are Blocks ++

: Block title
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.
:

++ But They Can Also Be Used As Lists ++

: Item lists
- with
- bullets
: Enumeration lists
+ one
+ two
+ three

++ ++

[octus.png]

++ Table (with Colours) ++

||  column1  |  column2  |
|   val1a     |  val2a   |
|   val1b     |  val2b   |

++ Uncovering Line by Line ++

Just add P A U S E at the end of the line.

||  column1  |  column2   |  colum3  PAUSE
|   val1a     |  val2a    |  val3a   PAUSE
|   val1b     |  val2b    |  val3b   PAUSE
|   val1c     |  val2c    |  val3c   PAUSE

+ Handling Verbatim +

++ Special Slide ++

**Caveats:**
Verbatim text in beamer  can be very tricky to use.

It has to be in a special slide that does not support animations like the
regular slides.

== Solution (Hack) ==

So we use unnumbered title instead (Latex handles


+ Section +

++ A standard slide ++
This is a regular slide with
+ ani
+ ma
+ tions
+


== Solution (Hack) cont. ==

With verbatim

== A Slide with Verbatim ==

You can insert regular verbatim blocks.


this
way



+ Conclusion +

++ Perspectives ++

Still a lot to do...

++    ++

**Thanks for your attention...**
------------------------------------------------------------------------------
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________