latex小白入门技巧

1 处理中文

首先必须要让.tex的文本文件是utf-8编码;然后要引用宏包\usepackage{ctex}

2 latex 文档结构

latex文档主要包含两个区:导言区和正文区(文稿区)
导言区:全局设置

\documentclass{article} %book,report,letter
\title{My first document}
\author{San Zhang}

3 公式编辑

3.1 等号对齐

\begin{equation}\label{equ:LB}
\begin{aligned}
\log p(\bX) &= \log \int p(\bX,\btheta) d\btheta \
&\geq \int q(\theta) \log {\frac{p(X,\theta)}{q(\theta)}}d\theta = \mathcal{F}(q)
\end{aligned}
\end{equation}

4 表格编辑

4.1 两个表格并排放

\begin{minipage}{\textwidth}
\begin{minipage}[t]{0.5\textwidth}
\centering
\makeatletter\def@captype{table}\makeatother\caption{LDA混淆矩阵}
\begin{tabular}{cccc}
\hline
predicted\textbackslash{}true & 1 & 2 & 3 \ \hline
1 & 478 & 22 & 0 \
2 & 4 & 494 & 2 \
3 & 0 & 20 & 480 \ \hline
\end{tabular}
\end{minipage}
\begin{minipage}[t]{0.5\textwidth}
\centering
\makeatletter\def@captype{table}\makeatother\caption{QDA混淆矩阵}
\begin{tabular}{cccc}
\hline
predicted\textbackslash{}true & 1 & 2 & 3 \ \hline
1 & 489 & 11 & 0 \
2 & 9 & 483 & 8 \
3 & 0 & 10 & 490 \ \hline
\end{tabular}
\end{minipage}
\end{minipage}

4.2 特殊表格的设置(一)

\begin{table}[]
\centering
\caption{不同方法在波形数据上的分类性能}
\begin{tabular}{ccc}
\hline
\multirow{2}{*}{Methods} & \multicolumn{2}{c}{Error Rates} \ \cline{2-3}
& Training & Test \ \hline
LDA & 0.13(0.018) & 0.196(0.013) \
QDA & 0.039(0.014) & 0.212(0.013) \
FDA/MARS(degree=1) & 0.102(0.024) & 0.2(0.016) \
FDA/MARS(degree=2) & 0.072(0.017) & 0.209(0.016) \
MDA(3 subclasses) & 0.089(0.015) & 0.177(0.013) \
MDA(3 subclasses penalized 4 df) & 0.141(0.023) & 0.167(0.019) \
PDA(penalized 4 df) & 0.147(0.017) & 0.163(0.02) \ \hline
\end{tabular}
\end{table}

5 多行公式编译

\usepackage{IEEEtrantools}
\begin{IEEEeqnarray}{rCl}

\end{IEEEeqnarray}

如果该公式环境下的所有公式都不编号,只需要加星号即可,\begin{IEEEeqnarray*}{rCl} \end{IEEEeqnarray*}.r如果只是该环境下的某一行公式不需要加编号,则只需要在该行公式前加\nonumber即可。

6 插入算法

 \begin{algorithm}[htbp]
 	\caption{CM algorithm for BFA}\label{alg:algorithm1}
 	\begin{algorithmic}[1]
 		\REQUIRE
 		Data $\cX$, subspace dimensions $(q_c,q_r)$, and initialization $(\bR,\bPsi_r,\bPsi_c)$.	 		
		\REPEAT
		\STATE
		\textbf{CM-Step1:} 
		\STATE	
		Compute $\bS_c$ by \refe{equ:S_c}, and compute $\btS_c$ by \refe{equ:S_cw}.
 		\STATE
		Update $\btC$ by \refe{equ:btC}, and update $\btPsi_c$ by \textcolor{red}{Yu and Zhao(2013)}.			
		\STATE
		\textbf{CM-Step2:}
		\STATE
		Compute $\bS_r$ by \refe{equ:S_r}, and compute $\btS_r$ by \refe{equ:S_rw}.
		\STATE
		Update $\btR$ by \refe{equ:btR}, and update $\btPsi_r$ by \textcolor{red}{Yu and Zhao(2013)}.	
		\UNTIL change of $\cL$ is smaller than a threshold.				
 		\ENSURE
		$(\btC,\btPsi_c,\btR,\btPsi_r)$
 	\end{algorithmic}
 \end{algorithm}

7 参考文献中出现&报错: 只需要在用\&即可.

8 定义新的引用命令

8.1 新的引用算法的命令

\newcommand\refa[1]{Algorithm~\ref{#1}}
\newcommand\refal[2]{Algorithm~\ref{#1}, line \ref{#2}}
\newcommand\refall[3]{Algorithm~\ref{#1}, line \ref{#2}-line \ref{#3}}

\refa{}
\refal{}{}
\refall{}{}{}

8 xcolor的颜色设置

https://blog.csdn.net/u014546828/article/details/104046713

插入图片问题

如果用pdflatex编译器,则插入图片的格式最好是pdf格式的;如果如果用latex编译,自然用eps,如果是xelatex编译器,则pdf和eps格式均可。
1.eps转pdf
matlab里的图可以另存外eps,但是pdflatex不认eps,怎么办,转吧。
我装的是CTEX最新版。里面自带eps转pdf的工具 epstopdf
如果CTEX正常安装的话, 打开cmd,直接cd到eps文件所在目录(假设名为a.eps),执行命令:epstopdf a.eps 就会在当前目录生成a.pdf
2.pdf转eps
这个必须借助Adobe acrobat,用它打开pdf,然后另存为ps,再用gsviewer打开ps,另存为eps即可。

并排摆放三个图片,每个图片一个子标题,然后三个图片共享一个总标题

\usepackage{subfig}
\begin{figure*}[htbp]%[tb]%![!htb]
\centering
\subfloat[原始生成模型]{
\scalebox{0.8}[0.8]{\includegraphics*{fig/GM1.eps}}
}
\subfloat[两阶段生成模型\refe{equ:bfa1}]{
\scalebox{0.8}[0.8]{\includegraphics*{fig/GM2.eps}}
}
\subfloat[两阶段生成模型\refe{equ:bfa2}]{
\scalebox{0.8}[0.8]{\includegraphics*{fig/GM3.eps}}
}
\vspace{-10pt}
\centering \caption{BFA的概率图模型} \label{fig:GM}
\end{figure*}

设置表格的间距

\renewcommand\arraystretch{0.8}
\resizebox{\linewidth}{!}{
}

文本中文编译后显示问号?

\usepackage{ctex}
另外,文本设置utf-8格式
在这里插入图片描述

latex 中公式编辑-括号换行的情形

公式编辑时,对于不同宽度的式子,使用\left( \right)可以优化括号的大小,但是在两个括号之间如果换行,则后一个括号会出现错误。

解决办法:\left( \(换行符)

                                                    \right)改写为

              \left(                \right.\\(换行符)

                           \left.                  \right)

注意: 要有 .

在latex中使用eps图片的截取方法

\includegraphics*[87,420][507,578]{im_mse.eps}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大浪淘沙_scc

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值