Category Archives: Linux

Creating Printable PDF Flash Cards Using LaTeX

This post details how to make high quality, printable flash cards like I have available at my web site. I am assuming you are using Ubuntu Linux. I did this on Ubuntu 8.04 (Hardy Heron), but it might work on some previous and later versions as well.

First you want to install LaTeX, plus Andrew Budge’s flashcards package. Open a command terminal and type in the following command to install TeX and LaTeX. The flashcards package resides in the texlive-latex-extra Ubuntu package.


$ sudo apt-get install texlive texlive-latex-extra

I also recommend installing Kile which is a great program for editing TeX/LaTeX documents. You can do this with the following command. Depending on your system configuration, apt-get might require you to install several extra packages. The following is optional:


$ sudo apt-get install kile

At this point, if you try to compile a latex document that uses the flashcards package, you’ll get the following error:


! Package geometry Error: You must set \paperwidth properly.

To fix this, we need to create a small file called geometry.cfg, which tells the geometry packages which type of paper we will be using. Create the file using the following command:


$ sudo gedit /usr/share/texmf-texlive/tex/latex/geometry/geometry.cfg

Now copy and paste the following into gedit, save the file and exit from gedit.


%%
%% This is file `geometry.cfg',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% geometry.dtx (with options: `config')
%%
%% File: geometry.dtx Copyright (C) 1996-2002 Hideo Umeki
%% (hideo.umeki@toshiba.co.jp)
%%
%% This package may be distributed under the terms of the LaTeX
%% Project Public License, as described in lppl.txt in the base
%% LaTeX distribution, either version 1.2 or (at your option)
%% any later version.
%%

%% Uncomment and edit the line below to set default options.
\ExecuteOptions{letterpaper,dvips}

\endinput
%%
%% End of file `geometry.cfg'.

Now, you should be able to compile a LaTeX document that uses the flashcards package without errors, but there will be some warnings. To fix the warnings, we need to change one line in flashcards.cls.


$ sudo gedit /usr/share/texmf-texlive/tex/latex/flashcards/flashcards.cls

The following diff command shows the change you need to make:


$ diff -ru flashcards.cls.bak flashcards.cls
--- flashcards.cls.bak 2009-01-26 17:15:27.000000000 -0700
+++ flashcards.cls 2009-01-26 19:43:57.000000000 -0700
@@ -83,7 +83,7 @@
top=\topoffset,
left=\oddoffset,
right=\evenoffset,
- twosideshift=\oddevenshift,
+ twoside=true,
bottom=0.0in,
noheadfoot}
\ifthenelse{\boolean{flashcards@dvips}}{\geometry{dvips}}{}

Now you should be able to compile a LaTeX document without any errors or warnings, excepting for any errors in your own markup of course.

Advertisements

Algebraic Geometry: “Ideals, Varieties, and Algorithms” C++ Code


Ideals, Varieties, and Algorithms book cover
I did an REU (Research Experience for Undergraduates) this summer and we used the textbook “Ideals, Varieties, and Algorithms” (isbn 978-0-387-35650-1) by David Cox, John Little, and Donal O’Shea. As the title mentions, algorithms are an important tool in the study of varieties via their corresponding algebraic ideals. One of the main tools used in algebraic geometry is what is known as a Groebner basis, which is somewhat akin to a basis set in Linear Algebra. Anyway, I wrote some C++ code which implements a few of the algorithms in the book, but stops short of implementing Buchberger’s algorithm for computing a Groebner basis. The code should be useful as a starting point because it implements a Monomial class and a Polynomial class both with lots of useful methods thus eliminating the drudgery of implementing the book’s algorithms in C++.

The code can be found at: my web site as a gzipped tarball. Please let me know if you find it useful. I developed the code on an Ubuntu Linux machine, but it is generic enough that it should compile on any platform. You will need to read the README to understand the simple input, output format.

Cool Ubuntu Desktop Trick

I just discovered that you can switch among open applications by positioning your mouse cursor over any app icon in the bottom toolbar and then scrolling your mouse wheel. Before I would always use Alt-Tab from the keyboard. Now I can use the mouse method when my hands are not on the keyboard.

Kaliope Now Includes Gravitational Potentials

I’ve added a C++ class that handles gravitational potentials to my Kaliope project. Below is a picture of a binary cluster orbiting around a logarithmic potential well. A logarithmic potential is the simplest kind of potential well. It corresponds to an inverse distance radial force field.

spirograph

Here is a slightly different simulation, with each body given its own color, so it is easier to see individual paths:
Spirograph-2