您的位置:首页 > 其它

LaTeX零基础入门

2016-03-11 11:40 274 查看
一、关于LaTeX

LaTeX是一种基于ΤΕΧ的排版系统,在我刚开始接触LaTeX时,我不是很懂tex,latex,和winedt的区别。后来百度了一下,区别如下:

1. TeX:一种宏语言

2. LaTeX: 一种基于ΤΕΧ的排版系统

3. winedt: 一种编辑器只能编辑文本,最后的程序编译还是需要调用 LaTeX 软件

二、使用winedt

一般我们用latex主要用来论文排版,所以在windet编译器中,只需打开一个.tex文件,编译成pdf格式的文件即可。编译的方式主要是:1.点击按钮

或2.点击Accessories–>PDF–>PDFLaTeX。

1.关于.tex模版。
一般你投什么期刊和会议,在其官网上都能找到相应的模版,把模版下载下来,直接在模版上修改即可。
2.关于公式
基本上每个部分的排版方式模版中都会给出实例,但还是会有几个难点。
公式需要用到mathtype,用mathtype打开你需要编辑的公式,设置mathtype的复制剪切格式:预置--->剪切和复制预置--->MathML
或Tex--->LaTex 2.09 and later。
设置后只需复制mathtype中的公式粘贴到tex编辑页面即可。
一般mathtype复制过来的公式都是直接可锲入到文字中的,若要公式显示到一行中,只需将$..$换成\[..\].
以下是我用的模版中给出的几个实例,大家参考一下:


%%% 1-line-equation-without-count-number. 不编号单行公式
\begin{equation}
\nonumber
A(d,f)=d^{l}a^{d}(f),
\end{equation}


%%% equation-array. 公式组
\begin{eqnarray}
\nonumber
&X=[x_{11},x_{12},\ldots,x_{ij},\ldots ,x_{n-1,n}]^{\rm T},\\
\nonumber
&\varepsilon=[e_{11},e_{12},\ldots ,e_{ij},\ldots ,e_{n-1,n}],\\
\nonumber
&T=[t_{11},t_{12},\ldots ,t_{ij},\ldots ,t_{n-1,n}].
\end{eqnarray}


3.关于图片
每个编译器或模版所能识别的图片类型不一样,所以都可以试一下。eps,jpg,png哪个有用,用哪个。
接着就是图片排版的问题,如下是模版中给出的例子。


%%% 1-figure. 单图
%%% Please use Figure~\ref{fig1} in the text (``~'' is not omitted)
%%% 请在文中使用Figure~\ref{fig1}, 不要省略``~'', 它能够使Figure和图号不断行
\begin{figure}[!t]
\centering
\includegraphics{fig1.eps}
\caption{Caption 1.}
\label{fig1}
\end{figure}


%%% 2-figures-in-1-row. 并排图
%%% Please use Figure~\ref{fig1} in the text (``~'' is not omitted)
%%% 请在文中使用Figure~\ref{fig1}, 不要省略``~'', 它能够使Figure和图号不断行
\begin{figure}[!t]
\centering
\begin{minipage}[c]{0.48\textwidth}
\centering
\includegraphics{fig1.eps}
\end{minipage}
\hspace{0.02\textwidth}
\begin{minipage}[c]{0.48\textwidth}
\centering
\includegraphics{fig2.eps}
\end{minipage}\\[3mm]
\begin{minipage}[t]{0.48\textwidth}
\centering
\caption{Caption 1.}
\label{fig1}
\end{minipage}
\hspace{0.02\textwidth}
\begin{minipage}[t]{0.48\textwidth}
\centering
\caption{Caption 2.}
\label{fig2}
\end{minipage}
\end{figure}


%%% 2-subfigures-in-1-row. 并排子图
%%% Please use Figure~\ref{fig1} in the text (``~'' is not omitted)
%%% 请在文中使用Figure~\ref{fig1}, 不要省略``~'', 它能够使Figure和图号不断行
\begin{figure}[!t]
\centering
\begin{minipage}[c]{0.48\textwidth}
\centering
\includegraphics{subfig1.eps}
\end{minipage}
\hspace{0.02\textwidth}
\begin{minipage}[c]{0.48\textwidth}
\centering
\includegraphics{subfig2.eps}
\end{minipage}
\caption{Caption 1. (a) Subfig1 caption; (b) subfig2 caption.}
\label{fig1}
\end{figure}


在我使用的过程中,还发现了以上模版的并排子图,子图无法编号的问题。
后来百度了很多方法,发现有两种方式:1.{minipage},2.{subfigure}。具体用法大家自行百度。
使用{subfigure}对子图编号更方便快捷,可在使用过程中,需要使用宏包\usepackage{graphicx}和\usepackage{subfigure}。
代码块中使用的\subfigure[]{...}语句又报错说没有定义。
最后百度发现subfigure宏包和figure宏包冲突了。解决方法有两个:
1.将\usepackage{subfigure}换成\usepackage{subfloat}.
2.将代码块中的\subfigure[]{...}换成\subfloat[]{...}。
以下是并列图并带有子图标号的代码实例(我采用的是第二种解决方式)。


\begin{figure}[!t]
\centering
\subfloat[] {\includegraphics[height=4cm,width=5cm,angle=0,scale=1]{pushvalue1.jpg}}
\subfloat[] {\includegraphics[height=4cm,width=5cm,angle=0,scale=1]{pushvalue2.jpg}}
\subfloat[] {\includegraphics[height=4cm,width=5cm,angle=0,scale=1]{pushvalue3.jpg}}\\
\subfloat[] {\includegraphics[height=4cm,width=5cm,angle=0,scale=1]{pushvalue1.jpg}}
\subfloat[] {\includegraphics[height=4cm,width=5cm,angle=0,scale=1]{pushvalue2.jpg}}
\subfloat[] {\includegraphics[height=4cm,width=5cm,angle=0,scale=1]{pushvalue3.jpg}}
\caption{The average force of topic driving statistic value about three topic. (a) Topic A’s the average force of topic driving statistic value; (b) Topic B’s the average force of topic driving statistic value; (c) Topic C’s the average force of topic driving statistic value.}
%\label{fig}
\end{figure}


4.关于表格,表格很简单,以下是实例


\begin{table}[!t]
\footnotesize
\caption{Tabel caption}
\label{tab1}
\tabcolsep 49pt %space between two columns. 用于调整列间距
\begin{tabular*}{\textwidth}{cccc}
\toprule
Title a & Title b & Title c & Title d \\\hline
Aaa & Bbb & Ccc & Ddd\\
Aaa & Bbb & Ccc & Ddd\\
Aaa & Bbb & Ccc & Ddd\\
\bottomrule
\end{tabular*}
\end{table}


5.关于算法流程
算法流程也很简单,以下是实例代码以及效果图。
在此基础上修改就可以了。


\begin{algorithm}
%\floatname{algorithm}{Algorithm}%更改算法前缀名称
%\renewcommand{\algorithmicrequire}{\textbf{Input:}}%更改输入名称
%\renewcommand{\algorithmicensure}{\textbf{Output:}}%更改输出名称
\footnotesize
\caption{Algorithm caption}
\label{alg1}
\begin{algorithmic}[1]
\REQUIRE $n \geq 0 \vee x \neq 0$;
\ENSURE $y = x^n$;
\STATE $y \Leftarrow 1$;
\IF{$n < 0$}
\STATE $X \Leftarrow 1 / x$;
\STATE $N \Leftarrow -n$;
\ELSE
\STATE $X \Leftarrow x$;
\STATE $N \Leftarrow n$;
\ENDIF
\WHILE{$N \neq 0$}
\IF{$N$ is even}
\STATE $X \Leftarrow X \times X$;
\STATE $N \Leftarrow N / 2$;
\ELSE[$N$ is odd]
\STATE $y \Leftarrow y \times X$;
\STATE $N \Leftarrow N - 1$;
\ENDIF
\ENDWHILE
\end{algorithmic}
\end{algorithm}




以上就是我这段时间学习latex的总结和体会了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: