LaTeX Tips

Specify a font for the whole document
To change the default font to sans serif just type this at the beginning of your tex file:
\renewcommand{\rmdefault}{cmss}
Here are some fonts:
cmr   serif font (default)
cmss  sans serif font
cmtt  typewriter font (fixed width)
cmb   light serif font
Specify fontsize of section headlines
To change the fontsize of the section headline type this at the beginning of your tex file:
\usepackage{sectsty}
\sectionfont{\LARGE}
In fact, you prepend \LARGE to the headline. You can also create italic headlines:
\sectionfont{\Huge\it }
To change the style of other headlines, just type:
\subsectionfont{\Large}
\subsubsectionfont{\Large}
\paragraphfont{\large\it}
\subparagraphfont{\normalsize\it}
Customize header and footer with the fancyhdr package
You can customize header and footer with the package fancyhdr. With this package you can define 3 justified parts in headers and footers: left, center and right:
\usepackage{fancyhdr}
\pagestyle{fancy}
\rhead{\large\bfseries My LaTeX Document}  %  right header: document title
\lhead{G. Smith}                           %   left header: document author
\cfoot{\large\thepage}                     % center footer: page number
You can also define horizontal lines. Add these commands to the above:
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.0pt}       % no line at footer
It is possible to create different headers and footers for equal and odd pages in a two-sided document. Use the more general command \fancyhf. To specify the parts of header and footer these selectors can be combined in the square brackets:
L - left / C - center / R - right
E - equal page / O - odd page
H - header / F - footer
Here is an example (see the result as image):
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.0pt}
\fancyhf[ROH,LEH]{\large\bfseries My LaTeX Document}
\fancyhf[REH,LOH]{\large\nouppercase\leftmark}        % \leftmark prints the current section
\fancyhf[ROF,LEF]{\large\thepage}
\fancyhf[REF,LOF,C]{}
For more information refer to the fancyhdr Manual. On my Linux system it is located at /usr/share/texmf/doc/latex/fancyhdr/fancyhdr.dvi.
Change itemize labels
You can use \renewcommand{\labelitem... for this. Just add these lines at the beginning of your file:
\renewcommand{\labelitemi}{\fbox{I'm a bullet!}}    % this is stupid ;-)
\renewcommand{\labelitemii}{$\circ$}
\renewcommand{\labelitemiii}{$\bullet$}
\renewcommand{\labelitemiv}{$\star$}
i,ii,iii,iv specifies the depth of the item. You can use any text as label.
Change spacing in itemize environments
Sometimes the spacing between the items of the itemitze (or enumerate) environment seem to be unconvenient. This is how one can create a new itemize environment that has a parameter to control the spacing:
% new itemize environment with itemsep parameter
\newenvironment{myitemize}[1][0]
  { \begin{itemize}
    % set spacing between items
    \addtolength{\itemsep}{#1\baselineskip}
    % set spacing between lines
    \addtolength{\baselineskip}{#1\baselineskip} }
  { \end{itemize} }
See the result as image. This tip has come from here.
Create source listings with the listings package
You can create eye-candy source listings with this package. This is a small example document:
\documentclass{article}
\usepackage{listings}
\begin{document}
  \begin{lstlisting}[language=C,numbers=left,xleftmargin=2em,stepnumber=1,frame=single]
  int main(int argc, char **argv)
  {
         return 0;
  }
  \end{lstlisting}
\end{document}
This package has many features like frames, numbers, captions and syntax highlight for a wide range of languages. I prepared a more complex example and its result as image. For more information refer to the listings Manual. On my Linux system it is located at /usr/share/texmf/doc/latex/listings/listings.dvi.
Create presentations with LaTeX and PPower4
PPower4 is a post processor for pdf files to create effects useful for presentations, such as adding or removing objects, transitions and fancy backgrounds. Together with pdflatex and a hand full of TeX style file, you can create really good presentations (demo from the PPower4 homepage).
Here is a quick installation guide: That's all! Now you can test your setup. To create an example presentation, do:
% wget http://www.ctan.org/tex-archive/support/ppower4/examplee.zip
% unzip examplee.zip 
% pdflatex exm2.tex
[lots of output]
% ppower4 exm2.pdf result.pdf
[some output]
% xpdf result.pdf
For more help, examples and manuals refer to these websites:
[ addr: 38.107.191.114 | cnt: 116052 | usr: 68ms | sys: 32ms ]