## Some Tips for Latex

1.

\if(0)

text

\fi

2.
Tips and tricks for LaTeX and friends

From http://fauskes.net/nb/latextips/

TeX, LaTeX, BibTeX and friends, are a constant source of joy and frustration. This growing collection of tips and tricks is an attempt to document some of the things I have learned working with these wonderful tools. This page is just one of many similar LaTeX tips and tricks pages on the net. Hopefully you'll find something useful here.

Numbering
LaTeX enumerates by default all sections. It is possible to disable numbering of a specific section by adding an asterisk (*) after the section command like this:

\section*{Introduction}
\subsection*{Test}However, when you do this, the section is not added to the table of contents. Sometimes you want to disable section numbering but still need to generate a table of contents, or you want to have bookmarks in the generated PDF file. Add this code at the start of your document, and your problem is solved:

% disables chapter, section and subsection numbering
\setcounter{secnumdepth}{-1} Margins
Marginal notes
Notes in the page margins are easily created with the command

\marginpar{marginal note}
Putting stars in the margin
Here's a handy command for displaying a user-specified number of stars in the margin. Useful for ratings and such.

% nstar is a command for drawing n stars in the margin. Useful for ratings.
% Requires the 'ifthen' package
\newcounter{scount} % create counter
\newcommand{\nstar}[1]{%
\setcounter{scount}{#1}% initialize counter
\marginpar{\hfill % move content closer to the main text
\whiledo{\value{scount}>0}
{{\Large{$\star$}}\addtocounter{scount}{-1}}
}
}The stars are not always placed where expected, so some experimentation may be necessary. Here's an example on how to use the \nstar command:

\paragraph{Item A} Regulari quam ti del coalescent \nstar{3}
\paragraph{Item B} Li nov lingua franca va \nstar{2}
\paragraph{Item C} A un Angleso it va \nstar{4}The final result will look like this:

Graphics
How to include graphics in a LaTeX document
Many newcomers to LaTeX find it difficult and confusing to include graphics in LaTeX documents. Common questions are: What format should I use? Why won't my graphics work with PDFLaTeX? What is EPS? Below are a few links to some excellent resources that will answer most of the common questions.

Strategies for including graphics in LaTeX documents
Using Imported Graphics in LaTeX and pdfLaTeX
Graphics for Inclusion in Electronic Documents
Using LaTeX in Matlab graphics
Matlab is a superb tool for advanced plotting of data. It can save graphics in the EPS format, which is perfect for inclusion in LaTeX documents. Matlab has some support for TeX syntax in annotations. However, the result does not look that good and the typography is different from LaTeX's. Fortunately there is a solution to this problem.

LaPrint is a neat Matlab script for saving figures in a LaTeX-friendly format. The script replaces all labels, text and annotations with LaTeX markup, which are subsequently processed by LaTeX. Read all about LaPrint's features in the documentation. Here's a small example of LaPrint in use:

theta = -pi:.1:pi;
y = sin(theta)./cos(theta);
plot(theta,y)
xlabel('$\theta$'); ylabel('$y$')
text(-1,20,'\LaTeX')
set(gca,'XTick',-pi:pi/2:pi)
set(gca,'XTickLabel',{'$-\pi$','$-\frac{\pi}{2}$','0', ...
'$\frac{\pi}{2}$','$\pi$'})
title('$y(\theta) = \frac{\sin \theta}{\cos \theta}$')
laprint(1, 'demofig') % Use LaPrint to save figureThe Matlab code above produces the following figure after some processing by LaTeX.

An interesting alternative to LaPrint is fig2tex. This Matlab script replicates Matlab figures using LaTeX and macros from the PSTricks package.

PDF
Hyperlinks and bookmarks with the hyperref package
One of the nice things about PDF documents is the ability to include hyperlinks and navigation in the document. Hyperref is a package for making documents with live links in PDF and HTML output formats. Here's an example on how to set up hyperref:

\usepackage{hyperref}
\hypersetup{%
pdftitle = {Document title},
pdfkeywords = {pdf, hyperref, bookmarks},
pdfauthor = {Kjell Propell}
}Hyperref has many features for manipulating the generated PDF document. My favourite is the ability to automatically generate tree structured bookmarks from the table of contents. It also inserts hyperlinks to figures, tables and references.

Hyperref defines several useful macros for inserting url's:

Take a look at my \href{http://fauskes.net}{web site}!
See \url{http://www.fauskes.net} for more information. An important thing to remember is that PDF bookmarks don't understand special LaTeX markup. If you use mathematics in for instance a section title, the hyperref will complain. A special macro \texorpdfstring is provided to solve the problem. Example:


※ 来源:·水木社区 newsmth.net·[FROM: 211.99.222.*]

\left. blah \middle| blah \right.

15.
from http://ma-yue.net/archives/110

Last Page Column Equalization

MaYue on 2004-9-13,17:48

Filed under:LaTeX

IEEEtran（用来向IEEE会刊投稿的样式）的style的话，可以使用IEEE提供的
\IEEEtriggeratref{x}命令，这个命令放在bibliography的前面，x就是你想要断开的文

\enlargethispage{-X.Yin}命令来使最后一页的左面栏的长度缩短。这个命令需要放在你

\IEEEtriggercmd{\enlargethispage{-5.35in}}的格式。