Categories

CategoryMatlab CategoryLinux CategoryLatex CategoryBeamer

See also

InSilico/LinuxOnWindows InSilico/LecturingWithBeamerLatex/MainStyle?action=raw


Introduction

This note explains the tools and work-flow practices I developed for creating lecture presentation slides and associated materials with LaTeXe-Beamer.

NB: We assume that the reader has a working LaTeX-Beamer system for the lecture notes (i.e. can run bookit, btex and ltex from a linux command line ... if this is not true, see section at the bottom for installation), and purely wants to know what new tools/comands are available to them under the lecture system.

The Lecture Style

The lecture style file (main.style) should be loaded in the preamble of a .tex doc thus:

\input{path/to/main.style}

and provides a number of additional packages (see the file for these, and the specific manuals for their use), plus some short-hand (see below), plus some additional classes that are of use in instructional contexts.

To download (see below)

General Comments

  1. Place all text to go to the slides within FRAMES

    • Example:
    \frame{\frametitle{New idea}
     \bit     % begin itemize
       \item<1-> First point
       \item<2-> Second point
       \item<3-> And so on ...
       \item<3-> etc.
     \eit
     }% eof (end of frame)
    
    • the standard setting of the lecture class is to 'ignore non frame text' when making the slides (only) which is a very nice feature since we can then write anything we like outside of a frame environment to go to the Lecture Book format, but not the slides

    • this is often used to write a short introductory comment about the lecture
    • note: to make a point of some text that is outside of a frame, it is worth using \noteit{}{} (see below) since this is a standardised stylistic mode and can be emphasised just a little more than simple non frame text

  2. Constantly think 'what class is this text?'

    • by setting text inside different class declarations (like the ones below), one can obtain attractive, consistent formatting.
    • moreover, if, at a later date, one wishes to increase (say) the size of the white area for working under the problem in the example class, this can be achieved once (in main.style) and all changes will flow through wherever \solveit{}{}{} is used.

  3. Don't be afraid to tinker with the classes

    • by inspecting main.style one will see that many 'classes' are not very complexly defined, and will yield to simple manipulation.

    • however, if editing, it would be wise to always keep a copy of the original class definition incase you wish to revert to it (in LaTeX this is simply accomplished by commenting out the unwanted portion)

Lecture Classes

Variations on the Block class

The following use the standard 'block' class, which has a header area and a text box below. They vary in that they have quite different outcomes whether in the Slides or Lecture Book (article) version.

Definitions/Theorems

Worked Examples

Danger, Will Robinson!

Extra Notes box

Keywords

Miscellaneous

Final Solution Marker

Chapter reference marker

Student work required

Graphics

To import a picture with a white background (especially Matlab plots)

For putting a picture in columns

Plotting functions on axis

Advanced

See the file for advanced options to quickly draw probability trees etc.

Short-hand

Faster typing of environments

\def\vis{\visible}
\def\adj{\text{adj}}
\def\ben{\begin{enumerate}}
\def\een{\end{enumerate}}
\def\bde{\begin{description}}
\def\ede{\end{description}}
\def\beq{\begin{equation}}
\def\eeq{\end{equation}}
\def\bea{\begin{eqnarray*}}
\def\eea{\end{eqnarray*}}
\def\bit{\begin{itemize}}
\def\ben{\begin{enumerate}}
\def\een{\end{enumerate}}
\def\eit{\end{itemize}}
\def\lra{\longrightarrow}
\def\bce{\begin{center}}
\def\ece{\end{center}}
\def\bco{\begin{columns}}
\def\eco{\end{columns}}
\def\bqu{\begin{quote}}
\def\equ{\end{quote}}
\def\btb{\begin{tabular}}
\def\etb{\end{tabular}}
\def\bma{\begin{bmatrix}}
\def\ema{\end{bmatrix}}
\def\bdm{\begin{vmatrix}}
\def\edm{\end{vmatrix}}
\def\bqu{\begin{quote}}
\def\equ{\end{quote}}

Miscellaneous

\def\mbf{\mathbf}
\def\thf{\therefore \quad}
\def\la{\leftarrow}
\def\ra{\rightarrow}
\def\lra{\leftrightarrow}
\def\imp{\Rightarrow}
\def\trans{^{\intercal}}
\def\inv{^{-1}}
\def\half{\frac{1}{2}}

Matrices

\def\xa{{\color{blue}p_{1} } }
\def\xb{{\color{blue}p_{2} } }
\def\xc{{\color{blue}p_{3} } }
\def\AA{\mathbf{A}}
\def\BB{\mathbf{B}}
\def\CC{\mathbf{C}}
\def\DD{\mathbf{D}}
\def\UU{\mathbf{U}}
\def\LL{\mathbf{L}}
\def\II{\mathbf{I}}
\def\OO{\mathbf{0}}
\def\XX{\mathbf{X}}
\def\AT{\mathbf{A}^{\intercal}}
\def\BT{\mathbf{B}^{\intercal}}
\def\CT{\mathbf{C}^{\intercal}}
\def\xx{\mathbf{x}}
\def\yy{\mathbf{y}}
\def\aa{\mathbf{a}}

Calculus

\def\Dx{\Delta x}
\def\Dy{\Delta y}
\def\dx{\,\, \text{dx}}
\def\dy{\,\, \text{dy}}
\def\dz{\,\, \text{dz}}
\def\du{\,\, \text{du}}
\def\dt{\,\, \text{dt}}
\def\dN{\,\, \text{dN}}
\def\over{\bigg ]}
\def\d{\delta}

Setting up the Lecture-system Scripts

To install

Here we assume that the user is working on either

  1. A native Linux system; or

  2. A Windows PC with cygwin installed (see InSilico/LinuxOnWindows for info on this).

In Windows

  1. Install cygwin as per instructions elsewhere, making sure that a c-shell is installed. To check this, type

 which csh

at the Linux prompt. One should receive a reply such as /bin/csh if all is OK.

  1. Next, within the My Computer application, or similar, find out where the Cygwin apparatus has been installed. (start at C:)

  2. Within this, navigate to: /usr/bin/ and move the latex-beamer-scripts.zip file there, unpacking it (right-click with the mouse and select unzip).

  3. Open up a cygwin terminal prompt (by using the shortcut on the desktop) and check that you can find the tools. For example:

     which btex
    
    at the Linux prompt should return something like

 /usr/bin/btex

In Linux

  1. Simply unpack the scripts into a folder currently on the path. For example, I place such scripts in a new folder called /usr/local/tools/ so that I know what is mine so I would type:

    % mv latex-beamer-scripts.zip /usr/local/tools/
    % cd /usr/local/tools/
    % unzip latex-beamer-scripts.zip
    
  2. Check that these are on the path, for example:
    % cd home
    % which btex
    /usr/local/tools/btex        # should be returned
    

To run

In the /slides folder of your lecture hierarchy, e.g.

 01/
 |-01.tex
 02/
 |-02.tex
 03/
 |-03.tex
 slides/
 |-Beamer01.pdf
 |-Beamer02.pdf
 ...
 book/
 |-book.ps
 |-book.pdf
 ...

simply type btex XX at the linux prompt where XX is the lecture to generate slides for:

% btex 03

Modes of operation: Slides

The standard mode is 'fast' which runs latex, dvips and ps2pdf once in series. This will thus create a .pdf (Beamer03.pdf in our example) which will have most things, but not fancy stuff like the navigation structure etc.

To obtain these, one would type

% btex f 03

to run it in 'final' mode, this runs latex three times to get everything right, before passing it to dvips and ps2pdf.

If things are going badly, then one can run things in 'safe' mode -- which doesn't use the 'batchmode' latex feature (as the others do) and so spews out all the processing log into the active window, this will help greatly for bug-finding. Example:

% btex s 03

For one-off creation of the lecture-book style, but just as standalone articles, one can use ltex in every place where btex was used above. Example

% ltex s 03

Finally, there is an 'accessibility' mode, which uses the extarticle format for the Lecture book (only, not the slides) and so is good for vision impaired students:

% ltex a 03

Modes of operation: Lecture Book

To create the full-blown lecture book is a little more taxing, since we need to chop off the top and tails of each of the .tex documents, concatenate them all into one contiguous document, and then run latex as appropriate over the whole thing.

To achieve the first jobs, we actually use the inbuilt sed program from Linux. It is standard in either a base linux installation, or in cygwin.

Normally, within the /book folder, to generate the Lecture Book style with the first two lectures:

% bookit 01 02

will generate book.pdf in the current folder. Again, one can use

% bookit a 01 02

to generate the 'accessibility' mode version of the book (larger fonts).

To generate a Lecture Book with all lectures within, one needs to list them all:

% bookit 01 02 03 ... 22 23 24

or, since this is quite tedious, one can use the short-cut:

% bookall

which currently will run bookit on lectures 01 ... 24. Or alternatively,

% bookall a

to do them all in 'accessibility' mode.

Should the number of lectures change, then simply open a text editor, and edit the file /usr/local/tools/bookall (for an example path).

Special Script: Worked Examples

Download: solveit files (.zip)

As opposed to the scripts above, to obtain a listing of worked examples (i.e. extract only the \solveit{}{}{} sections of each lecture) and place these in one file, we need to do some more intensive string manipulation.

To achieve this, a set of MATLAB functions are provided:

  1. solveit.m -- main calling function

  2. get_tex.m -- helper function that does the hard work

  3. int2strL.m -- helper function to get lecture numbers as '01', '02' etc. (rather than '1', '2');

To use them, we do something slightly different. All functions should be in the same folder, together with (editable) header and footer information:

  1. solveit.head (or solveit-a.head for accessibility mode)

  2. solveit.foot (or solveit-a.foot)

  3. introduction.tex (introductory script)

A README is supplied within the folder. However, one should have a directory system such as:

 01/
  |- 01.tex
 02/
  |- 02.tex
 styles/
  |- main.style
 solveit/
  |- solveit.m
  |- solveit.head
  |- solveit.foot
  |- introduction.tex
  ...
  |- README

To RUN Solveit.m

  1. (Install and) Open MATLAB;
  2. Navigate to lectures/solveit/ from within MATLAB: >> cd path/to/solveit/

  3. At the MATLAB prompt run one of

     >> solveit(2:23)           % standard
     >> solveit([2 4 5 7 21])   % a selection is fine
     >> solveit([2:15 18],1)    % turns 'on' accessibility mode (large fonts, single column)
  4. This will produce the file solve.tex which should have all of the \solveit{}{}{} arguments from each lecture file in one place. To produce the .pdf one would then need to run latex (probably twice), then get the resultant .dvi file to become a .pdf.

    • On Linux this would be:

       % latex solve.tex
       % latex solve.tex
       % dvips -o solve.ps solve.dvi
       % ps2pdf solve.ps
    • Via WinEDT this would be to use the 'latex' button (twice), then the 'dvi -> ps' button, then the 'ps -> pdf' button.

Bugs

  1. When I run solveit.m it says Didn't find an instance of \solveit in #15..

    • this just means that there was no \solveit{}{}{} used in lecture number 15

  2. When I run latex on solve.tex I get an error part-way through ...

    • this is some kind of formatting problem in the original .tex file .. most of these can be overcome by just typing 'r' at the prompt (if you are from the command line) .. or WinEDT will probably let you just go straight through.

    • if you want to avoid this, you could use batchmode .. which steamrolls through any of these 'minor' problems % latex -interaction=batchmode solve.tex

  3. My file includes instances of solveit{}{}{} that I thought I commented out in the original .tex file!

    • This is a bug introduced in the conversion from the (old) Linux based script to the current current MATLAB only version there is no simple way to not reproduce instances of \solveit{}{}{} that are actually commented out in the original lecture .tex file. This is a potential problem if you are updating and keeping 'old' text in comment form .. so be aware of this.

Files

  1. main.style (.tex)

    • rename to main.style

  2. Latex Beamer scripts (.zip)

Refs

  1. In-depth paper by Angus on the educational philosophy behind the LaTeX-Beamer system

  2. Pst-tricks pst-plot manual

  3. Reverse Polish (postfix) notation at Wikipedia

  4. Online converter of any pic format to .eps


CategoryInSilico

Leviathan: InSilico/LecturingWithBeamerLatex (last edited 2008-07-21 07:46:22 by sangus)