纪1 庆祝中国人民政治协商会议第一届全体会议 14.00元 |
星期二, 九月 15, 2009
纪念邮票盖销票价格表-2009年
星期五, 九月 11, 2009
让表格中的单元格换行
让表格中的单元格换行
\newcommand{\tabincell}[2]{\begin{tabular}{@{}#1@{}}#2\end{tabular}}
%然后使用&\tabincell{c}{}&就可以在表格中自动换行
%比如这么用
\begin{tabular}{|c|c|}
\hline
1 & the first line \\
\hline
2 & \tabincell{c}{haha\\ heihei\\zeze} \\
\hline
\end{tabular}
Latex 经验
[经典书籍]
经典的参考书lshort和中文的latex_manual。别的书不推荐,并不等于别的书不好,侧重点不同。
另外常备数学符号手册,有时候需要查询。
bbs.ctex.org,好地方,论坛的气氛超好。
[系统及组合工具]
miktex+winedt是极好的组合,latex编译和dvi、pdf显示等各种操作点击一下即可,完全配置好了,而且对于参考文献的编辑书写很方便,特殊符号也如此。
实际操作当中,对于需要跟老板反复讨论修改的文章,可以使用word写正文的doc文件,只需告诉老板忽略带\的代码以及图片、表格、公式等段落的语法代码。这样,不但可以利用word的语法检查,更可以做到修改的功能,与普通word操作无二。文本内容差不多之后,将doc另存为tex纯文本,编译生成pdf即可。
通常含有交叉引用或者公式等编号的TEX文件,需要反复编译4遍左右,才能达到最终效果,反正winedt中也就是多点几下按钮,倒是省事。
对于表格,使用latable,支持列复制粘贴,很方便数据输入,最后拷贝出Tex代码即可。
对于公式,使用Texaide4(或Mathtype),此软件是把mathtype的内核整了出来的,所以输入公式是直接可视化,最后拷出tex代码即可。有人用SWP来方便修改文章里的公式,也可行。
对于作图:函数公式图、三维图用gnuplot;二维数据图、非线性拟合用origin,导出eps文件;位图用gimp或photoshop;矢量图用其他工具,如dia, smartdraw,制作后直接导出或先打印成pdf然后用adobe另存为eps文件。
[入手须知]
latex用命令行肯定是不爽,所以一定要用winedt。
yap的逆向返回,在yap里设置一下即可。
再次强调,下载一个好的模板做准备,论文或者文章或者实验报告。
[书写经验]
常用的符号输入,埃 (\AA)、百分号 (\%)、~ ($\sim$)
温度符号或者直体希腊字母,可以先定义一些宏,角度 \def\degree{$^{\circ}$} 和摄氏度符号\def\centigrade{$^{\circ}\mathrm{C}$},或者引用现成的符号包。
双倍行距 \renewcommand{\baselinestretch}{1.6} 或者\linespread{1.6}
~?小间距,多用于两个连着的标点之间或者单位之前
“ ”?引号的正确输入
$?数学模式。若需输入希腊字母,也需进此模式
\[ \]?文中公式
若嫌论文每次生成pdf很慢,可采用draft模式,则插图处以黑框显示,最后定稿时再以final模式编译。
编译出错的时候,从最初给出的错误信息看起,后面的可能没用。
简单的子图,可以不用其他包,直接多写几个\includegraphics;需要上下排的时候,\\换行即可。
[图像制作]
eps图像?万能但是愚蠢的办法,是虚拟彩色打印机,分辨率确实高,但是虚拟打印重新得到的eps图像文件的分辨率与打印机设置有关,因为生成的文件有可能比原始文件大很多很多,完全没有必要。因此强烈推荐jpeg2ps这个小软件,命令行转化一下即可。数据作图只需用origin导出即可;若用gnuplot,也很方便。具体建议:如果所写论文里面几乎不含实验数据、矢量形状图,则建议统一使用jpg图像,同时用pdflatex直接生成pdf。
位图制作,使用gimp或ps都可以,gimp可以直接导出eps文件,ps可以采取生成jpg文件然后转化或者生成pdf再用acrobat另存。
矢量作图,使用dia或Inkscape,或者powerpoint!这里提到的几个软件在win32下都有直接的安装文件,然后打印成pdf再另存。
如果所写论文里面含有大量数据图,以及少量AFM等位图,为了保证准确性,建议统一采用eps图像,经latex-dvi-pdf制作。因为origin支持此项输出;对于位图,采用jpeg2ps转化成ps图像,不必剪裁,直接可以作为eps图像文件引用。然后用latex->dvi->pdf来生成最终成品pdf。更可喜的是,这两种方式所生成的ps图像文件,在yap的dvi浏览器里,就完全支持,浏览起来非常方便。除了通过jpg格式转化为eps文件;更通行的办法是打印为pdf文件,然后用acrobat裁剪并另存为eps文件。但是,并不建议采用虚拟ps打印机打印的方式,因为,一,打印的ps图像,可能需要重新用gsview进行剪裁,再进一步生成eps文件;二,打印的ps图像文件与所用的虚拟ps打印机分辨率设置有关,相当于重新采样制作,完全没有必要,反倒有可能图像文件很大。
BTW:据说photoshop制作的ps文件,如果设置的boundbox的话,也是可以被引用的。本人相信这是对的,但是没有深入研究。
[编译生成]
pdflatex->pdf?可直接一步生成pdf,支持jpg文件,方便,但是不支持eps,因此origin的作图成了问题。但是pdflatex竟然支持pdf的图,而任何文档转成pdf格式,都是很方便的,所以这种方法现在也非常可行。
latex->dvi->pdf?先生成dvi,再生成pdf,不支持jpg的图,通常用图都是eps,需要虚拟打印或者转换,缺点是修改eps图片不方便。一般说来,没必要经过ps中转,dvi作中间调整观察,pdf直接看到最终效果即可。
?需要指出的是,dvi预览的时候,暂时不支持的伪eps图会留出空档。
?另外,有交叉引用的时候,可能要多编译几次,这是正常现象。
[常见问题]
有些输入必须在数学环境下,比如最常用的希腊字母的书写方式。
参考文献的引用是用\cite,而表格、图像用的是\ref。用错了的话,那个问号可是一直会在哦。
bibtex的style一般用unsrt,即按照文中出现的次序逐个显示。revtex的模板库默认已经是这个了。
bibtex里的作者项,每个作者用and连接,不要用显示结果的逗号或者分号,因为最终显示的处理效果会有你设定的样式自动决定。
bibtex里的单项最好用{ },而不要用” “,因为用大括号的话,里面可以书写一些德文的怪点点。
每章单独的参考文献,可以用库\usepackage{chapterbib}来实现。
需要[1-4]这样的参考文献引用风格,在使用了bibtex之后,加上\usepackage[sort&compress,sectionbib]{natbib}可以实现。
星期四, 九月 10, 2009
更多Latex的功能
1,
\hspace{xx} 产生xx长的水平空格
\vspace{xx} 产生xx长的垂直空格。
Latex里面的长度单位有:
当换行时,\hspace{xx}产生的空格会被取消,如果要强制指定产生水平空格,用\hspace*;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)
同理,当换页时,\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表明子项的内容。
下面是一个比较复杂的例子:
\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个pt12pt:字体大小为12个pttwocolumn:输出分为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
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 typeto obtain the above formula.\[ \inftyint f(x)\,dx.\]
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 obtainWhat 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七,定理环境
这多用于数学推导,证明等的文章中。
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:
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
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:
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 Family | Code | Command |
| Roman (serif, with tails on the uprights) as the default | rm | \textrm{text} |
| Sans-serif, with no tails on the uprights | sf | \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 Style | Command | Example |
|---|---|---|
| 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.
Command Nominal Point Size Exact Point Size \tiny 5 5 \scriptsize 7 7 \footnotesize 8 8 \small 9 9 \normalsize 10 10 \large 12 12 \Large 14 14.40 \LARGE 18 17.28 \huge 20 20.74 \Huge 24 24.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.
Command Changes the defaults to times Times, Helvetica, Courier pslatex same as Times, but uses a specially narrowed Courier. This is preferred over Times because of the way it handles Courier. newcent New Century Schoolbook, Avant Garde, Courier palatino Palatino, Helevetica, Courier palatcm changes 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}