Showing posts with label latex. Show all posts
Showing posts with label latex. Show all posts

Thursday, March 6, 2008

用Listings高亮代码

http://en.wikibooks.org/wiki/LaTeX/Packages/Listings
pdf

例子

\documentclass{article}
\usepackage{listings}

\begin{document}

\begin{lstlisting}[language=C]
int main(int argc, char ** argv)
{
/* print a string "Hello world!"
printf("Hello world!\n");

return 0;
}
\end{lstlisting}

\end{document}

效果:

Sunday, January 27, 2008

用Minipage并排图形和表格

\begin{minipage}[htb]{.45\textwidth}
\begin{minipage}{.4\textwidth}
\centering
\includegraphics[width=100pt, bb=0 0 94.19mm 94.19mm]{fig.eps}
\makeatletter\def\@captype{figure}\makeatother\caption{\scriptsize An infobox of the Wikipedia page.}
\label{fig:myfig}
\end{minipage}
\quad
\begin{minipage}{.45\textwidth}
\centering
\tiny
\begin{tabular}{|cc|}
\hline
\multicolumn{2}{|c|}{Classes from Wikipedia structure}\\
\hline
% & Feature & Example \\
genre 70 & members 57\\
origin 48 &member role 48 \\
years active 44 & a music group 39\\
member occupations 26& album Name 18 \\
lyrics 13 &album no. 10 \\
single 10 & born in 8\\
\hline
\multicolumn{2}{|c|}{extra classes from corpus}\\
\hline
die in 7 & former Members 4 \\
alias 3 &instruments 3\\
awards 3 & label 2 \\
associate act 1 & birth name 1 \\
\hline
\end{tabular}
\makeatletter\def\@captype{table}\makeatother\caption{Relation classes.}
\label{tbl:mytbl}
\end{minipage}
\end{minipage}

Wednesday, January 16, 2008

one figure over two columns &&figure array

\begin{figure*}[tb]实现跨行
用subfigure排列子图。需要引用subfigure的包:
\usepackage{graphicx}

---------------------------------------------------------------
\begin{figure*}[tb]
\centering
\subfigure[1]{\includegraphics[width=400pt]{D:/0work/res/pic/1.eps}}
%\mbox{\hspace{0.5cm}}
\\
\subfigure[2]{\includegraphics[width=140pt]{D:/0work/res/pic/2.eps}}
\subfigure[3]{\includegraphics[width=140pt]{D:/0work/res/pic/3.eps}}
%\mbox{\hspace{0.5cm}}
\subfigure[4]{\includegraphics[width=140pt]{D:/0work/res/pic/4.eps}}
\renewcommand{\figurename}{figure}
\caption{hello} \label{hello}
\end{figure*}

Monday, January 14, 2008

latex 单行或多行公式的排版

from : http://www.boyeut.com/2007/05/equation.html

1.自动编号的单行公式环境是
\begin{equation}

\end{equation}

不参与自动编号的单行公式环境:
\[

\]

人工编号的单行公式可以使用Tex原有的行间公式标记
$$公式 \eqno 编号 $$ 将编号放在右边
$$公式 \leqno 编号 $$ 将编号放在左边

引用时候可以直接用$编号$即可。

例如,$$a^2+b^2=c^2 \eqno (**)$$
由公式($**$)即可得到结论。

一般情况下,行间公式 $$…$$也可以用\[…\]表示
但对于这种人工编号的公式,不能用\[..\]代替$$…$$.

2.单个公式很长,需要换行,但仅允许生成一个编号时,可以用split命令

\begin{equation}
\begin{split}
a &= b \\
c &= d
\end{split}
\end{equation}

注意:每行只允许出现一个“&”,使用split命令后,编号上下居中显示。

3.多行公式:

\begin{eqnarray}
左 & 中 & 右\\
左 & 中 & 右\\

\end{eqnarray}
该环境对多行公式每行都加自动编号,如果相对某行不加编号,可在换行之前添加命令\nonumber

如果要改变公式的自动编号,可以重设计数器初始值:
\setcounter{equation}{数}
下一个编号自动加1。

4.方程组的排版:
多个公式,每个公式自动编号。

1) gather环境
是下面align环境的一种特殊情形。
\begin{gather}
a &= b \\
c &= d \\

\end{gather}
>>1.如果其中某几行使用同一个编号,则需要内嵌一个split环境。
>>2.命令\notag可使当前行不编号。
2) align环境
可使几组公式并排在一起,即在同一行显示多个公式,方法是跟以前一样,使用”&”对齐。
可替代gather环境。
3) 以上几种方程组环境,无论每个公式多小,都会占满一行。使用相应的\gathered,\aligned环境,则只占据公式的实际宽度,整体作为一个特大的符号与其他符号一同处理。
这个结构还可以添加位置参数,以决定与其他符号的竖直对齐方式(b,t)。而且这种环境不再具有自动编号功能。

例如:
\begin{equation}
\left.
\begin{aligned}[b]
a &= b+c \\
d &= b+c
\end{aligned}
\right\}
\Longrightarrow
\qquad a=d
\end{equation}

这里更正参考文献中P149页的一个小错误。就是\right}应该改为\right\}.

【参考文献】
1.陈志杰等,LATEX入门与提高(第二版),高等教育出版社,2006.5



此外还有:
Latex-定理编号的引用

Latex-case环境

Latex-小细节

Latex-定理定义的排版

Wednesday, October 24, 2007

Latex 公式

from http://blog.sina.com.cn/s/blog_53be544e010003hn.html
首先你要先使用宏包 ntheorem

\usepackage[amsmath,thmmarks]{ntheorem}
% 定理类环境宏包,其中 amsmath 选项
% 用来兼容 AMS LaTeX 的宏包

%=== 配合上面的ntheorem宏包产生各种定理结构,重定义一些
%正文相关标题 ===
\theoremstyle{plain}
\theoremheaderfont{\normalfont\rmfamily\CJKfamily{hei}}
\theorembodyfont{\normalfont\rm\CJKfamily{kai}} \theoremindent0em
\theoremseparator{\hspace{1em}} \theoremnumbering{arabic}
%\theoremsymbol{} %定理结束时自动添加的标志
\newtheorem{definition}{\hspace{2em}定义}[section]
%\newtheorem{definition}{\hei 定义}[section]
%!!!注意当section为中国数字时,[section]不可用!
\newtheorem{proposition}{\hspace{2em}命题}[section]
\newtheorem{property}{\hspace{2em}性质}[section]
\newtheorem{lemma}{\hspace{2em}引理}[section]
%\newtheorem{lemma}[definition]{引理}
\newtheorem{theorem}{\hspace{2em}定理}[section]
\newtheorem{axiom}{\hspace{2em}公理}[section]
\newtheorem{corollary}{\hspace{2em}推论}[section]
\newtheorem{exercise}{\hspace{2em}习题}[section]
\theoremsymbol{$\blacksquare$}
\newtheorem{example}{\hspace{2em}例}[section]
\theoremstyle{nonumberplain}
\theoremheaderfont{\CJKfamily{hei}\rmfamily}
\theorembodyfont{\normalfont \rm \CJKfamily{song}} \theoremindent0em
\theoremseparator{\hspace{1em}} \theoremsymbol{$\blacksquare$}
\newtheorem{proof}{\hspace{2em}证明}


注意:如果你使用的book,而不是article,那么你要把所有的section改为chapter.

Friday, August 17, 2007

Latex中纵向排列两个子图

引入包subfigure.
\usepackage{subfigure}

使用的时候:
\begin{figure}[tb]
\centering \subfigure[subCaption_1 ]{\includegraphics[width=200pt]{1.eps}}
\label{fig:selFilter} \subfigure[subCaption_2]{\includegraphics[width=200pt]{2.eps}}
\label{fig:tripleQuery}
\caption{Query} \label{Fig:CellDropRates}
\end{figure}

Sunday, May 6, 2007

latex公式

http://en.wikipedia.org/wiki/Help:Formula

更改latex 中item的样子

\renewcommand{\labelitemi}{$\star$}

e.g.change the "dot" to "-"

\renewcommand{\labelitemi}{-}
\begin{itemize}
\item aaaaaa
\item bbbbbbb
\end{itemize}
\end{definition}

Thursday, May 3, 2007

Latex并列子图中使用minipage

\begin{figure}[htb]
\centering \mbox{
\subfigure[title for sub figure 1]{
\begin{minipage}[c]{3.7cm}
\small
a sentence\\
a sentence\\
a sentence\\
a sentence\\
\end{minipage}
\label{fig:labelOfSubFigureA}
}\quad


\subfigure[title for sub figure b]{
\begin{minipage}[c]{3.7cm}
\small
a sentence\\
a sentence\\
a sentence\\
a sentence\\
a sentence\\
\end{minipage}
\label{fig:tripleTagsB} }
} \caption{Triple tags}
\label{fig:label for sub figure B}
\end{figure}

--------------------------------------
e.g.

Wednesday, May 2, 2007

latex中输入定义

\documentclass[times, 10pt,twocolumn]{article}
....
\usepackage{amsmath,amsthm,amssymb} % 引入 AMS 數學環境g
....
\newtheorem{definition}{Definition}
\newtheorem{theorem}{Theorem}(for 公理)

\begin{document}
...
(如果只是definition,之用引入amssymb包)
\begin{definition}[Name of the Definition]
content of the definition
\end{definition}

....

Friday, February 16, 2007

latex中插入并列子图

使用graphicx宏包和subfigure宏包。下面是一个例子。


\begin{figure}[htb]
\centering
\mbox{
\subfigure[信元丢失率与加速因子之间的关系]{\includegraphics[scale=1.0]{temp1.e
ps}}\quad
\subfigure[信元丢失率与缓冲大小之间的关系]{\includegraphics[scale=1.0]{temp2.e
ps}}
}
\caption{影响信元丢失率的因素}
\label{Fig:CellDropRates}
\end{figure}