记录一下打黑工时遇到的问题

排版英文论文用pdflatex

碰到的第一个问题就是,我从官网下的模板我不能用?这是否

首先官网下的模板肯定是没问题的,出问题的肯定是我配置的问题

我本机texlive环境是TeX Live 2022,用的texstudio 4.2.2,默认编译器是xelatex

问了孙红光老师,他推荐用overleaf在线编译。把模板的zip包传上去,一次就正常通过了,证明了模板没有问题

问了孙海天老师,他建议先把本地的TeX Live升级成最新版,然后用pdflatex编译

我在overleaf上更改了配置为TeX Live 2022和xelatex,果然报错了

换成pdflatex就能正常编译

于是我就在本地用pdflatex编译了两遍,这下成功了

问题解决方法:本地命令行用pdflatex命令编译,就不去换texstudio的默认编译器了,因为以后排版中文文字可能更多


特殊字符

长时间不用真的忘了

#,%,&不能直接打出来

要加\

# $ % & { } _ ^ ~ \

\# \$ \% \& \{ \} \_ \^{} \~{} \textbackslash


四级标题以上

LATEX只支持到三级标题,则四级标题以上就得想办法

我用\paragraph解决的,但是这样貌似不会被添加到目录中

庆幸这篇论文用不到目录

公用编号的多行公式

这个在lshort有,但是我从来没用过

这次终于用上了

为了对齐,用了array环境

array环境需要在数学环境中使用

latex
1
2
3
4
5
6
7
\begin{equation}
\begin{array}{ccccccccc}
0&1&2&3&4&5&6&7&8\\
+&*&d&-&b&a&d&c&a
\end{array}
\label{equation2}
\end{equation}

如果列数特别多,就不用手动打那么多c

如有39个c\begin{array}{*{39}{c}}

align环境

如果要用align环境,且每个公式都打上标记,就得在换行前打标记

latex
1
2
3
4
\begin{align}
f_i&=\sum^{C_t}_{j=1}{(M-|C_{(i,j)}-T_j)|}\label{equation5}\\
f_i&=\sum^{C_t}_{j=1}{(M-|C_{(i,j)}-T_j)|}\label{equation6}\\
\end{align}


双列排版时的自适应表格

排版遇到表格超出页面的情况,用tabularx宏包解决

latex
1
2
3
4
5
6
7
8
9
10
11
12
13
\begin{table*}[htbp]
\centering
\caption{Three Transfer Operators and Their Characteristics}
\begin{tabularx}{\linewidth}{XXX}
\toprule
Transfer operator & Transfer Factor & Target location \\
\midrule
Gene Transfer & Entire gene & Multigene chromosome \\
Insertion sequence elements (IS elements) & Short sequences where the first position is a function or endpoint & Gene head anywhere except the root \\
Root insertion sequence element (RIS element) & Short sequence where the first position is a function & Root of the gene\\
\bottomrule
\end{tabularx}
\end{table*}

需要注意的是,这是表格,不能用figure*环境

同时因为是双列排版,table*环境会使表格跨越两列,但是tabularx环境的宽度仍然被设置为了单列的宽度,于是就得将tabularx环境的宽度设置为\linewidth来解决

{XXX}表示三列都自适应对齐

算法排版

我找到一篇牛逼文章,但是代码直接粘过来会报错

感觉含金量不如孙海天

IEEE Access的环境没有algorithm宏包,所以得加上

注意:算法环境中有多行变量解释时,需要在\REQUIRE后加\ \\来换行

第一个\是假行

第二个\\是换行

比较复杂的算法排版代码如下:

latex
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
\begin{algorithm}[!tb]
\caption{Pseudo-code for GEP-SVM Algorithm}
\label{alg1}
\begin{algorithmic}[1]
\renewcommand{\algorithmicrequire}{ \textbf{Input:}}
\REQUIRE \ \\
\begin{tabularx}{\linewidth}{lX}
$cases$ & The sample data set. \\
$N$ & Population size. \\
$h$ & gene head length. \\
$e$ & gene tail length. \\
$n$ & Maximum number of operations of the function. \\
$k$ & The number of genes. \\
$MaxGeneration$ & Fitness of termination iteration. \\
$P_{mu}$ & The mutation probability \\
$P_{tr}$ & Probability of string insertion \\
$P_{re}$ & Recombination probability \\
$P_{ex}$ & Extraction probability
\end{tabularx}


\renewcommand{\algorithmicensure}{ \textbf{Output:}}
\ENSURE \ \\
\begin{tabularx}{\linewidth}{lX}
$Y$ & Optimal individual (classifier) \\
\end{tabularx}

\STATE Pretreat $cases$;
\STATE $S$=InitialPopulation;
\STATE Best\_Ind=null;
\STATE $m$=MaxGeneration;
\STATE repeat
\STATE analyze chromosome;
\STATE fitness();
\STATE $S$=Selection($S$);
\STATE $S$=Mutation($S$) by $P_{mu}$;
\STATE $S$=Transpostion($S$) by $P_{tr}$;
\STATE $S$=Recombinations($S$) by $P_{re}$;
\STATE $S$=Extraction($S$) by $P_{ex}$;
\STATE $S$=Invertion($S$) by $P_{in}$;
\STATE $S$=Adjustment($S$) by $P_{ad}$;
\STATE Retain(Best\_Ind);
\STATE $m=m-1$;
\STATE until $m=0$;
\STATE return(Best\_Ind);
\end{algorithmic}
\end{algorithm}

一个不好排的表格

首先是三线表的线,可以用\cmidrule{2-13}

然后是合并单元格

换成英文以后真不好排

latex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
\begin{table*}[htbp]
\begin{tabularx}{\linewidth}{cccccccccccccXXX}
\toprule
Year & \multicolumn{6}{c}{Average Temperature} & \multicolumn{6}{c}{Average Rainfall} & Accumulated & Total & Degrees of \\
\cmidrule{2-13}
& Jan. & Feb. & Mar. & Jul. & Aug. & Sept. & Jan. & Feb. & Mar. & Jul. & Aug. & Sept. & Temperature & Rainfall & Occurrence \\
\midrule
1933 & -2.4 & 3.7 & 7.3 & 28.3 & 27.9 & 20.5 & 1.8 & 0.8 & 34.5 & 47.4 & 77 & 48.3 & 5409.4 & 285.2 & 1 \\
1934 & -1.7 & 1.8 & 7.7 & 28.4 & 27 & 21.3 & 3.5 & 20.6 & 24.7 & 98 & 75.1 & 49.1 & 5312.2 & 527.7 & 1 \\
&&&&&&&&&&&&&&&\\
2009 & 2.5 & 6.1 & 9.7 & 27 & 24.9 & 22.5 & 5.4 & 0 & 14.8 & 155.6 & 124 & 31.5 & 5522.6 & 482.5 & 2 \\
2010 & -0.5 & 3.4 & 12 & 26.6 & 26.4 & 22.3 & 9.2 & 4.9 & 9.8 & 90.6 & 97.4 & 49.3 & 5534 & 593 & 1 \\
\bottomrule
\end{tabularx}
\end{table*}

subcaption宏包

IEEE Access模板貌似与这个宏包冲突,所以用不了这个

如果用到子图,就可以用subfigure宏包,这个不冲突

latex
1
2
3
4
5
6
7
8
9
10
11
12
13
\begin{figure}
\centering
\subfigure[]{
\includegraphics[width=\linewidth]{figures/figure 7-a.png}
\label{fig7a}
}
\subfigure[]{
\includegraphics[width=\linewidth]{figures/figure 7-b.png}
\label{fig7b}
}
\caption{Parameter Optimization Fitness Curve}
\label{figure7}
\end{figure}


期刊论文的第一个字母是较大的大写字母,它在基线以下一行下降。这封信被称为“下沉”字母。第一个单词中的其他字母以大写字母呈现。使用 IEEEtran 命令\IEEEPARstart{}{}可以实现此效果