latex使用!🦸🏻‍♂️

latex使用

1. Dutchcal花体字母

用于更改数学模式下的教科书字母(calligraphic letters)的外观。默认情况下,LaTeX 提供 \mathcal 命令用于生成教科书字母,但它的风格可能比较简单。dutchcal 包提供了一种替代的风格,通常更加复杂和具有装饰性。

使用:

1
2
3
4
5
6
7
8
\documentclass{article}
\usepackage{dutchcal}

\begin{document}

这是一些使用 `dutchcal` 风格的字母:$\mathcal{A}$, $\mathcal{B}$, $\mathcal{C}$

\end{document}

使用前:

使用后:

2. 单词指定断字

在 LaTeX 中,\hyphenation 命令用于指定单词的断字位置。当 LaTeX 需要在单词的某个位置断行时,如果默认的断字规则不符合要求,可以使用这个命令手动指定可断开的词缀。

例如:

1
\hyphenation{op-tical net-works semi-conduc-tor}

这个命令告诉 LaTeX 在排版 opticalnetworkssemiconductor 这些单词时,可以在指定的位置进行断字。这在长单词需要在行尾断开时特别有用,确保断字的地方符合读者的习惯并保持美观。

3. 具有音标字符

在 LaTeX 中,\u{} 命令用于生成具有上方小勾(也称为标记或音标)的字符。这种小勾通常用于标记重音或特定语音特征。在 \u{} 命令中,你可以指定要在其上方添加的字符,并使用其 Unicode 编码点来定义。

例如,\u{G} 可能用于生成带有 G 字符上方小勾的字符。这种符号在语言学和语音学上有特定的用途,用于指示音素或语音变体。

4. 伪代码

1
\usepackage[ruled,vlined]{algorithm2e}

\usepackage[ruled,vlined]{algorithm2e} 是 LaTeX 的一个包,它用于排版算法。以下是每个选项的解释:

  • ruled:在算法的顶部和底部添加水平线,以使算法更清晰地分隔开。
  • vlined:在算法的每行旁边添加竖线,以使算法的结构更清晰。

1
\renewcommand{\algorithmcfname}{Procedure}

原来的标题是Algorithm,通过上述命令可以指定标题,例如本例中的Procedure

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
\begin{algorithm}[H]
\begin{small}
% \SetAlgoLined
\SetKwInOut{Input}{In}
\SetKwInOut{Output}{Out}
\Input{Algebra Problem Diagram}
\Output{Diagram Relation sets}
\BlankLine
\For{each relation of relation sets}{
Determine from which sentence this relation was obtained. \\
Determine to which scene this sentence belongs.
}
\BlankLine
Get organized relation sets along with their corresponding scenes.
\caption{Procedure of evolution}
\end{small}
\end{algorithm}

上面是伪代码结构主体部分,其中:

1.\SetKwInOut{Input}{In}\SetKwInOut{Output}{Out}定义关键字标签,如图所示

2.\BlankLine添加空行

3.\For{}{} 或者 \ForEach{}{}构成For循环

4.\If{}{} 或者 \eIf{}{}构成If 或者 if-else结构

5.\SetAlgoLined设置结尾出是否有end

6.small用来调节伪代码的大小

5. 画图

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
\begin{figure}[htp]
\centering
\thispagestyle{empty}

\tikzstyle{S0} = [rectangle, thick, rounded corners=0.5mm,minimum width = 4cm, minimum height=0.4cm,text centered, draw = black,font=\fontsize{9}{10}\selectfont\bfseries, fill=gray!10]
\tikzstyle{D} = [rectangle, text width=0.4cm,thick,rounded corners=2mm, minimum width = 0.7cm, minimum height=0.3cm,text centered, draw = black,font=\fontsize{7}{7}\selectfont\bfseries]
\tikzstyle{SS} = [rectangle,thick,text width=2cm,rounded corners=1mm, minimum width = 1cm, minimum height=0.5cm,text centered,draw=blue, % 修改边框颜色为蓝色
fill=blue!10, font=\fontsize{7}{7}\selectfont]
\tikzstyle{S} = [rectangle,thick,text width=2cm,rounded corners=1mm, minimum width = 1cm, minimum height=0.5cm,text centered,draw=black,, % 修改边框颜色为蓝色
font=\fontsize{7}{7}\selectfont]
\tikzstyle{S1} = [rectangle,thick,inner xsep=3mm,rounded corners=1mm, minimum width = 1cm, minimum height=0.5cm,text centered, draw = black,font=\fontsize{7}{7}\selectfont]
\tikzstyle{S2} = [rectangle,thick,text width=1.5cm,rounded corners=1mm, minimum width = 1cm, minimum height=0.5cm,text centered, draw = black,font=\fontsize{7}{7}\selectfont]
\tikzstyle{SS2} = [rectangle,thick,text width=1.5cm,rounded corners=1mm, minimum width = 1cm, minimum height=0.5cm,text centered, draw = blue,fill = blue!10,font=\fontsize{7}{7}\selectfont]
\tikzstyle{F} = [rectangle,thick,text width=0.5cm,rounded corners=0.5mm, minimum width = 0.7cm, minimum height=0.4cm,text centered, draw = black,font=\fontsize{7}{7}\selectfont\bfseries]
\tikzstyle{FF} = [rectangle,thick,text width=0.5cm,rounded corners=0.5mm, minimum width = 0.7cm, minimum height=0.4cm,text centered, draw = blue,fill = blue!10,font=\fontsize{7}{7}\selectfont\bfseries]
\tikzstyle{T} = [rectangle,thick,dashed,inner xsep=2mm,rounded corners=1mm, minimum width = 1cm, minimum height=0.5cm,text centered, draw = black,font=\fontsize{7}{7}\selectfont]
\tikzstyle{T1} = [rectangle,thick,dashed,text width=1cm,rounded corners=1mm, minimum width = 1cm, minimum height=0.5cm,text centered, draw = black,font=\fontsize{7}{7}\selectfont]
\tikzstyle{TT1} = [rectangle,thick,dashed,text width=1cm,rounded corners=1mm, minimum width = 1cm, minimum height=0.5cm,text centered, draw = blue,fill =blue!10,font=\fontsize{7}{7}\selectfont]
\tikzstyle{E} = []

\vspace{0.3cm}
\tikzstyle{A} = [->,>=stealth,rounded corners, thick]
\tikzstyle{AA} = [->,>=stealth,rounded corners, thick,blue]
\begin{tikzpicture}[node distance=1cm]
% \selectcolormodel{gray}

\node[S0](Start){Algebra Problem};
\node[D,right of = Start,yshift = -0.55cm,xshift=-1cm](D1){$\mathcal{D}_{01}$};
\node[SS,right of = D1,yshift = -0.8cm,xshift=0.5cm](S1){Algebra Problem Diagram};
\node[S,left of = D1,yshift = -0.8cm,xshift=-0.5cm](S2){Algebra Problem Text};
\node[F,right of = S2,yshift = -1.4cm,xshift=-1cm](F1){$\mathcal{F}_{01}$};
\node[T,left of = S2,yshift = -0.8cm,xshift=-0.4cm](T1){vectorizer};
\node[E,right of = S2,yshift = -0.8cm,xshift=-0.9cm](E1){};
\node[S1,right of = F1,yshift = -0.55cm,xshift=-1cm](S3){Vector Text};
\node[D,right of = S3,yshift = -0.55cm,xshift=-1cm](D2){$\mathcal{D}_{02}$};
\node[F,left of = D2,yshift = -1.4cm,xshift=-1.5cm](F2){$\mathcal{F}_{02}$};
\node[F,right of = D2,yshift = -1.4cm,xshift=-1cm](F3){$\mathcal{F}_{03}$};
\node[T1,left of = D2,yshift = -0.7cm,xshift=-0.3cm](T2){scene detector};
\node[T1,right of = D2,yshift = -0.7cm,xshift=0.3cm](T3){neural miner};
\node[E,right of = D2,yshift = -0.7cm,xshift=-1.1cm](E2){};
\node[E,left of = D2,yshift = -0.7cm,xshift=-1.6cm](E3){};
\node[S2,right of = F2,yshift = -0.6cm,xshift=-1cm](S4){Scene-Aware Relation Sets};
\node[S1,right of = F3,yshift = -0.55cm,xshift=-1cm](S5){Relation Sets};
\node[F,right of = S5,yshift = -1cm,xshift=-1cm](F4){$\mathcal{F}_{04}$};
\node[S1,right of = F4,yshift = -0.55cm,xshift=-1cm](S6){Integrated Relation Sets};
\node[D,right of = S6,yshift = -0.55cm,xshift=-1cm](D3){$\mathcal{D}_{03}$};
\node[F,right of = D3,yshift = -1.4cm,xshift=-1cm](F5){$\mathcal{F}_{05}$};
\node[S0,right of = F5,yshift = -0.55cm,xshift=-1cm](End){Solution};
\node[T1,right of = D3,yshift = -0.7cm](T4){symbolic solver};
\node[E,right of = D3,yshift = -0.7cm,xshift=-1.1cm](E4){};

\node[FF,right of = S1,yshift = -3.9cm,xshift=-1cm](F6){$\mathcal{F}_{06}$};
\node[SS2,right of = F6,yshift = -0.6cm,xshift=-1cm](S6){Diagram Relation Sets};
\node[TT1,left of = S1,yshift = -1cm,xshift=-0.4cm](T5){diagram relation extractor};
\node[E,right of = S1,yshift = -1cm,xshift=-0.9cm](E5){};




\draw [AA] (D1) -| (S1);
\draw [A] (D1) -| (S2);
\draw [A] (S2) -- (F1);
\draw [A] (T1) -- (E1);
\draw [A] (D2) -| (F2);
\draw [A] (D2) -- (F3);
\draw [A] (T3) -- (E2);
\draw [A] (T2) -- (E3);
\draw [A] (S5) -- (F4);
\draw [A] (S4) |- (F4);
\draw [A] (D3) -- (F5);
\draw [A] (T4) -- (E4);
\draw [AA] (S1) -- (F6);
\draw [AA] (S6) |- (F4);
\draw [AA] (T5) -- (E5);

\end{tikzpicture}
\caption{The state-transform graph of solving algebra problems, the blue part is the result of evolution}
\label{fig2}
\end{figure}

效果如下:

1
2
# 必要的包
\usepackage{tikz}
1
2
3
\begin{figure}[htp]
\centering
\thispagestyle{empty}

1.参数[htp]指示LaTeX尽量将图片放置在合适的位置(这里指的是这里(h)、顶部(t)、单独一页(p))

2.\centering:将图片居中对齐,\raggedright:左对齐图片,\raggedleft:右对齐图片。

3.\thispagestyle{empty}:设置当前页面的页眉页脚为空。

1
\tikzstyle{S0} = [rectangle, thick, rounded corners=0.5mm,minimum width = 4cm, minimum height=0.4cm,text centered, draw = black,font=\fontsize{9}{10}\selectfont\bfseries, fill=gray!10]
  1. \tikzstyle{S0} = [...]:定义一个名为 S0 的 TikZ 样式。
  2. rectangle:形状为矩形。
  3. thick:线条为厚线。
  4. rounded corners=0.5mm:圆角半径为 0.5 毫米。
  5. minimum width=4cm:矩形宽度最小为 4 厘米。
  6. minimum height=0.4cm:矩形高度最小为 0.4 厘米。
  7. text centered:文本居中对齐。
  8. draw=black:边框颜色为黑色。
  9. font=\fontsize{9}{10}\selectfont\bfseries:字体大小为 9pt,行间距为 10pt,粗体。
  10. fill=gray!10:填充颜色为 10% 的灰色。
1
2
\tikzstyle{E} = [] #设置空点,为了方便后续在线段中间连线
\vspace{0.3cm} #在当前行下方插入 0.3 厘米的垂直空白。这可以用于增加段落之间的间距,或者在特定的布局位置创建空白区域。
1
2
\tikzstyle{A} = [->,>=stealth,rounded corners, thick]
\tikzstyle{AA} = [->,>=stealth,rounded corners, thick,blue]
  1. ->:表示线条有箭头,箭头指向线条的终点。
  2. >=stealth:指定箭头的样式为 stealth,这是 TikZ 提供的一种常见箭头样式。
  3. rounded corners:线条的角为圆角,而不是直角。
  4. thick:线条的粗细为“厚”,即比默认线条粗。
  5. blue:线条的颜色为蓝色。
1
2
\begin{tikzpicture}[node distance=1cm] #设置所有节点的默认距离为 1 厘米
% \selectcolormodel{gray} #设置所有颜色只能为gray
1
\node[D,right of = Start,yshift = -0.55cm,xshift=-1cm](D1){$\mathcal{D}_{01}$}
  1. \node:用于创建一个新节点。
  2. [D]:应用之前定义的样式 D,该样式可能在 \tikzstyle\tikzset 中定义。
  3. right of=Start:将节点放置在名为 Start 的节点的右侧。这个位置是相对的。
  4. yshift=-0.55cm:将节点垂直方向上移动 -0.55 厘米(向下移动)。
  5. xshift=-1cm:将节点水平方向上移动 -1 厘米(向左移动)。
  6. (D1):为节点指定一个标签 D1,以便在其他地方引用。
1
\draw [AA] (D1) -| (S1)
  1. \draw:用于绘制线条。
  2. [AA]:应用定义的样式 AA,这可能包括箭头类型、颜色和线条粗细等。
  3. (D1):线条的起点节点。
  4. -|:绘制 L 形折线。线条首先水平延伸到与目标节点 S1 对齐的位置,然后垂直延伸到目标节点。
  5. (S1):线条的终点节点。
1
2
\caption{The state-transform graph of solving algebra problems, the blue part is the result of evolution}  #标题
\label{fig2} #引用标签

6. 表格

tabular包:

1
2
3
4
5
6
7
8
9
10
11
12
\begin{table}[]
\begin{tabular}{l|lll|l}
\hline
\multirow{3}{*}{alg} & \multicolumn{3}{l|}{dataset} & \multicolumn{1}{c}{\multirow{3}{*}{sum}} \\ \cline{2-4}
& \multicolumn{2}{l|}{math} & \multirow{2}{*}{geo} & \multicolumn{1}{c}{} \\ \cline{2-3}
& 1 & \multicolumn{1}{l|}{2} & & \multicolumn{1}{c}{} \\ \hline
s & a & \multicolumn{1}{l|}{a} & a & a \\
s & a & \multicolumn{1}{l|}{a} & a & a \\
d & a & \multicolumn{1}{l|}{a} & a & a \\
o & a & \multicolumn{1}{l|}{a} & a & a \\ \hline
\end{tabular}
\end{table}

1
\usepackage{multirow} # 必要的包

tblr包:

网站教程:https://www.latex-tables.com/ressources/tabularray.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
\usepackage{tabularray} 

\begin{tblr}{
vlines = {},
hlines = {},
cell{1}{1} = {c = 4}{halign = c},
cell{2}{1} = {r = 3}{valign = m},
cell{3}{3} = {c = 2, r = 2}{c,m}
}
A1 & & & \\
A2 & B2 & C2 & D2 \\
& B3 & C3 & \\
& B4 & &
\end{tblr}
  1. hlines 设置所有水平边框,hline 设置特定的水平边框,vlines 设置所有垂直边框,vline 设置特定的垂直边框

例如:

1
2
3
4
5
6
7
8
9
\begin{tblr}{
vline{1,4} = {3pt},
hline{1,4} = {},
hline{2} = {blue,dotted}
}
A1 & B1 & C1 \\
A2 & B2 & C2 \\
A3 & B3 & C3
\end{tblr}

2.使用 r 键设置行数或使用 c 设置单元格数,对齐方式如下:

halign = l:水平方向左对齐

halign = c:水平方向居中对齐

halign = r:水平方向右对齐

valign = t:垂直方向顶部对齐

valign = m:垂直方向居中对齐

valign = b:垂直方向底部对齐

halign = j:水平方向两端对齐

效果:

7. 参考文献引用

1
2
\bibliographystyle{elsarticle-num}
\bibliography{main}

把所有论文的bibtex复制进main.bib,根据引用顺序自动编号


latex使用!🦸🏻‍♂️
https://yangchuanzhi20.github.io/2024/06/18/工具/latex使用/
作者
白色很哇塞
发布于
2024年6月18日
许可协议