How to set font in Beamer

If you are not satisfied with the font themes that ship with Beamer, you can use any font family you want for your Beamer document. The font family you intend to use has to be available as a package. For example, to use the Helvetica font family include:

\usepackage{helvet}

The font theme has to match the style of the font family, else the resulting document may have a mix of fonts used in it. That is, use the serif font theme for a serif font family and so on. For example, to use the Concrete Math font family (which is serif):

\usefonttheme{serif}     % Font theme: serif
\usepackage{ccfonts}     % Font family: Concrete Math
\usepackage[T1]{fontenc} % Font encoding: T1

Sometimes, a font encoding may also have to be specified for the font family. For example, the T1 font encoding for Concrete Math font family in the example above.

Advertisements

Font themes in Beamer

A Beamer font theme represents the style of the font used in the document. Beamer comes with the following predefined font themes:

  • default (This is sans serif)
  • professionalfonts
  • serif
  • structurebold
  • structureitalicserif
  • strucutresmallcapsserif

To set the font theme for a Beamer document use the \usefonttheme command in the preamble of the document.

For example to set the font to serif:

\usefonttheme{serif}

Gmail: Mark All Incoming Email as Read

Since I have been following Inbox Zero for quite a while now, the only email seen in my inbox are unread email. If there is new email when I open Gmail, it is acted upon immediately or moved to other labels (folders) for later action. So, there is no point of the read-unread status of email in the inbox for me. Also, I do not like to see my inbox showing a unread count or seeing new email in the unread style (bold fonts).

In short, I would like all my incoming email to be marked as read. Since Gmail has no setting to do this, here is how I use a filter to achieve the same:

  1. Create a new filter. In the Has the words field enter is:unread and press Next Step ยป.


  2. Gmail pops up a dialog warning that this is not recommended and should it continue? Press OK.


  3. Check the Mark as read option and press Create Filter.


Python: Product of Elements of a List

Python has a built-in function to find the sum of the elements of a list:

alist = [10, 3, 8]
sum(alist) # 21

But, there are no such built-in functions for other arithmetic operations. Defining such arithmetic functions that operate on sequences like lists is easy.
Here is how to write a method that gives the product of the elements of a list:

import functools
import operator

def product(seq):
    """Product of a sequence."""
    return functools.reduce(operator.mul, seq, 1)

Python: __lt__()

If you try to sort a list of objects of your own class …

class Foobar:
    def __init__(self, idx):
        self.idx = idx
        return

fooList = [Foobar(10), Foobar(2)]
fooList.sort()

… you get a TypeError error:

TypeError: unorderable types: Foobar() < Foobar()

Python is reporting that it does not know how to compare Foobar objects.

Define a __lt__() method in the Foobar class. This rich comparison method is preferred over the generic __cmp__() method.

class Foobar:
    def __lt__(self, other):
    """Less-than comparison."""
    return self.idx < other.idx

C++: Initialize STL Vector with Array

A STL vector does not have any constructor that looks like it accepts an array. So, the straightforward way to initialize a vector with an array looks like:

#include <vector>

int arr[ARR_LEN] = { /* Array elements */ };
std::vector iVec;
for (int i = 0; i < ARR_LEN; ++i)
    iVec.push_back( arr[i] );

That is too much code for a simple initialization! Thankfully, there is another way do it with less code.

The constructor vector(InputIterator begin, InputIterator end) which initializes a vector with the elements of the range [begin, end) can be used with arrays too. This is because array pointers have all the properties required of an (input) iterator:

#include <vector>

int arr[ARR_LEN] = { /* Array elements */ };
std::vector<int> iVec(arr, arr + ARR_LEN);

Note that the second argument arr + ARR_LEN is beyond the last element of the array and thus behaves as the correct end().

Windows 7: Shared Folders Management

In Windows 7, shared folders do not have an overlay icon on them indicating they are being shared. The reason for this change is explained by Raymond Chen here:

Given the changes in how people use computers, sharing information is becoming more and more of the default state. When you set up a HomeGroup, pretty much everything is going to be shared. To remove the visual clutter, the information was moved to the Details pane. What’s more, a single overlay cannot express the different ways an item can be shared, so in order to figure out what the deal is, you have to go to the Details pane anyway.

So, the best place to view your shared folders and to stop sharing them (after the sharing love is over) is the Shared Folders MMC. It can be invoked by typing fsmgmt.msc at the Start menu.