星期四, 九月 10, 2009

更多Latex的功能

一,在Latex文档中产生空格
1,
\hspace{xx} 产生xx长的水平空格
\vspace{xx} 产生xx长的垂直空格。

Latex里面的长度单位有:
pt  point         (1 in = 72.27 pt)

pc pica (1 pc = 12 pt)
in inch (1 in = 25.4 mm)
bp big point (1 in = 72 bp)
cm centimetre (1 cm = 10 mm)
mm millimetre
dd didot point (1157 dd = 1238 pt)
cc cicero (1 cc = 12 dd)
sp scaled point (65536 sp = 1 pt)
当换行时,\hspace{xx}产生的空格会被取消,如果要强制指定产生水平空格,用\hspace*;
同理,当换页时,\vspace{xx}产生的空行也会被取消,强制指定用\vspace*。

2,但句子结尾时,'.'后面会自动加上一个空格,当有些情况'.'并不是句子结尾。
比如Mr.Wu, etc.and,这时要在.后加上“\ ”(反斜线+一空格)。

3,换行时latex会自动把词拆开,如果不想2个或个词被拆开放在2行,可以用在词与词之间加上~。

4,\noindent强制不缩进,\indent强制不缩进。

二,列表
1,编号列表:

\begin{enumerate}


\item

A
\item
B
...

\end{enumerate}
将产生一个列表,列表里的子项A和B将被自动标上编号1,2...

2,无编号列表
用itemize代替上面的enumerate,则产生无编号列表。这时编号1,2...将被一个大黑点代替。

3,描述性列表
在编号列表的item后面加上{xx},这时xx将代替编号1,2...作为每个子项的前缀。

三,显示引用
1,\begin{quote} ... \end{quote},整个引用都将缩进,但引用内部的每一段不再缩进,适
合于短引用,比如一段话。
2,\begin{quotation} ... \end{quotation},整个引用都将缩进,而且引用内部的每一段还将按正常格式再缩进。

四,表格
\begin{tabular}和\end{tabular}表示开始和结束。

格式举例:
\begin{tabular}{format}

\hline
$n$&$n!$\\
\hline
1&1\\
2&2\\
3&6\\
4&24\\
\cline{1-1}
5&120\\
6&720\\
&5040\\
8&40320\\
9&362880\\
10&3628800\\
\hline
\end{tabular}
format可以是以下几种值的集合
l 表明对应的列要向左对齐
c 表明对应的列要向中对齐
r 表明对应的列要向右对齐
p{width} specifies a left-justified column of the given width
| 在列与列之间插入一条竖线(即网格)
@{text}在列与列之间插入文本text

(注:如果想要无网格,则format里不加入'|')

\hline表明插入一条水平线。
\cline{x-y}表明从x到y列(包括x和y)加入一条水平线。

&分隔没一行的列,如果要把某一格(即对应某一行某一列)置空,则直接用&跳过。
\\表明换行


合并表格:
\multicolumn{num}{fmt}{text}
num表明总共要占用num列的宽度,fmt为子项的fromat,text表明子项的内容。

下面是一个比较复杂的例子:
[GIF Image]

\begin{tabular}{|l||l|l||l|l|}

\hline
&\multicolumn{2}{l|}{Singular}&\multicolumn{2}{l|}{Plural}\\
\cline{2-5}
&English&\textbf{Gaeilge}&English&\textbf{Gaeilge}\\
\hline\hline
1st Person&at me&\textbf{agam}&at us&\textbf{againn}\\
2nd Person&at you&\textbf{agat}&at you&\textbf{agaibh}\\
3rd Person&at him&\textbf{aige}&at them&\textbf{acu}\\
&at her&\textbf{aici}& & \\
\hline
\end{tabular}

五,Latex的总体格式
一典型的例子:
\documentclass[a4paper,12pt]{article}
\begin{document}
......
\end{document}
1,
documentclass
的样式包括article
, report, book和letter。
方框里的列表为可选的,可以包括:
11pt:字体大小为11个pt
12pt:字体大小为12个pt
twocolumn:输出分为2列
a4paper:输出为A4纸

2,页码
在\documentclass和\begin之间加入\pagestyle{option},option可以是:
plain:页码在底部,这是文章和报告的默认格式
empty:无页码
headings:页码在顶部
myheadings:
Similar to the headings pagestyle, except that the material to go at the top of the page is determined by \markboth and \markright commands

六,自定义宏
这一般用在同一文章中多次出现同一公式的情况下,自定义宏可以省去很多时间.

Defining your own Control Sequences in LaTeX

Suppose that we are producing a paper that makes frequent use of some mathematical expression. For example, suppose that integrals like

[GIF Image]
occur frequently throughout the text. This formula is obtained by typing
\[ \int_{-\infty}^{+\infty} f(x)\,dx.\]  
It would be nice if we could type \inftyint (say) to obtain the integral sign at the beginning. This can be done using\newcommand. What we do is to place a line with the command
\newcommand{\inftyint}{\int_{-\infty}^{+\infty}} 
near the beginning of the input file (e.g., after the \documentclass command but before the \begin{document} command). Then we only have to type
\[ \inftyint f(x)\,dx.\]  
to obtain the above formula.

We can modify this procedure slightly. Suppose that we we defined a new control sequence \intwrtx by putting the line

\newcommand{\intwrtx}[1]{\int_{-\infty}^{+\infty} #1 \,dx} 
at the beginning of the input file. If we then type the line
\[ \intwrtx{f(x)}.\]  
then we obtain
[GIF Image]
What has happened is that the expression in braces after \intwrtx has been substituted in the expression defining \intwrtx, replacing the #1 in that expression.

The number 1 inside square brackets in the \newcommand line defining \intwrtx indicates to LaTeX that it is to expect one expression (in braces) after \intwrtx to substitute for #1 in the definition of \intwrtx. If we defined a control sequence\intwrt by

\newcommand{\intwrt}[2]{\int_{-\infty}^{+\infty} #2 \,d #1} 
then it would expect two expressions to substitute in for #1 and #2 in the definition of \intwrt. Thus if we then type
\[ \intwrt{y}{f(y)}.\]  
we obtain
[GIF Image]

七,定理环境
这多用于数学推导,证明等的文章中。

Theorem Environments

In LaTeX, one can create `environments' for statements of theorems, lemmas, propositions, corollaries, etc., and also for proofs, definitions, examples and remarks. These can be established using appropriate \newtheorem and \newenvironment commands: these commands are best included in the LaTeX input file before \begin{document}. The following code will create theorem,lemma, proposition, corollary, proof, definition, example and remark environments, together with a control sequence\qed which produces `tombstones' for the ends of proofs:

\newtheorem{theorem}{Theorem}[section] \newtheorem{lemma}[theorem]{Lemma} \newtheorem{proposition}[theorem]{Proposition} \newtheorem{corollary}[theorem]{Corollary}  \newenvironment{proof}[1][Proof]{\begin{trivlist} \item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}} \newenvironment{definition}[1][Definition]{\begin{trivlist} \item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}} \newenvironment{example}[1][Example]{\begin{trivlist} \item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}} \newenvironment{remark}[1][Remark]{\begin{trivlist} \item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}  \newcommand{\qed}{\nobreak \ifvmode \relax \else       \ifdim\lastskip<1.5em>
(For an explanation of the syntax of the LaTeX commands used to define the above environments, consult the LaTeX User's Guide and Reference Manual by Leslie Lamport.)

The statement of any theorem can then be enclosed between \begin{theorem} and \end{theorem}. The theorem will be labelled and numbered by LaTeX, and the statement of the theorem with be automatically italicised. Lemmas, propositions and corollaries will be treated similarly.

To introduce cross-references, one can give the command \label{name} within the statement of a theorem, lemma, proposition or corollary in order assign the given name to that result. To reference the number assigned to that result in some other theorem, one gives the command \ref{name}; this will be replaced by the number automatically assigned by LaTeX to that result when the LaTeX program is executed. The necessary space above and below the statement of the theorem will automatically be generated by LaTeX.

The environments and commands introduced above are used in typesetting the following text:

[GIF Image]
This text is typeset from the following LaTeX input:
\begin{definition} Let $H$ be a subgroup of a group~$G$.  A \emph{left coset} of $H$ in $G$ is a subset of $G$ that is of the form $xH$, where $x \in G$ and $xH = \{ xh : h \in H \}$. Similarly a \emph{right coset} of $H$ in $G$ is a subset of $G$ that is of the form $Hx$, where $Hx = \{ hx : h \in H \}$ \end{definition}  Note that a subgroup~$H$ of a group $G$ is itself a left coset of $H$ in $G$.  \begin{lemma} \label{LeftCosetsDisjoint} Let $H$ be a subgroup of a group $G$, and let $x$ and $y$ be elements of $G$.  Suppose that $xH \cap yH$ is non-empty. Then $xH = yH$. \end{lemma}  \begin{proof} Let $z$ be some element of $xH \cap yH$.  Then $z = xa$ for some $a \in H$, and $z = yb$ for some $b \in H$. If $h$ is any element of $H$ then $ah \in H$ and $a^{-1}h \in H$, since $H$ is a subgroup of $G$. But $zh = x(ah)$ and $xh = z(a^{-1}h)$ for all $h \in H$. Therefore $zH \subset xH$ and $xH \subset zH$, and thus $xH = zH$.  Similarly $yH = zH$, and thus $xH = yH$, as required.\qed \end{proof}  \begin{lemma} \label{SizeOfLeftCoset} Let $H$ be a finite subgroup of a group $G$.  Then each left coset of $H$ in $G$ has the same number of elements as $H$. \end{lemma}  \begin{proof} Let $H = \{ h_1, h_2,\ldots, h_m\}$, where $h_1, h_2,\ldots, h_m$ are distinct, and let $x$ be an element of $G$.  Then the left coset $xH$ consists of the elements $x h_j$ for $j = 1,2,\ldots,m$. Suppose that $j$ and $k$ are integers between $1$ and $m$ for which $x h_j = x h_k$.  Then $h_j = x^{-1} (x h_j) = x^{-1} (x h_k) = h_k$, and thus $j = k$, since $h_1, h_2,\ldots, h_m$ are distinct.  It follows that the elements $x h_1, x h_2,\ldots, x h_m$ are distinct. We conclude that the subgroup~$H$ and the left coset $xH$ both have $m$ elements, as required.\qed \end{proof}  \begin{theorem} \emph{(Lagrange's Theorem)} \label{Lagrange} Let $G$ be a finite group, and let $H$ be a subgroup of $G$.  Then the order of $H$ divides the order of $G$. \end{theorem}  \begin{proof} Each element~$x$ of $G$ belongs to at least one left coset of $H$ in $G$ (namely the coset $xH$), and no element can belong to two distinct left cosets of $H$ in $G$ (see Lemma~\ref{LeftCosetsDisjoint}).  Therefore every element of $G$ belongs to exactly one left coset of $H$. Moreover each left coset of $H$ contains $|H|$ elements (Lemma~\ref{SizeOfLeftCoset}).  Therefore $|G| = n |H|$, where $n$ is the number of left cosets of $H$ in $G$. The result follows.\qed \end{proof}

星期一, 八月 17, 2009

LaTeX: Fonts

You will need to define your fonts at the beginning of any LaTeX document. After defining them, you'll only need to use font commands to change the font, for instance to bold or italicize a word or words.

In LaTeX, there are generally three styles within any font family, which are distinguished as font family, font shape, and font series. The commands for family, shape, and series are commutative, so they can be combined as with the command:
{\bfseries\itshape\sfffamily text you want in bold, italics, and sans-serif}

The above command would make the type in bold, italic, and sans-serif. The commands for font can only be combined as long as they aren't contradictory. Contradictory font commands would be trying to get slanted italics, or attempting to combine different font families.

LaTeX expects three font families as defaults.

Font FamilyCodeCommand
Roman (serif, with tails on the uprights) as the defaultrm\textrm{text}
Sans-serif, with no tails on the uprightssf\textsf{text}
Monospace (fixed-width or typewriter)tt\texttt{text}

For the common type shape and series commands, use the simplified syntax in the table below.

Type StyleCommandExample
Italic\textit{words in italics}puts the words in the brackets in italics
Slanted\textsl{words to be slanted}puts a few words in slanted type.
Small Capitals\textsc{words to be in small capitals}puts the words in the brackets in small capitals
Bold\textbf{words to be in bold}puts the words in brackets in bold
Sans-serif\textsf{words to be in sans-serif}puts the words into sans-serif type
Monospace\texttt{words to be in monospace}puts a few words in typewriter type
Emphasis\emph{word}italicizes word(s). When the surrounding text is in italics, LaTeX knows to read \emph{words} as emphasized and so it will unitalicize words when used within surrounding text already in italics.
Monospace{\tt words}Monospaces all words within the curly braces.
Italics{\it words}Italicizes all words within the curly braces.

Font Size

Font size in LaTeX is controlled with font size commands. Please note that you will need to reset the font size with one of these commands after changing it. Also, note that certain commands may overrule the font size commands; for instance, the \end{center} will cancel the font size commands. If you want to select just some text for a size change, use the following commands in the bracket, command, bracket words, close bracket, close bracket syntax; like this: {\huge{short}}. The commands and their sizes are listed in the table below.

CommandNominal Point SizeExact Point Size
\tiny55
\scriptsize77
\footnotesize88
\small99
\normalsize1010
\large1212
\Large1414.40
\LARGE1817.28
\huge2020.74
\Huge2424.88

Changing Fonts

If you use any packages that change the font, those packages will change the default of the same type. For instance, using the Bookman font (which is done by using this command in the preamble:\usepackage{bookman})makes the default Roman font Bookman, but leaves the sans-serif and monospace fonts alone. Similarly, using the Helvetica font (done with this command in the preamble: \usepackage{helvet}) changes the default sas-serif font to Helvetica, but leaves the Roman and Monospace fonts alone. When changing fonts, you can do so like this, using the command and calling the particular font, or you can change all of the default fonts at once with the following commands.

CommandChanges the defaults to
timesTimes, Helvetica, Courier
pslatexsame as Times, but uses a specially narrowed Courier. This is preferred over Times because of the way it handles Courier.
newcentNew Century Schoolbook, Avant Garde, Courier
palatinoPalatino, Helevetica, Courier
palatcmchanges the Roman to Palatino only, but uses CM mathematics

For more on the fonts available with a typical LaTeX installation, please see the documentation in the IMAGE Lab (page 75 in A Beginner's Guide to Typsetting with LaTeX). Also, please note that there are many more fonts available for download.

Changing Fonts Temporarily

To change the font temporarily, first group the text where you want the font changed in curly braces. Then, use the commands \fontencoding, \fontfamily, and \selectfont. These commands should be used immediately inside the opening curly braces, like:

{\fontfamily{phv}\selectfont Helvetica looks like this}
and {\fontencoding{OT1}\fontfamily{ppl} Palatino looks like this}.
}

The above commands would make a sentence where "Helvetica looks like this" would be in the Helvetica font (phv is the code for Helvetica) and "and" would be in the default font and "Palatino looks like this" would be in the Palatino font (denoted with the Palatino code, which is ppl). This example would be very rare, but it shows how the fonts can be changed in the most extreme circumstances.

Font Color

Using the color package (which must be called in the Preamble), you can typeset LaTeX in any color. To add the color package in the Preamble, use the command:
\usepackage{color}

The color package makes a default color package available. The colors available with this are: red, green, and blue (for screen display) and cyan, magenta, and yellow (to go with black for the CMYK color model for printing). To make a single word or phrase in color, use the command:
\textcolor{color}{words to be in color}
For example, \textcolor{red}{text in red}

星期二, 五月 19, 2009

不能访问windows Installer服务的解决办法!

现在安装软件时提示:不能访问windows Installer服务,可能是你在安全模式下运行windows或者windows Installer 没有正确地安装,请和你的支持人员联是以获得帮助。导致任何的软件都无法安装和卸载
一、微软Windows Installer 组件介绍:
微软Windows Installer作为Win2K/WinXP的组件之一,是专门用来管理和配置软件服务的工具。在Win95、Win98、WinMe与WinNT4,0下,作为额外的产品提供,允许用户有效地安装与配置软件产品与应用程序。新的Installer提供给软件产品新的特性,例如使用命令行安装产品、增加了用户的可定制性。
Windows Installer 软件安装技术。该技术包括适用于 32 位 Windows 操作系统的 Windows Installer 服务器,以及一个用于存储有关配置和安装信息的新软件包文件格式。
Windows Installer 不仅仅是一个安装程序,它还是一个可扩展的软件管理系统。Windows Installer 管理软件的安装,管理软件组件的添加和删除,监视文件复原,并通过使用回滚来维护基本的灾难恢复。
此外,Windows Installer 还支持从多个源安装和运行软件,并且可以由要安装自定义程序的开发人员定制。

二、Windows Installer 的功能包括: 
? 在安装失败时将计算机还原为原始状态:Windows Installer 跟踪在程序安装过程中对系统进行的所有更改。如果安装失败,Installer 可以将系统恢复到其初始状态。这称为“回滚”。 
? 帮助防止特定形式的程序之间产生冲突:正在安装或卸载的程序可能会导致计算机上已安装的另一个程序出现问题,甚至导致计算机停止响应(挂起)。Installer 可以强制实施一些安装规则,以帮助防止当安装操作更新由现有程序共享的动态链接库 (DLL) 文件时,或当卸载操作删除由另一个程序共享的 DLL 文件时出现冲突。 
? 诊断并修复损坏的程序:程序可以要求 Installer 确定已安装的程序是否缺少文件,或者文件是否已损坏。然后,它可以要求该服务根据需要再次只复制已发现丢失或损坏的文件来修复该程序。 
? 可靠地卸载现有程序:Installer 可以可靠地卸载以前安装的任何程序,并删除所有相关联的注册表条目和程序文件,但其他已安装的软件所共享的文件及注册表条目除外。 
? 支持按需安装程序功能:可以指示 Installer 首先安装程序的最小子集。之后,在您首次使用需要附加组件的功能时,会自动安装附加组件。 
? 支持无人参与的程序安装:Installer 支持根据管理员的指令使用脚本来安装程序。 
Windows Installer 技术分为以下两部分,它们结合在一起工作:客户端安装服务 (Msiexec.exe) 和 Microsoft 软件安装 (MSI) 软件包文件。Windows Installer 使用软件包文件中包含的信息安装程序。
Msiexec.exe 程序是 Windows Installer 的一个组件。当安装程序调用 Msiexec.exe 时,它使用 Msi.dll 读取软件包 (.msi) 文件,应用任何转换 (.mst) 文件,并合并安装程序所提供的命令行选项。Installer 执行所有与安装有关的任务,包括将文件复制到硬盘、修改注册表、在桌面上创建快捷方式,以及在必要时显示对话框以提示用户输入安装首选项。
在计算机上安装 Windows Installer 后,它将更改注册的 .msi 文件的文件类型,以便当您双击 .msi 文件时,将运行 Msiexec.exe。
每个 MSI 软件包文件都包含一个关系类型的数据库,用于存储在各种安装方案中安装(或卸载)该程序所需的指令和数据。

三、Windows Installer出错的解决方案
  Windows Installer(windows安装服务)是一种通用的软件发布方式,现在许多软件都使用windows Installer作为自己的安装程序,有时因为各种原因以及windows Installer本身的缺陷,会导致windows Installer出错。

  症状一:删除某个程序后,在运行某些软件时,老会弹出一个“windows正在配置Windows Installer,请稍候”的窗口。
  解决办法:
  1、重新安装Windows Installer,office XP安装盘的根目录有两个名为instmsi.exe和InstMsiW.exe的文件,instmsi.exe用于win9X/Me,InstMsiW.exe用于Win2000/XP;
  2、打开组策略→计算机配置→管理模板→Windows组件→Windows Installer→禁用Windows Installer,只是这样一来,很多软件就有能安装了,此法用于Win2000/XP。
  3、请看本文最后的“终级解决方案”

  症状二:Win2000/XP安装软件时提示“无法访问windows安装程序,服务中windows Installer状态为停止,不能启动”
  解决办法:
  1、命令提示符下输入:misiexec /regserver
  2、在“管理工具”→“服务”中启动windows Installer

  症状三:Win2000/XP安装软件时提示“不能访问Windows Installer服务……”
  解决办法:
  1、检查当前用户有无管理员权限;
  2、结束进程Ikernel,exe后再安装;
  3、删除系统安装目录Program FilesCommon FilesInstallShieldEngine下的所有文件再安装。
  4、首先,运行“msiexec /unregserver”,停止Windows Installer服务;
  接着,安装InstMsiW.exe(office XP安装盘的根目录下有,也可以从网上下载,地址为:http://download.microsoft.com/download/WinfowsInstaller/Install/2.0/NT45/EN-US/InstMsiW.exe),用Winrar解压至设定的目录;进入目录,右键点击msi.inf选“安装”,右键点击mspatcha.inf,选安装;
  最后运行“msiexec /regserver”启用服务。

  症状四:安装软件时提示“系统管理员设置了系统策略,禁止进行此项安装”
  解决办法:
  1、尝试用症状三的解决方法;
  2、打开组策略→用户配置→管理模板→Windows组件→Windows安装服务→将“禁止从媒体安装”设为“禁用”,将“永远以高特权进行安装”设置为“启用”

四、以上问题的终级解决方案:
  下载安装微软提供的Windows Installer CleanUp Utility 1.0,它的主要功能是清除程序的Windows Installer配置信息。启动该工具,它会列出目前系统中所有Windows Installer使用安装的软件,选中出问题的软件,然后点“Remove”按钮即可。
Windows Installer CleanUp Utility 1.0下载地址:http://www.onlinedown.net/soft/27518.htm

星期日, 五月 10, 2009

德国新教马丁·尼莫拉牧师的忏悔诗

德国新教马丁·尼莫拉牧师 的忏悔诗 

“在德国,起初他们追杀共产主义者,我没有说话…,因为我不是共产主义者; 
接着,他们追杀犹太人,我没有说话…,因为我不是犹太人; 
后来,他们追杀工会成员,我没有说话…,因为我不是工会成员; 
此后,他们追杀天主教徒,我没有说话…,因为我是新教徒; 
最后,他们奔我而来,却再也没有人站起来为我说话了。” 

――德国新教牧师马丁·尼莫拉Martin Niemöller (1892 - 1984) 

据说有很多不同的中文版和英文版。以下是其中一个英文版: 

THEY CAME FIRST for the Communists, 
and I didn't speak up because I wasn't a Communist. 
THEN THEY CAME for the Jews, 
and I didn't speak up because I wasn't a Jew. 
THEN THEY CAME for the trade unionists, 
and I didn't speak up because I wasn't a trade unionist. 
THEN THEY CAME for the Catholics, 
and I didn't speak up because I was a Protestant. 
THEN THEY CAME for me, 
and by that time no one was left to speak up. 

以下是众多法文版中间的一个: 

Un petit poème écrit par Martin Niemöller. Arrêté en 1937 et envoyé au camp de concentration de Sachsenhausen, il fut ensuite transféré en 1941 au camp de concentration de Dachau. Libéré du camp par la chute du régime nazi, en 1945. 

« Quand ils sont venus chercher les communistes, je n'ai pas protesté parce que je ne suis pas communiste. 
Quand ils sont venus chercher les Juifs, je n'ai pas protesté parce que je ne suis pas Juif. 
Quand ils sont venus chercher les syndicalistes, je n'ai pas protesté parce que je ne suis pas syndicaliste. 
Quand ils sont venus chercher les catholiques, je n'ai pas protesté parce que je ne suis pas catholique. 
Et lorsqu'ils sont venus me chercher, il n'y avait plus personne pour protester. » 

据专家说,很难找到真正的原版,或许正式的原版都不存在,以下是可能的一个德文版: 

« Als die Nazis die Kommunisten holten, 
habe ich geschwiegen; 
ich war ja kein Kommunist. 
Als sie die Sozialdemokraten einsperrten, 
habe ich geschwiegen; 
ich war ja kein Sozialdemokrat. 
Als sie die Gewerkschafter holten, 
habe ich nicht protestiert; 
ich war ja kein Gewerkschafter. 
Als sie die Juden holten, 
habe ich nicht protestiert; 
ich war ja kein Jude. 
Als sie mich holten, 
gab es keinen mehr, der protestierte. »

星期二, 二月 24, 2009

Motto of Marie Curie

In life, nothing is to be feared. Everyghing is to be understaood.
                                                                                    -- Marie Curie