Archive

Archive for August, 2009

Automatically count the number of appendices in LaTeX

August 24th, 2009

This guide will show you how to automatically count the number of appendices in your LaTeX document.

First of all you need to place this code in the preamble of your document:

\makeatletter
\newcounter{numapp}
\newcommand{\numberofapp}{%
    \immediate\write\@auxout%
      {\string\setcounter{numapp}{\the\c@chapter}}%
}
\AtBeginDocument{\AtEndDocument{\numberofapp}}
\makeatletter

The script simply counts the number of \chapter’s started since the environment \appendix is called. The number of appendiced will then be placed in the variable \numapp, thus accesible throughout your document using \thenumapp.

Note: The script should run at least twice, before the variable will produce the correct number of appendices.

Ricehigh LaTeX guides

How to get LaTeX on Linux to coorporate with LaTeX on Windows

August 24th, 2009

When writing in LaTeX it is frequently done in small or larger groups. These groups will typically access the LaTeX files via an SVN-like service, thus it is important that the LaTeX files is accesible and compilable on multi-platform. This guide should help you if you’re having trouble getting LaTeX on Linux to coorporate with LaTeX on Windows.

Starting point:
Computer1:
This is a computer with Windows Vista installed, that uses MiKTeX for LaTeX package sourses and compiler, TeXnicCenter as LaTeX editor, and uses a SVN-folder to share files with the group.

Computer2:
This is a computer with Ubuntu 8.04 installed, that wants to be able to share and compile files within the SVN-folder.

The solution:
All the setup is done on Computer2, the one with Ubuntu installed, because, frankly, there isn’t much configuration available in TeXnicCenter regarding encoding and such.

First of you need to install the following packages, and their dependencies: Texlive, Kile and Okular.
apt-get install texlive kile okular
Remember, you need root access to install packages. In Ubuntu, you do that by:
sudo apt-get install texlive kile okular

Then you need to configure kile, a LaTeX editor for Linux, to use the same character encoding as TeXnicCenter:

Settings:
Choose Editor, Chose Open/Save ,Set Encoding to Western European (iso 8859-1), Set Encode auto to disabled, Set End of line to DOS/Windows

Now you should be able to open and save documents readable to both you and users of the SVN-folder.

Compiling:
You can compile your LaTeX document by pressing the LaTeX in Kile, thus producing a dvi-file. Say you want to produce a pdf-file instead, just press DVItoPDF after you’ve pressed LaTeX.

Ricehigh LaTeX guides , ,