10 July 2012

205. Debian, TeXLive and style files: making lecture slides

Because I keep forgetting...(my blog serves as a public notebook). I don't make any presumptions about this being terribly new or relevant to a lot of people.

This post expanded into something quite different from what was indicated by the title:

Here's the short version:
kpsewhich -var-value=TEXMFHOME
$HOME/texmf
ls $HOME/texmf
ls: cannot access /home/me/texmf: No such file or directory
mkdir ~/texmf/tex/latex -p

Copy your style files e.g.
cp lecturestyles/ -R ~/texmf/tex/latex

(sudo) texhash

And here goes the long version:

I hate powerpoint presentations --- even if they are made with latex (time to make it a generic trademark?) but the university I'm working at considers blackboards too old-fashioned. Apparently the maths and physics departments are still fighting the good fight, but my department has rolled over. Why do we let people who don't teach decide how we do things? Anyway...

For my lecturs, slides, seminar talks etc. I'm using a fairly heavily edited version of this
http://robjhyndman.com/researchtips/latex-templates-for-monash/
for making slides. It's served me well for giving seminar talks etc. I'm currently putting together a new course* and it's now becoming more important than ever to make sure I organise my material already from the outset.

So, a few things to do:
1. Organise everything neatly in folders:
main.tex

/lectures/silicon.tex
/lectures/aluminium.tex

images/aluminium/
images/algorithms/opa

etc.

Beware: when you include images in silicon.tex but call silicon.tex via main.tex, the paths are relative to main.tex, i.e. it's not ../images/aluminium/ore.eps but images/aluminium/ore.eps.

2. Finally move the style files from the local folder (i.e. where the tex file is) to the destination indicated by TEXMFHOME variable:


kpsewhich -var-value=TEXMFHOME
/home/me/texmf
ls $HOME/texmf
ls: cannot access /home/me/texmf: No such file or directory
mkdir ~/texmf/tex/latex -p

Copy your style files e.g.
cp lecturestyles/ -R ~/texmf/tex/latex/

(sudo) texhash 

3. Make liberal use of \include{} in latex
Basically -- you have a document with the preamble

\documentclass[14pt]{beamer}
\usepackage[version=3]{mhchem}
\usepackage{array}
\usepackage{color}
\usetheme{styles/Hytex}
 \def\biz{\begin{itemize}[<+-| alert@+>]}
 \def\eiz{\end{itemize}}
 \def\ben{\begin{enumerate}[<+-| alert@+>]}
 \def\een{\end{enumerate}}

\title{Chemistry 3456}
\author{Verahill}
\date{}

\begin{document}
\include{lectures/introduction}
\include{lectures/silicon}
\include{lectures/phosphorous}
\include{lectures/aluminium}
\end{document}

And then you create individual files for each lecture or topic e.g. silicon.tex:

\title{Silicon: spines, shells and minerals}
\begin{frame}
 \titlepage
 \centerline{Department of Chemistry}
 \centerline{\includegraphics[width=8cm]{styles/myunilogo}}
 \centerline{\small\color[rgb]{0.01,0.33,0.58}}
\end{frame}

\section{Silicon}
\begin{frame}
Today's lecture will cover:
biz
\item Bouncy balls
\item Froth reductors
eiz
\end{frame}

without preambles or anything of that sort.

It's still a bit annoying that you can't set the location of the aux, nav, log etc. files in each .tex document since the clutter offends my eyes. But hey, there's a limit even to my grumpiness.

4. \usepackage{}
Try looking for chemistry related packages which are installed on your system
find /usr/share/texlive/texmf-dist/tex/latex/ -name "*.sty"|grep [cC]hem

The ones which show up on my system are:
achemso, mychemistry, chemstyle, chemcompounds, mhchem, chemmacros, chemarrow and chemfig

mhchem is most likely the most useful one:
\usepackage[version=3]{mhchem}
You can either do
\ce{OH-}+\ce{[B(OH)3} $\rightarrow$ \ce{[B(OH)4-}or more elegantly:\begin{reaction}
OH- + B(OH)3 -> B(OH)4-
\end{reaction}
SIunits are good too:
\usepackage{SIunits}
The bond length is 1.1 \angstrom{} at 298\kelvin{} (25 \celsius{})
Chemfig looks very promising for a 2D chemistry drawing package and uses tikz, but it has a fairly steep learning curve (in the sense that you need to familiarise yourself with most use cases before you can do anything - it doesn't necessarily take very long):

\chemfig{C(-[2]H)(-[4]H)(-[6]H)-C(-[2]H)(-[6]H)-H}
draws ethane. The 2, 4, 6 are angles in multiples of 45 degrees. So, there are H at 90, 180 and 360  relative to the first carbon. 0 degrees is parallel to the horizontal, and angles increase as in a normal coordinate system (i.e. counter-clockwise).
In addition, you can do Lewis dot structures:
\chemfig{B(-[3]\lewis{420,Cl})(-[5]\lewis{460,Cl})-\lewis{260,Cl}
The 420 means bar to the left (0), top (2) and left (4). 260 means bar left, bottom and top. There's a lot to learn though...

Lastly, e.g.
\chemfig{*6(-=-=-=)}
draws benzene. The 6 indicates a hexagon and the -=-= the sequence of bonds.


5. Dia for flowcharts and cycles
I tried using tikz to make pretty, native flowcharts and cycling diagrammes, but it was too much work and too hard for lecture slides (I might revisit it for articles)
Instead, the dia package in debian make it easy to quickly make up .eps flowcharts

6. Use inkscape to turn png into eps
A lot of programmes can create eps files from raster formatted image files. However, most of them do a very poor job.

Instead I like using inkscape and have a .sh file for it:
inkscape --verb FileSave --verb FileClose --export-eps=$1.eps $1.png

7. BKChem for more difficult schemes
8. GDIS/povray for nice 3D structures.

9. MOdiagram for MO diagrams. Awesome BUT enabling labels leads to catastrophic failure:
"! Font LGR/cmss/m/n/12=gsmn1200 at 12.0pt not loadable: Metric (TFM) file not found."

You need to install cbfonts which is supposed to be included in texlive (I think). But it seems that some files are missing. Download cbfonts.zip from http://www.ctan.org/tex-archive/fonts/greek/cbfonts. Assuming you downloaded in ~/Downloads.
mv ~/Downloads/cbfonts.zip ~/tmp
cd ~/tmp
unzip cbfonts.zip
cd cbfonts/
sudo cp fonts/* -R /usr/share/texmf/fonts/ 

sudo update-updmap

sudo texhash && sudo updmap-sys
*to all my former lecturers: I am so, so, so truly sorry for not appreciating more how 1) much effort is involved in putting together a course (even a badly prepared one) and 2) as an undergraduate I didn't acknowledge that teaching isn't your main job.

No comments:

Post a Comment