My Xuletas for LaTeX!

Those are my "Xuletas", my basic survival guide to LaTeX!!!

Fisrt of all, know that I allways start by modifying an existing doc, so I don't really know LaTeX, I just copy/paste what I need.

WARNING: I can't give any guarantee about the contents of the stuff here, since it is for personal use only!
Also, don't ask questions on the things youi see here, since I probably won't be able to answer them!

Spelling !!

    (with emacs)

Form emacs)
    esc-x: ispell-buffer
From winterm)
   ispell filename
keys: ? -> help
      0-9 -> to replace by option #
      i -> inserts at own dictionary
      space -> ignore

LaTeX codes in eps figs!

    (psfrag)

1) Your EPS figure must have "TAG" words in the positions you want latex.
2) Add an \usepackage{psfrag} at the and of the "\usepackage" section.
3) For each "tag" in the .eps file, add a line like
   \psfrag{tag}{LaTeX text}
   Watch out that the "tag" must be whole strings in the .eps file, no 
   partial replacement is done!
4) When looked with xdvi, it will appear a list of replacements next to 
   the figure. When you make dvips, everithing gets right!!
For more info, see PSfrag documentation!!

LaTeX codes in eps figs!

    (with xfig)

This is an alternative solution to the previous one that comes from (cut & paste) Frederic's page:

Do the drawing using "xfig", and write your text in the usual LaTeX
style. 4 example, a text could be $\int \pi x^2\,dx$. then edit that
text element (through the "Edit panel") changing the "Special Flag"
from "Normal" to "Special" (maybe there is a way to set this flag as
we want by default, by using some resource file, don't know by now),
and obviously, "apply" that change.

fine. when U've got your picture ready for saving, just save it in the
ordinary way (through "File..." + "Save") and also export it in the
next 2 (yes, two) formats:

Combined PS/LaTeX (PS part): 4 example we would obtain the file
"myFigure.pstex" 
Combined PS/LaTeX (LaTeX part): obtaining the file "myFigure.pstex_t"

done? okay. now let's edit accordingly our LaTeX file, which is
expected to use the picture. in order 2 avoid extra work (that is,
editing a file generated by "xfig"), you are requested to define a new
command (this is only necessary @ Girona):

   \newcommand{\epsfig}{\psfig}

and finally use it: 

   \input myFigure.pstex_t
or
   \begin{figure} [hbtp]
    \centerline{\input myFigure.pstex_t}
    \null\vspace{-7mm}
    \caption{\small {\em My caption.}}
    \label{fig:myFigure}
   \end{figure}
or
   \begin{figure} [hbtp]
    \begin{center}
     \begin{tabular}{cc}
      \input myFigure.pstex_t & \input myFigure.pstex_t \\
      \input myFigure.pstex_t & \input myFigure.pstex_t
     \end{tabular}
    \end{center}
    \null\vspace{-7mm}
    \caption{\small {\em Other caption.}}
    \label{fig:figures}
   \end{figure}
or ...

Important note: The \centerline doesn't seem to work fine when we have
text in LaTeX font in the outer parts of the figure. An awful trick to
avoid that is to draw a line in the xfig figure with width=0 with a
length being what you think would occupy the text. Obviously then
\centerline will work okay, but remember you have that somehow
"invisible" line in your image when you edit it for changes.

Including JPG figures !!

    (to take as little disk space as possible)

You can use xv to transform jpg->eps, but the file would be hughe!!
or... 
(This trick is courtesy of frederic, see ~frederic/blah/src/environment.GI.blah!!)
1) Convert .jpg to the eps with jpeg2ps:
   jpeg2ps -h image.jpg > image.jpg.eps
2) Get bouding box with "fgrep" -> name the file image.jpg.eps.bb
   fgrep BoundingBox image.jpg.eps > image.jpg.eps.bb
3) gzip image.jpg.eps
4) Put at the .tex file (once):
  \DeclareGraphicsRule{.jpg.eps.gz}{eps}{.jpg.eps.bb}{`gunzip -c #1}
5) For each image add:
  \includegraphics[width=3cm,angle=270]{image.jpg.eps.gz}
  (angle param is needed because the method puts the images to the side(?))
6) Get ready to have several xdvi hang-ups!!

7) IIF you need to show only A PORTION of the image, change the above line for 
  something like
 \includegraphics[bb=20 20 575 560,clip=true,viewport=25 25 500 500,
                  width=3cm,height=2cm,angle=0]{image.jpg.eps.gz}

  where 
  * bb=llx lly urx ury; enters the coordinates of the bounding box
    manually, if they are missing or incorrect in the graphics file,
    or to be deliberately altered; the specifications are four lengths
    separated by blanks; units may be given, but if omitted, big
    points (bp) are assumed;
  * clip=true forces the clipping of the image
  * viewport=llx lly urx ury; specifies the bounding box but relative
    to the lower left corner of the existing one; useful for
    correcting the bounding box, or (with clip) to select only a
    portion of the whole figure;

GRAPHIX PACKAGE

    (includegraphics)


If one selects the graphicx rather than the graphics package, a
different interface is available for both importing and rotation, one
making use of keys and values:
	\includegraphics[key=value,. . . ]{file_name}
The keys are of two types: those that take a numerical value, and
those that are flags with the values true or false. Simply giving the
name of a flag without a value is equivalent to setting it to
true. Possible keys and their values are:

scale=number; enters the number by which the figure size should be
    magnified over its natural size; width= length; specifies the
    width to which the figure should be scaled to; if height not
    given, it is scaled with the same factor as the width;

height=length; specifies the height to which the figure should be
    scaled to; if width is not given, it is scaled with the same
    factor as the height;

totalheight=length; like height but specifies the height plus depth
    of the figure; should always be used in place of height if the
    figure has been rotated;

keepaspectratio (= true/false); if both height and width are
    specified, this flag ensures that the original height/width ratio
    remains unchanged; the figure will not exceed either of the given
    dimensions;

angle= number; the angle by which the figure is to be rotated
    counterclockwise, in degrees; any height or width specifications
    coming before this key are also rotated, so that the height
    becomes the width, while the width becomes either the height
    (positive angle) or depth (negative angle);

origin= loc; determines the point about which the rotation occurs;
    default is bl for bottom left corner; also possible are c for
    center, t for top, r for right, and B for baseline; any sensible
    combination, such as tr, is allowed;

draft (= true/false); like the draft package option but applied to the
    one graphics file; the figure is not imported, but rather a framed
    box of the correct size is printed containing the name of the
    file;

clip (= true/false); suppresses the printing of any graphic outside
    the bounding box;

bb= llx lly urx ury; enters the coordinates of the bounding box
    manually, if they are missing or incorrect in the graphics file,
    or to be deliberately altered; the specifications are four lengths
    separated by blanks; units may be given, but if omitted, big
    points (bp) are assumed;

viewport= llx lly urx ury; specifies the bounding box but relative to
    the lower left corner of the existing one; useful for correcting
    the bounding box, or (with clip) to select only a portion of the
    whole figure;

trim= dllx dlly durx dury; reduces the existing bounding box by the
    amounts specified; hiresbb (= true/false); like the hiresbb
    package option but applied to the one graphics file; reads
    bounding box information from the %%HiResBoundingBox line in the
    graphics file.

The keys are all optional; they are included as needed. Their order is
not important other than that angle can change previous height and
width meanings. The sets of key/values are separated from each other
by commas.

With the key/value syntax, the tilted, scaled graphic on page 5 is produced with
	\includegraphics[height=2cm,angle=30]{clock.eps}
For compatibility with the graphics package, there also exists an
\includegraphics* version that clips the imported figure; this is
equivalent to including the key clip.

With the graphicx package, the \rotatebox command is similarly
redefined to accept the optional key origin.

Drawing non-continuous lines in tables

    (hhline)

at the beginning:
  \usepackage{hhline}
and at the place you want a full-width line
  \hline
BUT if you want to skip some cells:
  \hhline{|~|-|-|=|}
whete each "|" means a vertical intersection
           "-" means a cell-width single line
           "=" means a cell-width double line
           "~" to skip drwaing a line the with of the corresponding cell!

Tables that need more than one page (multipage tables)

    (longtable)

at the beginning
  \usepackage{longtable}
and, instead of \begin{tabular}{...} ... \end{tabular}
use
   \begin{longtable}{|p{2.5cm}|p{4cm}|p{4cm}|p{4cm}|}
   ...
   \caption{...}
   \label{...}
   \end{longtable}
NOTE: DON'T PUT A longtable INTO A table ENVIRONMENT!!! Use one
INSTEAD of the other! (if you don't, LaTeX won't be able to break the
table properly!)
OTHER OPTION: the supertab package, and using \begin{supertabular} and
\end{supertabular}, but read the manual.

Rotating multipage Tables

    (longtable+landscape)

Basically, there are two ways to have multipage tables in landscape mode: 
a)The ugly, two-pass way:
  \usepackage{longtable, portland}
  and write your table using \begin{landscape}...\end{landscape}
  Print all non-landscape pages in the traditional way: dvips file, ...
  THEN, add the line
  \special{papersize=11in,8.5in}
  To tell dvips to switch to landscape mode. Now, after "dvips file",
  you can print ONLY the landscape pages.


b)The nice way: type at the header
  \usepackage{longtable, lscape}
  and use the table with
  \begin{landscape}
  \begin{longtable}
  ...
  \end{logntable}
  \end{landscape}

Equation Formating

    Multline/eqnarray/array

There are a set of different ways of writting formatted equations:
a) The most primitive one
  \begin{equation}
   \begin{array}{...}
     partA1 & partA2 & ... $ partAN \\
     partB1 & partM2 & ... $ partBN \\
     ...
     partM1 & partM2 & ... $ partMN 
  \end{equation}
b) more evolved:
  \begin{eqnarray}
     partA1 & partA2 & ... $ partAN \\
     partB1 & partM2 & ... $ partBN \\
     ...
     partM1 & partM2 & ... $ partMN 
  \end{eqnarray}
c) If you only have to split the equation in several lines:
  \begin{multline}
    partA \\
    partB
  \end{multline}
d) To avoid numbering the equations, use instead
  eqnarray*
  multline*