crossz

Archive for the ‘latex’ Category

lyx: change Bibliography to Reference

In howto, latex on December 1, 2008 at 5:17 pm

\renewcommand{\bibname}{References}

lyx: insert unnumbered chapter/section to Table of Contents

In howto, latex on December 1, 2008 at 5:06 pm
Just like metioned here:
http://wiki.lyx.org/FAQ/Unsorted1#toc11

To insert unnumbered chapter:
\addcontentsline{toc}{chapter}{THECHAPTERNAME}

To insert unnumbered section:
\addcontentsline{toc}{section}{THESECTIONNAME}

Multiline Formulae in LaTeX and lyx

In howto, latex on January 22, 2008 at 6:39 pm

Cited from: http://www.maths.tcd.ie/~dwilkins/LaTeXPrimer/Multiline.html

Consider the problem of typesetting the formula

[GIF Image]

It is necessary to ensure that the = signs are aligned with one another. In LaTeX, such a formula is typeset using the eqnarray* environment. The above example was obtained by typing the lines

\begin{eqnarray*}\cos 2\theta & = & \cos^2 \theta - \sin^2 \theta \\            & = & 2 \cos^2 \theta - 1.\end{eqnarray*}

Note the use of the special character & as an alignment tab. When the formula is typeset, the part of the second line of the formula beginning with an occurrence of & will be placed immediately beneath that part of the first line of the formula which begins with the corresponding occurrence of &. Also \\ is used to separate the lines of the formula.

Although we have placed corresponding occurrences of & beneath one another in the above example, it is not necessary to do this in the input file. It was done in the above example merely to improve the appearance (and readability) of the input file.

The more complicated example

[GIF Image]

was obtained by typing

If $h \leq \frac{1}{2} |\zeta - z|$ then\[ |\zeta - z - h| \geq \frac{1}{2} |\zeta - z|\]and hence\begin{eqnarray*}\left| \frac{1}{\zeta - z - h} - \frac{1}{\zeta - z} \right|& = & \left|\frac{(\zeta - z) - (\zeta - z - h)}{(\zeta - z - h)(\zeta - z)}\right| \\  & = &\left| \frac{h}{(\zeta - z - h)(\zeta - z)} \right| \\ & \leq & \frac{2 |h|}{|\zeta - z|^2}.\end{eqnarray*}

The asterisk in eqnarray* is put there to suppress the automatic equation numbering produced by LaTeX. If you wish for an automatically numbered multiline formula, you should use \begin{eqnarray} and \end{eqnarray}.

#############################################
For Lyx, in the menu of Insert > Math > Eqnarray Environment, here it's easy to input multiple-line equation.

Lyx: equation numbering ALT+M N

In howto, latex on January 22, 2008 at 2:09 pm

LATEX is at its best when handling mathematical equations. Using LyX, you can get those perfect
equations with relatively little effort. There are two ways of entering equations. The first is to
use the menus. The “math” submenu in the “insert” menu contains everything you need. The
only problem is that it is clumsy, and only suitable for very beginning users. Far better is to
use the keyboard. The Alt-m key sequence gives you pretty much everything you need to create
equations. Let us try to create the following equation:


1. First enter the “Descriptive Math Mode” by pressing Alt-m d which starts an equation on
a separate line.
2. The terms on the left side involve fractions. A fraction is entered by typing Alt-m f (“f”
for fraction). To enter the ¶ symbol, type Alt-m p (“p” for partial). So type
Alt-m d Alt-m f Alt-m p A Alt-m p z
The takes you to the denominator field, while the leaves the fraction
and allows you to enter the next term.
3. The second term involves a subscript. This is done by typing “_”. So the second term is
entered as:
+ v_G Alt-m f Alt-m p A Alt-m p t
5
The “v_G” entry creates vG.
4. The third term involves superscripts. This is done by typing “^”. So the third term is
entered as follows:
+ iD Alt-m f Alt-m p^2 A Alt-m p t^2
Notice the “Alt-m p^2” and the “t^2” entries. These create the second derivitives.
5. The term on the right involves a Greek letter and vertical bars. These are entered as follows:
= Alt-m g g |A|^2 A
Here the “Alt-m g” sequence selects the Greek keyboard, where “abcde. . . ” become
“abcde. . . ”. The vertical bar is just directly typed in as seen above.
6. Finally, we want to give the equation a number. By default, LyX does not number equations.
If you want to add a number to an equation, just put the cursor into the equation
and type Alt-m n. The equation number is automatically generated, and is guaranteed to be
in proper sequence, with proper respect paid to style. If you want to remove an equation
number, just type Alt-m Shift-n.
However, the only real reason to number an equation such as Eq. (1) is to refer to it in the
text. In that case, we can’t just add a number, we have to give that number a meaningful
label. This is done by placing the cursor in the equation, and typing Alt-i l, which opens
up a dialog box where you can give the name of the label, say “eq:maineq” (by default,
LyX will put “eq:” as part of an equation label to keep it from being confused with a
section label or a figure label or any other label). Once you have done that, you can refer
to that equation elsewhere by typing
Eq. Alt-i r and selecting “eq:maineq”

That is pretty much it. There is much more you can do, like creating matrices, integral signs etc.
But the essence of the math mode in LyX is what we just did. But look at the result (type Alt-x
p) and see the quality of the typesetting that we have painlessly obtained. The Alt-m keyboard is
summarized below for quick reference:

############################
Normally, equation with label will be numbered automatically.

Lyx: equation numbering ALT+M N

In howto, latex on January 22, 2008 at 2:09 pm

LATEX is at its best when handling mathematical equations. Using LyX, you can get those perfect
equations with relatively little effort. There are two ways of entering equations. The first is to
use the menus. The “math” submenu in the “insert” menu contains everything you need. The
only problem is that it is clumsy, and only suitable for very beginning users. Far better is to
use the keyboard. The Alt-m key sequence gives you pretty much everything you need to create
equations. Let us try to create the following equation:


1. First enter the “Descriptive Math Mode” by pressing Alt-m d which starts an equation on
a separate line.
2. The terms on the left side involve fractions. A fraction is entered by typing Alt-m f (“f”
for fraction). To enter the ¶ symbol, type Alt-m p (“p” for partial). So type
Alt-m d Alt-m f Alt-m p A Alt-m p z
The takes you to the denominator field, while the leaves the fraction
and allows you to enter the next term.
3. The second term involves a subscript. This is done by typing “_”. So the second term is
entered as:
+ v_G Alt-m f Alt-m p A Alt-m p t
5
The “v_G” entry creates vG.
4. The third term involves superscripts. This is done by typing “^”. So the third term is
entered as follows:
+ iD Alt-m f Alt-m p^2 A Alt-m p t^2
Notice the “Alt-m p^2” and the “t^2” entries. These create the second derivitives.
5. The term on the right involves a Greek letter and vertical bars. These are entered as follows:
= Alt-m g g |A|^2 A
Here the “Alt-m g” sequence selects the Greek keyboard, where “abcde. . . ” become
“abcde. . . ”. The vertical bar is just directly typed in as seen above.
6. Finally, we want to give the equation a number. By default, LyX does not number equations.
If you want to add a number to an equation, just put the cursor into the equation
and type Alt-m n. The equation number is automatically generated, and is guaranteed to be
in proper sequence, with proper respect paid to style. If you want to remove an equation
number, just type Alt-m Shift-n.
However, the only real reason to number an equation such as Eq. (1) is to refer to it in the
text. In that case, we can’t just add a number, we have to give that number a meaningful
label. This is done by placing the cursor in the equation, and typing Alt-i l, which opens
up a dialog box where you can give the name of the label, say “eq:maineq” (by default,
LyX will put “eq:” as part of an equation label to keep it from being confused with a
section label or a figure label or any other label). Once you have done that, you can refer
to that equation elsewhere by typing
Eq. Alt-i r and selecting “eq:maineq”

That is pretty much it. There is much more you can do, like creating matrices, integral signs etc.
But the essence of the math mode in LyX is what we just did. But look at the result (type Alt-x
p) and see the quality of the typesetting that we have painlessly obtained. The Alt-m keyboard is
summarized below for quick reference:

############################
Normally, equation with label will be numbered automatically.

Headers in latex

In howto, latex on November 29, 2007 at 8:41 pm
The GNU Revision Control System is generally considered a tool for software development, but it is also useful for tracking revisions of text documents. This article explains how to include and format RCS keywords in LaTeX documents, and how to track document revisions using these keywords.

Most discussions of the GNU Revision Control System occur in the context of tracking source code revisions. But RCS can track revisions of any type of file, text or binary, provided that the diff utilities which generate RCS change files can handle binary data.

RCS seems ready-made for working with LaTeX input files. The pre-defined keyword identifiers built in to RCS are easy to format and print. They provide ready information that can include the document’s author, its revision, filename, and, revision log entry. RCS also provides facilities for user-defined identifiers.

RCS is commonly included with the development software of Linux distributions. The latest source code version of RCS is available from ftp://prep.ai.mit.edu/pub/gnu and its mirror sites.

The ident(1) manual page has a list of the standard RCS keywords that are generated when documents are checked out by RCS. They include:

* $Author: lg $: The login name of the person who checked in the revision.
* $Date: 2002/10/09 22:24:18 $: The date and time the document was checked in.
* $RCSfile: latex.html,v $ The basename and extension of the RCS file.
* $Id: latex.html,v 1.2 2002/10/09 22:24:18 lg Exp $: String containing the name of the RCS file, the revision number, date and time, author, state, and locker if any.
* $Revision: 1.2 $: The document’s revision number.
* $Log: latex.html,v $
* Revision 1.2 2002/10/09 22:24:18 lg
* Remove all lg_toc##.html; change hyperlinks to index.html
*
* Revision 1.1.1.1 2002/08/14 22:27:03 dan
* Preliminary.
*
* Revision 1.1.1.1 1997/09/14 15:01:51 schwarz
* Imported files
* The log message entered when the document was checked in.

These keywords are included verbatim in documents. They are expanded when the document is checked out with co(1).

One consideration that needs to be taken into account is that the keywords’ dollar signs are interpreted by LaTeX (and TeX) as starting and ending math-mode typesetting. LaTeX and TeX will not generate an error when it encounters the dollar signs. However, because LaTeX and TeX typeset equations differently than normal text, the results can be unpredictable.

For example, including the $Id: latex.html,v 1.2 2002/10/09 22:24:18 lg Exp $ string at the top of the odd pages the commands

\pagestyle{myheadings}
\markright{$Id: latex.html,v 1.2 2002/10/09 22:24:18 lg Exp $}

results in the expanded RCS $Id: latex.html,v 1.2 2002/10/09 22:24:18 lg Exp $ string to be printed at the top of the pages, but some of the keywords run together because of the way TeX formats the string. An alternative is to use the keywords of the individual identifiers, and separating them with the appropriate command. Here, the TeX command \hfil inserts the necessary space when the keyword strings are typeset in the running head.

\pagestyle{myheadings}
\markright{$Date: 2002/10/09 22:24:18 $\hfil$RCSfile: latex.html,v $\hfil$Revision: 1.2 $}

The string given to the \markright command will be typeset with the date in the upper left of the page, the filename centered, and the revision number at the top right.

The \markright command is all that’s needed for printing on one side of a sheet. For printing on both sides of the page, use the \markboth command.

\pagestyle{myheadings}
\markboth{$Date: 2002/10/09 22:24:18 $\hfil$RCSfile: latex.html,v $\hfil$Revision: 1.2 $}{\thepage}

The first argument to \markboth prints the RCS information at the tops of the left-hand pages and the page number at the top of the right-hand pages. The identifier \thepage is a standard LaTeX variable which prints the page number.

The RCS log message can be placed anywhere in a document that the $Log: latex.html,v $ Revision 1.2 2002/10/09 22:24:18 lg Remove all lg_toc##.html; change hyperlinks to index.html Revision 1.1.1.1 2002/08/14 22:27:03 dan Preliminary. Revision 1.1.1.1 1997/09/14 15:01:51 schwarz Imported files keyword can be inserted. For example, to place a (short!) log message in the margin at the beginning of a document, put the command \marginpar{$Log: latex.html,v $ \marginpar{Revision 1.2 2002/10/09 22:24:18 lg \marginpar{Remove all lg_toc##.html; change hyperlinks to index.html \marginpar{ \marginpar{Revision 1.1.1.1 2002/08/14 22:27:03 dan \marginpar{Preliminary. \marginpar{ \marginpar{Revision 1.1.1.1 1997/09/14 15:01:51 schwarz \marginpar{Imported files \marginpar{} immediately after the \begin{document} command, or after the \maketile command if the document has a title page and you’d rather have the RCS log text annotating the body text of the document.

The RCS information can be included in the documents footer by using the fancyhdr package, which is available from any TeX archive site.

If you want to include the $Date: 2002/10/09 22:24:18 $ and $Revision: 1.2 $ keywords at the bottom of a page, you could include

\usepackage{fancyhdr}
\fancypagestyle{rcsfooters}{%
\fancyhf{}
\fancyhead[C]{thepage}
\fancyfoot[L]{$Date: 2002/10/09 22:24:18 $}
\fancyfoot[R]{$Revision: 1.2 $}

in the document preamble; that is, before the \begin{document} command. At the point you want the RCS data to be typeset, insert the commands

\thispagestyle{rcsfooters}
\pagestyle{rcsfooters}

ident(1) also searches files for RCS keywords. Typing the command ident term-paper.tex for example, will print a list of the keywords and their values to standard output. It’s a simple matter of typing ident *tex | grep “fred” – to search for the documents which were last checked out by user fred.

For further information, consult the manual pages of the various programs in the RCS package, and the rcsintro(1) manual page for an introduction to the RCS system.

Powered by ScribeFire.

lyx+beamer for presentation

In latex, linux, software on November 9, 2007 at 7:58 pm

lyx, very powerful latex tool, whose author is the person who started KDE project.

However lyx is not so clever, for instance, when you installed ‘latex-beamer’, it can not find the relative document class and style files. You must go to TOOLS->RECONFIGURE to find the new installed stuff.

Latex is famous for the feature of no worries about layout while concentrating on the contents you are writing.
Beamer is a kinda plugin to enable you concentrate on the contents of your presentation. Here I attached the template of latex-beamer.

latexbeamer.pdf

lyx+beamer for presentation

In latex, linux, software on November 9, 2007 at 7:58 pm

lyx, very powerful latex tool, whose author is the person who started KDE project.

However lyx is not so clever, for instance, when you installed ‘latex-beamer’, it can not find the relative document class and style files. You must go to TOOLS->RECONFIGURE to find the new installed stuff.

Latex is famous for the feature of no worries about layout while concentrating on the contents you are writing.
Beamer is a kinda plugin to enable you concentrate on the contents of your presentation. Here I attached the template of latex-beamer.

latexbeamer.pdf

Files about Latex

In howto, latex on October 17, 2007 at 3:39 pm

There are also files that are created by LaTeX2e, the .aux file, the .toc file and the .bib file. The .aux (auxiliary) file is where LaTeX stores all the information about the counters (like section numbers), footnotes, bibliography entries, reference marks, and anything else that LaTeX may need to keep track of. This file is written over whenever a file is typeset by LaTeX. Whenever a document is typeset LaTeX reads this file to get the information it need, and writes to it after typesetting is completed. This is why changes in the counters will not take effect until LaTeX is run twice, because the .aux file is not up to date the first time. The .bib file is where all the bibliography information is kept. You can either make this file yourself, or you can use BibTeX to create the file. The .toc file contains all the information needed to create the Table of Contents. This file is created when LaTeX sees the command \tableofcontents, and the section names, numbers and page numbers are all read from the .aux file.

latex template

In howto, latex on August 8, 2007 at 3:56 pm

\documentclass{report}%\documentclass[12pt]{report}%seems only 12pt is an option for the class of report, others do not work, so not every number is meaningful and useful for the whole article.

\setlength{\parindent}{0pt} % indent of paragraph

\setlength{\parskip}{10pt} % distance between paragraphs

\setlength{\itemsep}{-5pt}

%\usepackage[top=1in,bottom=1in,left=1.25in,right=1.25in]{geometry}

%% Because here macro:geometry is used, so the following 4 setting is invalid

%\setlength{\topmargin}{0pt}%

%\setlength{\leftmargin}{0pt}%

%\setlength{\rightmargin}{0pt}%

\usepackage{setspace} %linespace

\onehalfspacing % or \doublespacing \setstretch{3}

\usepackage{graphicx}

\title{The Template of Latex Report}

\author{Cross Zheng\\

PhotoPhysics Research Centre\\

London South Bank University\\

\texttt{zhengx@lsbu.ac.uk}

}

% \date{17 Apr 1984}

\begin{document}

\large

%\fontsize{10}{15}%12pt type, with 15pt leading; compared with \large, the latter is easier.

%% the number for size of font is depending on the ‘large’,'huge’,etc,. Not each number is meaningful and useful.

% \maketitle%The title of the “article” with date, not suitable for report,
%% only \title,\author,\thanks,\date are the optional parameters.
%% for report, \titlepage is suitable.

\begin{quote}

Here I just list the commands I always use to decorate my reports…\emph{Cross Zheng}

\end{quote}

\begin{abstract}

without DOUBLE SLASH only emptyline

without emptyline only DOUBLE SLASH \\

DOUBLE SLASH plus emptyline\\

From above we know that DOUBLE SLASH is for newline within a paragrah,

while emptyline is for new paragraph.\\

aaaaaaaaaaaaaaaaaaaa

bbbbbbbbbbbbbbbbbbbb

cccccccccccccccccccc

aaaaaaaaaaaaaaaaaaaa

bbbbbbbbbbbbbbbbbbbb

cccccccccccccccccccc\\

aaaaaaaaaaaaaaaaaaaa\\

bbbbbbbbbbbbbbbbbbbb\\

cccccccccccccccccccc\\

\emph{ So DOUBLE SLASH is for new line and an empty line is for new paragraph}\\

above sentence is emphasized.

\end{abstract}

\tableofcontents

\newpage

\chapter{First Chapter}

\section{Some Formats can be used in paragraph}

\label{someformat}

You may want to write things \textsf{in a sans-serif font},

or \texttt{in a typewriter font}, or \textsl{in a slanted font}

(which is \emph{slightly different} than italics).

Sometimes it pays \textsc{to write things in small capitals}.

You can next go to \textbf{bold and then \textsl{bold and slanted} and

then back to just bold} again.

\subsection{Three ways to emphasize the words}

{\em emphasize Part 1}\\%\\ + emptyline makes a new paragraph, only \\ just newline,andempty line

\emph{emphasize Part 2}\\

\begin{em}

emphasize Part 3

\end{em}

%\indent % Empty line between paragraphs

\subsection{Itemize and enumerate}

\label{itemandenum}

The following is itemize

\begin{itemize} %\setlength{\itemsep}{-\itemsep} %here is for modification of distance between items

\item some days where nothing goes right?

\item times when you just cannot get a decent telephone connection?

\item years when drought follows drought?

\item long periods when gusts of wind come thick and fast?

\end{itemize}

The following is enumerate

\begin{enumerate}

\item start with a bar of some length;

\item then remove its middle third to leave two separate thirds;

\item then remove the middle thirds of these to leave four separate ninths;

\item then remove the middle thirds of these to obtain eight separate twenty-sevenths;

\item and so on.

\end{enumerate}

\subsection{Figure and Table}

\begin{figure}[htp]%[htp] is for absolute position where the figure should appear. otherwize the figure will be on the top of the page.

\centering

\includegraphics[width=0.5\textwidth]{figu.jpg} %%for pdflatex,JPEG is ok. but for dvi, EPS works.

\caption{steps in the construction of a Cantor set.}

\label{F:fig1}

\end{figure}

Construct the tabular set in the following manner:

\begin{table}[htp]%[htp] is for absolute position where the figure should appear. otherwize the figure will be on the top of the page.

\begin{center}

\begin{tabular}[t]{|c|c|} %\begin{tabular}[t]{|l|ccccc|c|} here [t] is vertical alignment,{|l|ccccc|c|} is column alignment.

%\multicolumn{2}{c}{USAMTS Scores Round 1}\\ % some kind of same with previous line,just caption here.

\hline

Object & Dimension \\

\hline

point & 0 \\

The item and enum, \S\ref{itemandenum} & AAAAAAA \\

line & 1 \\

Math and Equation, \S\ref{me} & BBBBBB \\

plane & 2 \\

How to quote, \S\ref{reftoqutote} & CCCCCCC \\

solid & 3 \\

\hline

\end{tabular}

\caption{common Euclidean and fractal objects and their fractal

dimension.}

\label{T:tab1}

\end{center}

\end{table}

\section{Math and Equation}

\label{me}

Here will list some different style of the maths:

\subsection{Embedded Math}

\label{embeded}

\(3\times 3\times 3 + math display style\) \\% \( and \) for math display

alternatively,it can be like this

\begin{math}

3\times 3\times 3

\end{math}

\( N\propto d^{-2} \) a math in para. also it can be embedded in para like this

\begin{displaymath}

\frac{4A}{\pi d^2}

\end{displaymath}

\subsection{Various Equations}

\label{vequ}

The followings are equations:\\

the relation between \(N \) and \( d \) involves a fractional exponent \( D \):

\begin{equation}

N\propto d^{-D}.

\label{eqf}

\end{equation}

Such an object of the fraction \( D \). Here D is math style.

\begin{equation}

s = \frac{\delta+\theta^{2}_{3}}{\left(a+b\right)}

% s = \left(a+b\right)/\deta

\label{equ:a}

\end{equation}

\begin{equation}

s = (\delta+\theta)/\left(a+b\right)*

% s = \left(a+b\right)/\deta

\label{equ:b}

\end{equation}

If any format is unclear, one way is to use TeXnicCenter to generate the codes,

the other way is just to google.

\section{Ref to quote}

\label{reftoqutote}

The Ref mechanism is very powerful. Even section can be quoted in another

para or table easily, no matter the appearing sequence.

In the table~\ref{T:tab1}, three sections are quoted from different

positions\footnote{The sequence is disorder, but the quote still works

properly}.\\

Here I used footnote as another reference style.\\

Of course, the Figure~\ref{F:fig1} and Table~\ref{T:tab1} can be quoted as

normal functions. But Reference is quoted in another way by “cite”, here~\cite{ref2}.

\newpage

\begin{thebibliography}{99}% The thebibliography environment produces a bibliography or reference list. In the article style, this reference list is labeled “References”; in the report style, it is labeled “Bibliography”.

\addcontentsline{toc}{section}{References}% Add a chapter title to the contents page.

\bibitem{ref1} B.~B.~Mandelbrot, \emph{The fractal geometry of

nature}, 1983 .

\bibitem{ref2} H.~Kornberg, \emph{J.\ Irreducible Results}.

\bibitem{ref3} L.~F.~Richardson, somewhere and sometime in the

1920s..

\end{thebibliography}

\end{document}