2003-10-04 22:12
Visitors since 29-Mar-2000

LaTeX
[lay:tech]

LaTeX is a language for typesetting documents. If you are already using it you may find some of these things useful.


Shortlinks


Links

The homepage for the currently most active version of LaTeX.
This article is heavily biased towards LaTeX. It raises some good points though that everyone should recognise.
One-stop-place for the usual stuff.
This is a very good intruduction into writing documents in LaTeX. If you read through this and understand it you are well on your way to create really nice documents in LaTeX.
Essential LaTeX
Introduction to writing LaTeX. I have not had the chance to have much of a look at it myself yet.
A gentle introduction to TeX
This is the paper on how to get started with plain TeX
How to use graphics and colour in your documents to make them even more nice on the screen and printer.
Want to use your windows fonts in LaTeX? No problem, you can but you have to convert them first. Have a look here.
Web interfaced CTAN, here is where you will find most TeX related material.
MikTeX
This is probably one of the best versions for windows that is free.
LaTeX2HTML
Translates LaTeX documents into HTML equivalents.
IDVI

Java applet for displaying TeX exactly like it should look on the web. Very interesting applet if you want to publish your paper on the net.


Abbreviations

PDF = Portable Document Format, developed by Adobe is a convenient way of publishing documents on the net. It will always look the same printed and on screen.

DVI = Device Independent, a format LaTeX generates which can later be converted to PDF or Postscript, viewed on screen, printed etc.


Windowsed?

If you are running windows 95/98 or NT there is a great (La)TeX package out there called MikTeX which you should get and install.

There is a nice editor called WinTeX2000 that you might like to have a look at as well. I prefer Emacs myself, but if you are not familiar with Emacs I suggest you try something more windowslike. Notepad or wordpad works pretty well too.


 


--------------------

LaTeX Page

Tips & Tricks for the beginner...Space is the limit



Good style for articles and mails

You can download and toy with my private template for making technical documentation. Please if you make any nice changes to it, share it with me. Email me a copy please!

The document needs some non-standard LaTeX things. You need to find and install a copy of "fancyheadings.sty". If you are supposed to make use of the hyperlinks in your PDF's and such I recommend you get epstopdf converter so that you can enjoy your logotypes and pictures in PDF.

I also have a small template for business mails if you are interested in this kind of thing.


Getting rid of orphans and widowed words

Sometimes when you typset something in LaTeX you will find that a single word or a few of them ends by them selves on an otherwise blank page. This is called "orphans" if it is at the bottom of a page or "widowed" if they are at the top in typographic lingo and is generally something that TeX handles pretty well (at least better then Word), but in some occasions it still happens.

You can avoid this by setting the following penalty values

\clubpenalty=9999
\widowpenalty=9999

This makes it rather hard for LaTeX to "break the rule" and typeset orphans or widows. However it is still possible in some situations they will still occur.

It is not recommendet to set this to 10000, bad things can happen then when LaTeX can never break this rule.


Three digit chapter numbers in the TOC

It was for me. I am typesetting a book with roman numbers (I, II, III) as chapter numbers and when there are more then two letters for the chapter there is a problem because the chapter name will then overwrite the last letter.

Like in "XIV A chapter name", the A will overwrite the V of the roman number. I found this crude but effective solution to the problem:

  1. copy the book.cls to a your own layout file (like mybook.cls)
  2. edit the \newcommand*\l@chapter[2]{% section :
  3. change "\setlength\@tempdima{1.5em}%" to "\setlength\@tempdima{2em}%"
  4. this adds another space to the number

The number {2em} can of course be changed to anything you like in order to make it typset the chapter numbers nicely.


Swedish style of typesetting?

I have written a swedish style ichiswedish.sty to be used with LaTeX to typeset swedish documents. It calls upon babel and does various other things so you do not need to do that yourself. It makes for saving some time when writing a document. You can download it here.

Ideas for this style comes from various sources, among those usenet groups and others.


Footnotes inside tables...

This is a little bit tricky, but I have found a solution that works even if it is not a very nice one. It's a bit crude, but effective.

Inside the table where you want the marker to be, place a \footnotemark there. Then outside of the table place a \footnotetext Now, for each footnote you do this way you need to keep track of the footnotemark/footnotetext pairs yourself. As I said, a bit crude.

In plain TeX you can use \footnote and \vfootnote in the same manner.


Numbering of sections and TOC-depth

LaTeX autonumbering is usually a good thing and works very well. There are however certain instances when this is not what you want and you might like to turn it off. The best way of doing that is to set the counter secnumdepth in the preamble of your document:

\setcounter{secnumdepth}{0}          

This will make section and down numberless. Parts and chapters will still be numbered, to avoid this change the 0 to -1 and so on. Try it out it works all right.

In a similar way you can set tocdepth to the number you want. Standard is 3, you can increase this to get more into the table of contents or lower it to get less.

\setcounter{tocdepth}{1}

Adding space between a float and its caption

Sometimes the space is too little when you have done some modifications to a figure or table or something else with a caption. The lengths \belowcaptionskip and \textfloatsep can be used to cure this.

\addtolength{\belowcaptionskip}{6pt}

Fancy headings package

The fancy headers package is a great package for changing the headers and footers of your document. There is a lot to say about this, but what you need to do is this:

Place this in the preamble of your document:

\usepackage{fancyheadings}
\pagestyle{fancy}

Then set up the pagestyle as you want it by using this template code and filling in whatever you wish here:

%% Setting up pagestyles for ``fancy''
\chead{}
\rhead{\sl Page \thepage}
\lhead{\sl My document}
\headrulewidth 0.5pt
\footrulewidth 0.5pt
\lfoot{\scriptsize \copyright Me, Myself and I}
\cfoot{}
\rfoot{\tt \scriptsize http://welcome.to/ichimusai}

As you can see \thepage gives you a page number. There are similar commands that will give you section numbers, chapters etc. as well. Have a look at the documentation for the fancy headers package if you want to know more about this.


Barchart Package

Get the file bar.sty from your closest CTAN archive FTP server and install it by copying it to the apropriate directory where your LaTeX installation sists. (You can find a suitable place by searching for other .sty files).

Now you are set to use it. Try this code:

\begin{figure}[hb]
\begin{center}
\begin{barenv}
\setwidth{20}
\setdepth{0}
\setstretch{6}
\setnumberpos{up}
\setxaxis{0}{7}{1} \setxname{$n$}
\setyaxis{0}{30}{2} \setyname{$F(n)$}
\bar{0}{0}
\bar{1}{1}
\bar{3}{2}
\bar{6}{3}
\bar{10}{4}
\bar{15}{5}
\bar{21}{6}
\bar{28}{7}
\end{barenv}
\end{center}
\caption{Example diagram}
\end{figure}

Writing a letter

Writing letters in LaTeX is rather simple, there are functions that will help you to put things where they should go, and this is the template I usually use myself.

\documentclass[12pt]{letter}
\pagestyle{plain}
\usepackage{a4}
\usepackage[ansinew]{inputenc} 
\usepackage[swedish]{babel}
\sloppy
\nonfrenchspacing
\renewcommand{\baselinestretch}{1.0}
\address{
your name\\
Your address1\\
Your address2\\
your address3\\
}

\signature{}
\begin{document}
\begin{letter}{
Receivers name\\
Receivers address 1\\
Receivers address 2\\
Receivers address 3\\
}

%% Actual letter goes here

\opening{Regarding}

% letter here
\closing{Sincerely,\ }

%% If you have things to enclose, specify here
%\encl{Encl. 1}
%\encl{Encl. 2}

\end{letter}

\end{document}

Writing your own environments

To write your own environments is not very hard or hairy at all. Any TeXnician should become familiar with the simple steps you need to learn in order to expand and extend the environments of LaTeX.

It is particularly useful when you are trying to create your own styles for quoted material, writing a protocol or anything like that.

Here is how you define a new environment:

\newenvironment{mycitation}
{% This is the begin code
    \begin{quotation}
    \begin{enumerate}
}
{% This is the end code
     \end{enumerate}
     \end{quotation}
}

As you can see, the \newenvironment command takes three arguments. The first is the name of the new environment, the second is the start of the environment and the last is the closing of the environment.

The above environment will cause a new environment called mycitation to be created. It looks like the ordinary quotation environment but it is numbered. You can use this whenever you want to put a citation in the text. If you do not like the looks of this, then you only need to change your definition in one place of the LaTeX source, not everywhere.


Changing the spacing of paragraphs

Put this early in your document to change how paragraphs are shown. The two lines below will change the environment to show paragraphs the way they are typeset in letters.

\setlength{\parindent}{0pt}
\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex} 

The parindent length determines how far the paragraphs first line will be indented in print. The second one sets how much vertical space there will be in.

Don't put this before you have a table of contents or similar autogenerated insertion because it will definitely screw that up. If you still need this, the very least you have to do is to put the parskip back to 0pt again.


[Search] [Sign guest book] [Read guest book]

©2003 Ichimusai