文档库 最新最全的文档下载
当前位置:文档库 › Latex常用技巧20131010

Latex常用技巧20131010

Latex常用技巧20131010
Latex常用技巧20131010

软件准备:

1、CTex 套装

2、office (建议2010版或以上,同时安装画图Visio )

3、Adobe Acrobat (用来编辑PDF,同时安装Adobe Reader)

4、MathType 公式编辑器

其中软件2-4需要注册,以上软件找不到的可以到我这里拷

3、4安装好后会在Word里面增加如上图两个栏目

Word里面图片的处理

a如果是Visio画的,使用Visio另存为PDF

b其他矢量图,新建Word,图片复制进去,ACROBAT选项另存为PDF

c非矢量图,直接存为jpg或者同b

图片处理原则矢量图不能转换为非矢量图,不能降低分辨率

学习中遇到问题善于利用搜索,一般问题基本上都有比较好的解决方案,至少也能提供一些思路另外就是多尝试,不要怕麻烦

Latex现在还不能很好的处理同时插入PDF图和EPS图片,只能在同一篇文章中出现一种格式的图片。因此有两种办法。

1)将eps的图片转化为PDF图片。

单个文件转化: convert file.eps file.pdf

多文件批量转化:find . -name "*.eps" -exec epstopdf {} \;

然后LatexPDF编译。

2) 将pdf文件转化为EPS文件。

convert file.pdf file.eps

用Latex直接编译。

我还是比较倾向于第二种方面,一是因为自己写文章大部分图片是eps格式的,少量是PDF格式的,再者eps的图片似乎更美关一下。

XeLaTeX编译支持的更多一点,如对bmp的支持,有问题的时候可以尝试下这种编译

图片问题导致文字偏黑 PDF图片有Acrobat按照PDF/A标准另存为即可

eps图片转换格式,然后PS to EPS

常见错误:(减少错误:仔细对照原文,生成PDF后检查下是否与代码预期一致)

1、空格:标点前面不空,后面空格。经常出现标点与下一句间忘记空格,特殊字符与下一个

单词间忘记空格。标点出现在行首的问题一般也是标点前多了空格造成的。

代码里面多个空格当作一个,段前、公式代码中的空格无效,但注意{ A space},

这种A前面的空格有效,不应该出现。

2、引号:双引号`` ”,单引号` ’(注意前、后引号的代码是不一样的)

3、特殊字符:如&,代码 \& ,还不行就$\&$。其他如法语字母上标、波兰字母等注意。

4、分隔符 ' ’ (注意和求导符号的区别)

5、中英文标点:一般情况JCIS论文不出现中文字符。非特殊处理,中文字符在生成PDF

时不显示,也不报错,所以代码要看仔细。如果代码里面空了PDF里面没有,可

能是中文的空格。中文字符占位比英文大一点,也可以在代码中全文搜索、替换。

6、缺少标点:单位地址中有使用分行的没有逗号间隔,取消换行记得加逗号。作者间缺少逗

号(最后一个作者名后面不加标点)

7、求和符号上下标:独立一行的公式放上下\sum\limits,正文中公式放右边\sum\nolimits Gsview注册码:用了很久的Latex,每次都在用Gsview看ps文件时,都会弹出注册的对话

框,分享下注册码:32411-26380,18963-21159,16417-30959,55555-24868

使用eps图片也可以用PDFTeXify编译导言区加\usepackage{epstopdf}

将求和符号的下标分行 \atop \scriptstyle

公式等特殊环境中的空格(公式等环境空格无效)

\; \, ~

或者使用\hspace{10mm} %水平方向空10mm(垂直方向空\vspace{0.5cm})

①\textcircled{\scriptsize 1}

\hyphenation{hy-phen-a-tion} 指定一个单词可以从-处断开。

法语字母的上标

{\'E}ric Marchand éric Marchand 区别于数学模式重音符号\acute{a}

\usepackage{url} \url{http: }

画横线,空行间距

\vspace{0.5cm}%\\

\hrule

{\bf Algorithm 1}. PSO algorithm

\hrule

控制enumerate中标签缩进

\begin{enumerate}[a)] \setlength{\itemindent}{0.01em}

\item aaa

\end{enumerate}

也可用\leftskip0.15in ,二者稍有不同

List 环境间距

List 环境 ( 包括enumerate,list,itemize) 三种,其实是占空间大户,每次看着都觉得别扭,行距太大。为了解决这个问题,有个很简单的方法,那就是在导言区加上这句(禁止加在导言区):

/setlist[enumerate]{itemsep=0pt, parsep=0pt} % 或者其他两个list环境

这样就可以改变enumerate的默认行间距设置,如果不想改变全局的设置,也可以把这两个设置放在每次使用 List环境时,(禁止加在导言区,一般只用在要调整的地方,一般情况下不改变默认的间距,为调整排版美观或缩减页数,可以稍微调整一点)

\begin{itemize}

\setlength{\itemsep}{1pt} %一般只调整此间距

\setlength{\parskip}{0pt}

\setlength{\parsep}{0pt}

\item A.blahblah

\item B Blahblah

\end{itemize}

这样每次只改变当前的 List 环境,还有一个小 Tips 在 Texmaker 中 ctrl + shift + I 可以快速创建 \item

正文加框

\begin{minipage}[h]{0.5\textwidth}

\fbox{ \parbox{\textwidth}{

Add $a$ squared and $b$ squared to get $c$ squared. Or, using a more

mathematical approach : $$c^2=a^2+b^2$$or you can type less

with:$$a+b=c$$} }

\end{minipage}

并列的子图形详细参考https://www.wendangku.net/doc/8716253020.html,/documents/latex/graphics/node111.html

在某些情况下,有时会希望将并列的图形组成一组,而其中的每一幅图都保持其独立性。 paisubfigure 宏包

的 \subfigure 命令将这一组做为一幅图形,其中的每一幅图做为子图形。

例如:

\begin{figure}

\centering

\subfigure[Small Box with a Long Caption]{

\label{fig:subfig:a} %% label for first subfigure

\includegraphics[width=1.0in]{graphic.eps}}

\hspace{1in}

\subfigure[Big Box]{

\label{fig:subfig:b} %% label for second subfigure

\includegraphics[width=1.5in]{graphic.eps}}

\caption{Two Subfigures}

\label{fig:subfig} %% label for entire figure

\end{figure}

生成图 27.9。这里使用 LATEX 的引用命令 \ref{fig:subfig:a} 会得到 27.9(a), \ref{fig:subfig:b} 得

到 27.9(b), \ref{fig:subfig} 得到 27.9。

多个figure并列代码,区别于一个figure里面含两个图(并列子图)

\begin{figure}[htbp]

\centering

\begin{minipage}{0.45\linewidth}

\centering

\includegraphics*[width=2.8in]{image01.eps}

\caption{Schematic diagram of experimental system}\label{fig:1}

\end{minipage} \;\; %在此处加 \;\, 空格使两幅图不会靠的太近

\begin{minipage}{0.45\linewidth}

\centering

\includegraphics[width=2.8in, height=2.10in, keepaspectratio=false]{image02}

\caption{Practical E-nose system}\label{fig:2}

\end{minipage}

\end{figure}

标题对齐

生成图27.5和27.6,我们可以看到这里两幅图形的标题并不对齐。而若只使用小页的[b]选项,会使得标题的最后一行对齐,并不能解决问题。

一种解决办法是在小页环境中把图形和标题分开放到两行中:第一行放置图形,第二行放置标题。例如:

\begin{figure} \centering \begin{minipage}[b]{.33\textwidth} \centering

\includegraphics[width=2cm]{graphic.eps} \end{minipage}% \begin{minipage}[b]{.33\textwidth} \centering \includegraphics[width=2cm,angle=-30]{graphic.eps} \end{minipage}\\[-10pt]

\begin{minipage}[t]{.33\textwidth} \caption{Box with a Long Caption} \end{minipage}%

\begin{minipage}[t]{.33\textwidth} \caption{Rotated Box} \end{minipage}% \end{figure}

生成的图 27.7 和 27.8 中,图形的基线和标题的第一行分别对齐。

在这个例子中,需要注意:

?在最后一幅图后面用\\来断行,\\的参数项[-10pt]使得图形与标题之间的距离比当前行距减少10pt。这样做是让图形和标题更接近些,用户也可自己选用合适的值。

?包含图形的小页使用[b]选项,使得它们的参考点为其最后一行的基线。

?包含标题小页使用[t]选项,使得它们的参考点为其第一行的基线。

?任何一个\label 命令都必须和它相应的\caption 命令在同一个小页中。

学术论文普遍使用三线表。参考https://www.wendangku.net/doc/8716253020.html,/blog-260588-257763.html

三线表的特点主要是:整个表格通常只有三条横线,首尾两条横线较粗,中间一条较细,一般不使用竖线。LaTeX 处理三线表相当简单方便。用到的宏包主要是 booktabs ,即:在导言区加入:\usepackage{booktabs}。下面是普通三线表的代码和效果:

\begin{table}[htbp]

\caption{\label{tab:test}示例表格}

\begin{tabular}{lcl}

\toprule

。。 & 。。 & 。。 \\

\midrule

。。 & 。。 & 。。 \\

。。 & 。。 & 。。 \\

。。 & 。。 & 。。 \\

\bottomrule

\end{tabular}

\end{table}

效果图:

关于表格合并单元格

\begin{table}[ht] \centering \caption{Cate。。。} \label{tab:result1}

\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|}

\hline

\multirow{2}{*}{Group} & \multirow{2}{*}{Category} &

\multicolumn{3}{c|}{Positive} &

\multicolumn{3}{c|}{Neutral} &

\multicolumn{3}{c|}{Negative} & \multirow{2}{*}{Accuracy} \\

\cline{3-11}

& & P & R & $F_1$ & P & R & $F_1$ & P & R & $F_1$ & \\

\hline

1 & Auto & 0.27 & 0.19 & 0.2

2 & 0.37 & 0.71 & 0.48 & 0.6

3 & 0.38 & 0.47 & 0.45 \\

\hline

2 & Auto & 0.16 & 0.09 & 0.12 & 0.35 & 0.71 & 0.47 & 0.62 & 0.38 & 0.47 & 0.4

3 \\

\hline

1 & Digi & 0.49 & 0.45 & 0.47 & 0.13 & 0.07 & 0.09 & 0.57 & 0.67 & 0.61 & 0.51 \\

\hline

2 & Digi & 0.51 & 0.42 & 0.46 & 0.1

3 & 0.07 & 0.09 & 0.56 & 0.69 & 0.62 & 0.51 \\

\hline

\end{tabular}

\end{table}

如何设定列宽并居中

\begin{table}[h]

\centering \small

\begin{tabular}{c c c c c c } % c表示居中,l 表示左对齐,c与c之间 | 表示显示竖线,在此处设定列宽后,表格内容居中要在每个单元格内容前后加 \hfil

\hlinewd{1.5pt}

\multicolumn{1}{p{2.5cm}}{\centpcol Nice} & \multicolumn{1}{p{1.7cm}}{\centpcol

a} & \multicolumn{1}{p{1.7cm}}{\centpcol b} & \multicolumn{1}{p{1.7cm}}{\centpcol c}

& \multicolumn{1}{p{1.7cm}}{\centpcol d} & \multicolumn{1}{p{1.7cm}}{\centpcol e}\\

\hlinewd{1.0pt}

A1& -1.60& -4.07& -5.58& -6.48& -7.30\\

A2& -1.40& -4.00& -5.50& -6.32& -7.13\\

A3& -1.35& -3.90& -5.40& -6.20& -7.00\\

\hlinewd{1.5pt}

\end{tabular}

\end{table}

单独控制每个单元格内容的位置

\begin{tabular}{|c|p{8cm}|}

\hline

a & \hfil 居中测试 \hfil \\

\hline

b & 居左测试 \\

\hline

c & {\hfill 居右测试} \\

\hline

\end{tabular}

表格中一个格子多行/usepackage{makecell}

-----------------------------------------------------------------------------------------------------------------------------------

调整表格列高、行高及大小。可以使用(尽量不更改这些默认的设置):

\begin{table} \renewcommand{\arraystretch}{1.5} //调整行高到1.5倍

\begin{table} \addtolength{\tabcolsep}{-2pt} //减少列宽-2pt

Latex设置表格字体大小(可以很好的控制页面布局,防止右边超出页面)

\begin{table}[h] \small%此处写字体大小控制命令

\begin{tabular} \end{tabular} \end{table}

Latex 设置字体大小命令由小到大依次为:

\tiny \scriptsize \footnotesize \small \normalsize \large \Large \LARGE \huge \Huge 以上大小控制命令也可以用在其他地方,但写法可能有变化,如要改变公式字体大小(非必需不要改,公式一行放不下可以分多行)

\begin{small} \begin{equation} +++ \end{equation} \end{small}

*****************************************************************************************************************

正文中的公式$a+b=c$,单独一行的公式$$a+b=c$$ 或者\[a + b = c\],均无编号

正文加公式编号

\begin{equation}

\text{\parbox{0.925\textwidth}{All AIDS patients are infected with HIV. Antony

Perkins has AIDS. But he is not infected with HIV. These

two sentences are inconsistent.}}

\end{equation}

\begin{equation}\label{eq1} %要手动空格才能让后面公式居中

\text{\parbox{0.925\textwidth}{Error: \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad $e(t)=Rin(t)-Cout(t)$ }}

\end{equation}

手动的公式(编号) $$x^n+y^n=z^n \eqno{(1)}$$

$$公式\leqno编号$$ 将编号放在左边

如果要改变公式的自动编号,可以重设计数器初始值:

setcounter{equation}{数}

单个公式很长,需要换行,但仅允许生成一个编号时,可以用split命令(也可以用Array,下面关于公式的整理的不好不必细看)

\begin{equation}

\begin{split}

a &=

b \

c &= d

end{split}

end{equation}

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

多个公式共用一个编号

\begin{equation}\label{subSWandSB}

\begin{aligned}

\begin{matrix}

S_W=\sum\limits_{r=1}^C \sum\limits_{\theta =1}^{C_r} \sum\limits_{\rho

=1}^{N_{(r)(\theta)}}(h_\rho^{(r)(\theta)}-\mu^{(r)(\theta)})(h_\rho^{(r)(\theta)}-\mu^{( r)(\theta)})^T \\

S_B=\sum\limits_{i=1}^C \sum\limits_{r \neq i}^{C} \sum\limits_{j=1}^{C_i}

\sum_{\theta=1}^{C_r} (\mu^{(i)(j)}-\mu^{(r)(\theta)})(\mu^{(i)(j)}-\mu^{(r)(\theta)})^T \end{matrix}

\end{aligned}

\end{equation}

再如:----------------------------------------------------------------------------------- \begin{eqnarray}\label{eq:10}

&&E\{|[z(1,j)-z(1,j+N/2)]-[z(2,j)-z(2,N/2+j)]|^2\} \\

&=&E\{|[\eta(1,j)-\eta(1,j+N/2)]-[\eta(2,j)-\eta(2,j+N/2)]|^2\}\nonumber \\

&=&4W \nonumber

\end{eqnarray}

\nonumber 此行不编号

或者加 * 表示该公式或图不编号

\begin{equation*}[h]\label{eq:1}

\includegraphics*[width=5.36in

表格不用\caption 就不会编号,直接添加好了,比如

\centerline{\bf The caption.}

==================================================================== The split Environment 公式分行

The split environment is not an independent environment but should be used inside something else, such as equation or align. If there is not enough room for it, the equation number for a split will be shifted to the previous line when equation numbers are on the left; the number shifts down to the next line when numbers are on the right. When you do not want an equation number, use the equation* environment. This was produced by the following input (the TEX command \phantom is used to leave a space equal to the width of its argument):

\begin{equation}

\begin{split}

f_{h,\varepsilon}(x,y)

&= \varepsilon \mathbf{E}_{x,y} \int_0^{t_\varepsilon}

L_{x,y_\varepsilon(\varepsilon u)} \varphi(x) \, du \\

&= h \int L_{x,z} \varphi(x) \rho_x (dz) \\

& \quad +h \biggl[ \frac{1}{t_\varepsilon} \biggl(

\mathbf{E}_{y} \int_0^{t_\varepsilon} L_{x,y^x(s)} \varphi(x)\,ds

-t_\varepsilon \int L_{x,z} \varphi(x) \rho_x(dz) \biggr) \\

& \phantom{{=}+h\biggl[}+\frac{1}{t_\varepsilon}

\biggl( \mathbf{E}_{y} \int_0^{t_\varepsilon} L_{x,y^x(s)}

\varphi(x) \,ds - \mathbf{E}_{x,y} \int_0^{t_\varepsilon}

L_{x,y_\varepsilon(\varepsilon s)}

\varphi(x) \,ds \biggr) \biggr] \\

---------------------------------------------------------------------------------------------------------------------- caption较长时如何居中?一般也无需居中

\begin{figure}[htb]

\centering

\includegraphics[width=2.5in]{}

\caption{aaa bbb } \*{abcdefghighlmn}

\end{figure}

---------------------------------------------------------------------------------------------------------------------- 插入汉字参考https://www.wendangku.net/doc/8716253020.html,/ligangliu/latexforum/tex_cjk.htm

CJK 的使用比较简单。首先在文件的头部(\documentclass 之后)加上:\usepackage{CJK}

然后在正文中(\begin{document} 到\end{document})需要使用中文的地方使用:\begin{CJK*}{GBK}{song} ……中文或者英文…… \end{CJK*}

这样中间的中文部分就会以宋体来排版。常用的其他字体还有:fs(仿宋)、kai(楷体)、hei(黑体)、li(隶书)、you(幼圆)。命令中的GBK 是指中文内码,还可以用GB 和BIG5(繁体字),前提是相应的字库设置是正确的。CJK Setup for Win32中已经设置好

了GB 和GBK。

如果在中间想要改变中文字体,就可以使用:

\CJKfamily{GBK}{fs}

来改为仿宋字体。改变中文字体的大小使用和英文相同的命令,也就是说中文和它附近的英文大小始终都是一致的。

以上所说都是针对使用TrueType 字库的。如果Type1 字库生成时使用了-c 参数,也就是说是compact 模式的,那么用法是一样的。而Type1 字库更常用的一种方式是不使用-c 参数生成的,称作pmC 模式。则相应的CJK 命令中要加上[pmC] 参数: \begin{CJK*}[pmC]{GB}{song} …… \end{CJK*}

------------------------------------------------------------------------------- 斜体与加粗 \it \bf等,公式特殊字母加粗斜体使用\bm

================================================================================ \begin{algorithm}[htb] %算法的开始

\caption{The building process of NPHT} %算法的标题

\label{NPHTB} %给算法一个标签,这样方便在文中对算法的引用

\begin{algorithmic}[1] %出现的序号

\REQUIRE ~~\\ %算法的输入参数:Initialization

Let the pointer $P$ point to the first trie structure

\ENSURE ~~\\ %算法的迭代:Iteration

\IF{$P$ is NULL}

\STATE Build a new trie and insert the rule into the second layer;

\RETURN;

\ENDIF

\STATE Let the pointer $S$ point to the root node of the trie which $P$ point to; \LOOP

\IF{the rule of the node $S$ point to is NULL}

\STATE Add a pointer point to the second layer and add the rule;

\RETURN;

\ENDIF

\IF{the prefix of the $S$ node is the same with the inserted prefix}

\STATE Insert the rule into the second layer of the node;

\RETURN;

\ENDIF

\IF{the prefix of the $S$ node has prefix relationship with the inserted prefix} \STATE End of the search in this tree and point the P to the next trie, restart the loop;

\ENDIF

\STATE Compare the second bit of the insert prefix and make the $S$ point to the child

\ENDLOOP

\lastcon ~~\\

\end{algorithmic}

\end{algorithm}

-------------------------------------------------------------------------------------------表格单元格划斜线 \backslashbox{Parameters}{Network Type}

\input{config}

%\makeatletter

%\renewcommand\normalsize{%

%\@setfontsize\normalsize\@xpt\@xiipt

% \abovedisplayskip 5\p@ \@plus2\p@ \@minus5\p@

%\belowdisplayskip 8\p@ \@plus2\p@ \@minus5\p@

%\abovedisplayshortskip \z@ \@plus3\p@

% \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@

%\belowdisplayskip \abovedisplayskip

% \let\@listi\@listI}

%\makeatother

\usepackage{enumerate}

------------------------------------------------------------------------------------------- origin

origin 指定图形绕那一点旋转,缺省是图形的参考点(12/95 增加)。

初始点有可能与第 8.3节的 \rotatebox 命令中的一样。比如 origin=c

将使图形绕它的中心旋转。

bb

设定 BoundingBox 的值。 bb=10 20 100 200 设定 BoundingBox 的左

下角在 (10,20),右上角在 (100,200)。因为 \includegraphics 会自

动从 EPS 文件中读入 BoundingBox 行所给的值,所以一般不使用 bb 这

个选项。但它在 EPS 文件中的 BoundingBox 丢失或出错时还是很有用

的。

viewpoint

指定图形可以被看到的部分。如同 BoundingBox 一样,这是一个

由四个数字,左下角和右上角的坐标所确定的区域。这里的坐标

是相对于 BoundingBox 的左下角的(6/95 增加)。

例如,如果图形的 BoundingBox 的值是 50 50 410 302,

viewpoint=50 50 122 122 将显示以图形的左下角为左下角的

一英寸大小的区域。而 viewpoint=338 230 410 302 则会显示

以图形的右上角为右上角的一英寸大小的区域。

必须使用 clip 选项(见表 7.3)来阻止显示视图以外的图形部

分。

trim

指定图形可以被看到的部分的另一选项。所给出的四个数字分别

代表了从左、下、右、上被截去的值。正数代表从此方向截去的

大小,而负数则代表从此方向加上的大小。

-------------------------------------------------------------------------------------

教一下,这个怎么变成3-9

加个宏包,\usepackage{cite}

%%%%\RequirePackage[numbers,sort&compress]{natbib}

\usepackage[numbers,sort&compress]{natbib} %会影响参考文献格式

-------------------------------------------------------------------------------------

表格字体已经设置为\tiny还是超出页宽怎么处理:使表格更紧凑,减小间距

\tabcolsep 0.05in

\begin{tabular}

----------------------------------------------------------------------------------------

并列子图

\begin{figure}[!h]

\centering

\graphfile[33]{F1.eps}[$f_1$]

%\graphfile[33]{F2.eps}[$f_2$]

\graphfile[33]{F3.eps}[$f_3$]

%\graphfile[33]{F4.eps}[$f_4$]

\graphfile[33]{F5.eps}[$f_5$]\\

%\graphfile[33]{F6.eps}[$f_6$]\\

\graphfile[33]{F7.eps}[$f_7$]

%\graphfile[33]{F8.eps}[$f_8$]

\graphfile[33]{F9.eps}[$f_9$]

%\graphfile[33]{F10.eps}[$f_{10}$]

\graphfile[33]{F11.eps}[$f_{11}$]

%\graphfile[33]{F12.eps}[$f_{12}$]

\caption{Comparison among SPSO, PSO-OBL-w and PSO-OBL on the selected functions.}

\label{fig:fig1}

\end{figure}

+++++++++++++++++++++++++++++

Just taking the definition of \xrightarrow and replacing r by R :

\documentclass{article}

\usepackage{amsmath}

\makeatletter

\newcommand{\xRightarrow}[2][]{\ext@arrow 0359\Rightarrowfill@{#1}{#2}}

\makeatother

\begin{document}

$\xrightarrow{hello}$

$\xRightarrow{hello}$

\end{document}

关于自动生成参考文献,一般模板指定格式,每次编译会生成bbl文件覆盖修改后的文件。把bbl文件里面内容复制出来替换掉

%{\small

%\bibliographystyle{ieee}

%\bibliography{egbib}

%}

\begin{thebibliography}{10}

\end{thebibliography}

相关文档