# Tex

### From NA-Wiki

## Contents |

## LaTeX related

### Local `~/texmf` tree

If you have downloaded a LaTeX pacakge from the Comprehensive TeX Archive Network and would like to install it but don't have `root` on the current machine. Then as an alternative you can install the package into your `~/texmf` directory.

Remember that you have to run `texconfig` and choose to do a `REHASH` when your installation is complete. Otherwise LaTeX won't find your new packages.

### Figure files

If you have a bitmap file (jpeg, png or simular) and you want to include it in LaTeX do the following to get the best result:

convert input.png eps2:output.eps

The file `output.eps` will be highly optimized by the convert utility.
The convert utility is a command in the Image Magick package.

If you have a huge figure file which is vector based do the following using the eps2bb utility

eps2bb input.eps gzip input.eps

Now you will have the following to files

input.eps.bb input.eps.gz

Just include like normal `\epsfig{figure=input}` and LaTeX will use the `.bb` figure out the dimensions of your compressed eps file and only when runinning `dvips` unpack and render your gzip file.

If you want Matlab to save your figures with a *good bounding box* get
the exportfig packge from Matlab Central.

The command is very simple to use

% plot something exportfig(gcf,'output.eps','color','rgb');

### Tips and tricks

- KTH Beamer templates

- Including graphics from another subdirectory

\graphicspath{{path1/},{path2/},...}

- Using UTF8

\usepackage[utf8]{inputenc}

- Changing algorithmic Require and Ensure to Input and Output

\usepackage{algorithm} % for the Figure environment \usepackage{algorithmic} % the actual algorithm \renewcommand{\algorithmicrequire}{\textbf{Input:}} \renewcommand{\algorithmicensure}{\textbf{Output:}}

- Declaring Math operators

From section 5.1 in ftp://ftp.ams.org/pub/tex/doc/amsmath/amsldoc.pdf:

\operatorname{abc} in a math formula is equivalent to a use of \abc defined by \DeclareMathOperator. This may be occasionally useful for constructing more complex notation or other purposes. (Use the variant \operatorname* to get limits.)

### Insert movies in beamer presentations

The package needed is `movie15.sty` that has a dependency on `ifdraft.sty`. A very good tutorial that follows closely all the steps is:

http://www.math.northwestern.edu/~wphooper/code/latex/mathematica_movie/

### Line Numbers

(From: http://www.bgu.ac.il/~sgabriel/latextips.html LaTeX tips)

In order to have line numbers on the output, consider using the (somewhat buggy, but pretty straightforward) lineno package.

Put \linenumbers to have linenumbers run through the entire document, or \pagewiselinenumbers to have linenumbers reset to 1 at every page. Put either of these commands where you want the linenumbers to begin.