Archive

Archive for the ‘LaTeX’ Category

Beamer theme creation

June 13, 2013 2 comments

inrabeamerAs mentioned in a previous post , INRA renewed it’s visual identity. Unfortunately no beamer theme was provided. This gave me the occasion to look a bit deeper on beamer’s theme and how to create a relatively simple INRA theme.

I tried to keep things simple. Thus, I first identify the main characteristics of the powerpoint template.

  1. First slide have a green background while others slides have a white background and a logo on the left of the header
  2. General colors for title and subtitle are two specific green (with a precise RGB code)
  3. All the slides contains author name, presentation title, and date in their footer.

Beamer theme are defined through “.sty” files. Here, we’ll create a file named beamerthemeINRA.sty , the later will be used via the command \usetheme{INRA} in our source code. The beamerthemeINRA.sty itself, contain instructions to include sty files each defining a part of the theme.

\ProvidesPackage{beamerthemeINRA}[]
\useoutertheme{INRA}

We will address the solutions I’ve adopted for each of the 3 main points of the INRA theme.

Background

The Background can be changed in the outtertheme, we have to redefine the canvas template and include a background image.

In my case, to get the background, I opened the powerpoint templates, removed any text made  screen-shots of it. The screen-shots were then pasted in gimp, and saved as png. Now, in the file outerthemeINRA.sty we define the images to include in the background. As we’ll use a different background on the first slide, we’ll need a conditional instructions.

\setbeamertemplate{background canvas}{%
 \ifnum\c@framenumber=1%First slide
 \includegraphics[width=\paperwidth,height=\paperheight]{bgINRA1}
 \else%Other slides
 \includegraphics[width=\paperwidth,height=\paperheight]{bgINRA2}
 \fi%
 }

First test, add \usetheme{INRA} in your source code, check bgINRA1 and bgINRA2, and all the sty file are in the current directory. Compile, check your pdf (things should already be pretty close to what you expect).

The title slide is obviously not where it should it should ! We’ll have to tweak the title template. After a quick look at some other beamer theme, and series of trials and errors, I  end out with this bunch of code :

Colors

Colors are generally defined in a beamercolortheme.sty file.

\definecolor{INRA@lgreen}{RGB}{188,214,49}
\definecolor{INRA@dgreen}{RGB}{139,172,33}
\setbeamercolor{structure}{fg=INRA@dinst}

Structure will define the color set for most of the elements of your presentation. We define only the foreground color, since a background colour would hide the upper left logo in the background. Now add \usecolortheme{INRA} to the beamerthemeINRA.sty, compile and check the results.

Footline

Back to the outertheme, we now want to add the author, presentation title and date in the footline. Once again, after a look at other theme, we copy paste code that look close to what we are looking for. Proceed by trial and errors, until obtaining a satisfactory result. For me it gave something like :

%footline
 \defbeamertemplate*{footline}{INRA theme}{
 \begin{beamercolorbox}[wd=\paperwidth,ht=15 pt,leftskip=1.5cm,dp=1ex]{structure.fg}%
 \color{white}\qquad \insertauthor\qquad\color{INRA@linst}\inserttitle \hfill \color{white}\insertdate\par
 \end{beamercolorbox}
 }

Useful resources

The theme is now available on the animal genetics’ forge

In order to create the theme, I googled a lot, here is a stack of useful link I went trough, it might be of interest to you.

Click to access mertz.pdf

http://en.wikibooks.org/wiki/LaTeX/Presentations

http://mcclinews.free.fr/latex/beamermodif.php

http://www.math.umbc.edu/~rouben/beamer/quickstart.html

Click to access beameruserguide.pdf

http://programming-r-pro-bro.blogspot.fr/2011/11/create-your-own-beamer-template.html

Categories: Communication, LaTeX

eMarch 1 : Add AucTeX local variables to your LaTeX file

March 1, 2013 2 comments

trombineI just thought about a fancy way to present some of my favorite emacs tips. So every Friday of marsh, I’ll try to give an emacs tips I like.

English is obviously not my maternal tongue, so I really need some word spelling software. When I first started using LaTeX with emacs, I thought that this was impossible. I was really wrong, in fact if ispell and FlySpell you can have a first help against misspelling. Type in emacs M-x Flyspell-mode. In order to change the dictionnary, type M-X change-dictionnary and choose the correct language.

Second point, if you really want to take advantage of LaTeX power, you should split your source in several files, that will be called from a “main” or “master ” file which in turn have the “\include” instruction to include each of your file. With this scheme, if you edit one file and want to check your output, you should always compile (from) the main file. AucTeX, allow you to declare the master file from its menu (command, Master File).  Then, when you  compile your source code, no matter which file you are visiting, the master file will be compiled.

Now the awesome tips, an even better way to proceed is to add local variables to the end of each of your latex file. Like this :

%%%Local Variables:
%%%TeX-master: "MasterDocument"
%%%End:

The latter indicate that the file “MasterDocument.sty”, is the master file to compile and from which the actual file will be called. Likewise, the following code :

%%%Local Variables:
%%% mode: latex
%%% eval: (TeX-PDF-mode 1)
%%% ispell-local-dictionary: "en_US"
%%% eval: (flyspell-mode 1)
%%%End:

Will ask AucTeX to use pdfTeX for compilation and to switch to the “en_US” dictionary, with flyspell mode enabled by default, every time you open your file.

Note since emacs 24.1 you should use eval to use the Tex-PDF Minor-mode (earlier version allowed the ” %%% mode: Tex-pdf ” syntax).

Categories: emacs, LaTeX, Linux

Myriad and Minion Font for LaTeX

February 14, 2013 1 comment

My new employer, recently changed its “visual identity”. Yes, a new CEO have been designated 6 months ago. I won’t be cynical enough to underline how much this sound like a cliché — changes being first (and sometimes foremost) cosmetic– , or point out that generally people who want to stand out of the crowd, end out doing the exact same thing (like using Minion or Myriad font, which by the way are now pretty common fonts). The aim of this post is to provide some link on how to install these fonts on Linux for people working with LaTeX.

As any anyone, I first asked googled for help, but the answers varied a bit — due to outdated solutions ?  The solution that worked perfectly for me (i.e. using Linux Mint 14, a full install of TeXlive 2012 made through synaptic) was using FontPro, I just followed the instructions in README and had everything running fine.

The MnSymbol package should provide Math fonts for Minion and Myriad, but I still haven’t found how to make it work properly (I instead set eulervm as a math font…more on another post).

Last it sounds like XeLaTex can handle otf fonts natively, but I am still “old school”, working mainly with LaTeX or pdfTeX. Can’t be that geek !

More on the topic here, and for windows users more here

Categories: LaTeX

AUCTeX install made simple

February 6, 2013 Leave a comment

ELPAAUCTeX is my  default LaTeX editor, I admit I may sometime advise people to use the cross platform, shiny and user friendly Texmaker…but come on, the real one use emacs for everything !

One annoying point was that I generally relied on the AUCTeX version available on the my distro repository, whereas, I often add the emacs-snapshot PPA, to benefit from the freshest emacs possible.  Thus I  generally had two versions of emacs installed on my computer, the “normal” one which allow me to use AUCTeX, and the brand new version without this feature.

Fortunately, since emacs 24,  ELPA is now shipped by default, which ease a lot AUCTeX install. Here is the procedure :

  1. M-x list-package
  2. Put cursor on auctex, hit enter
  3. In the new buffer click on install

Did I say, it was a doodle ?  The ELPA is a such a killer feature ! Hope this may help you.

Categories: emacs, LaTeX