Latex简明参考指南

294 阅读2分钟

本文已参与「新人创作礼」活动,一起开启掘金创作之路。


本人会将经常用到的latex技巧或者是命令总结更新于此,便于日后直接复制粘贴。

repeat util

效果:

在这里插入图片描述

代码:


\usepackage[ruled,linesnumbered]{algorithm2e}

\begin{algorithm}[tp]
\caption{Test Algoritm2e}
\label{procedure}
\KwIn{Samples: $\{\mathcal{X}, \mathcal{Y}\}$.}
\Repeat{convergence condition}{
     $\mathbf{X}_b \leftarrow$ a random minibatch from $\mathcal{X}$ \\
     \uIf{warm-up over}{
        start training
    }
}
\end{algorithm}


if else

效果:

同上

代码:

同上

latex 包含于 包含

包含于: ABA \subseteq B 代码:

A \subseteq B

真包含于: ABA \subset B 代码:

A \subset B

真包含: BAB \supseteq A 代码:

B \supseteq A

包含 BAB \supset A 代码:

B \supset A

latex figure table htpb 到底是什么意思

\figure[htpb]

h(此处),t(上方),b(下方),p(浮动页。 将图形放置在允许有浮动对象的页面上。)

按顺序选择,也可以只用某一个,某几个。

Latex长箭头上加字

效果:

Xθf(X,θ,Z)YX \xrightarrow[\theta]{f(X, \theta, Z)} \mathcal{Y}

代码:

\usepackage{amsmath}

X \xrightarrow[\theta]{f(X, \theta, Z)} \mathcal{Y}

注意,这种方式的箭头长度会随着上面{}或者下面[]的文字长度而变化。

如果用: \longrightarrow: \longrightarrow,则不能加字。

表格

持续更新。只要我用到一个表格,我就会放上来,不断增加表格样式。

方便随时直接复制粘贴使用。

样式一:

\usepackage{times}
\usepackage{soul}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{multirow}
\begin{table*}[t]
\centering
\begin{tabular}{ccc|ccc}
\toprule[1pt]

\multicolumn{3}{c|}{Components} & \multicolumn{3}{c}{Metrics} \\
\hline
C1 & C2 & C3  &M1 & M2 & M3  \\
\hline
w/o& w/o& w/o &6 & 14 & 0.7\%  \\
w/o& w/o& w/o  & 3 &  6.87 &  0.3 \% \\
w/& w/o& w/o  &8 & 9 & 0.5\% \\
w/o& w/& w/o & 51 & 85 & 0.2\%  \\
w/o& w/& w/  &\textbf{6} & \textbf{3} &  \textbf{9\%} \\

\bottomrule[1pt]
\end{tabular}
\centering
\caption{This can be used for ablation study.}
\label{ablation}
\end{table*}

样式二

效果:

\begin{table}[t]
\centering
\begin{tabular}{ccc|ccc}
\toprule[1pt]

\multicolumn{3}{c|}{Components} & \multicolumn{3}{c}{Metrics} \\
\hline
C1 & C2 & C3  &M1 & M2 & M3  \\
\hline
w/o& w/o& w/o &6 & 14 & 0.7\%  \\
w/o& w/o& w/o  & 3 &  6.87 &  0.3 \% \\
w/& w/o& w/o  &8 & 9 & 0.5\% \\
w/o& w/& w/o & 51 & 85 & 0.2\%  \\
w/o& w/& w/  &\textbf{6} & \textbf{3} &  \textbf{9\%} \\

\bottomrule[1pt]
\end{tabular}
\centering
\caption{This can be used for performance comparison.}
\label{ablation}
\end{table}

下面是一些关于数学符号或者语法的小技巧或者小命令。

【latex 数学符号】latex for any

\forall: \forall