公式里的冒号: \colon
算法里的一撇: ^\prime
属于: /in
不属于:/notin
latex 打出波浪线一般有两种方式:
1. 数学模式下
$\sim$
2. 文字模式下
\textasciitilde
1.如何使连续的参考文献能够中间用破折号连起来?比如[6,7,8,9]变成[6-9]?
方法:在文档开始前加上下面的语句命令
\newcommand{\upcite}[1]{\textsuperscript{\textsuperscript{\cite{#1}}}}
\usepackage{natbib}
\setcitestyle{numbers,sort&compress}
上标, 压缩参考文献标号,可以进行排序,即无论正文里面的顺序怎样,显示出来都是先后顺序。
伪代码中的for,while一定要记得加{}
这段时间在上算法课,有些作业题目要求写出伪代码。正好这段时间在学习latex,于是就收集整理了下latex描写算法的包。latex下描写算法的包主要有algorithmic, algorithmicx和algorithm2e
algorithmic和algorithmicx
介绍下algorithmic和algorithmicx,这两个包很像,很多命令都是一样的,只是algorithmic的命令都是大写,algorithmicx的命令都是首字母大写,其他小写(EndFor两个大写)。下面是algorithmic的基本命令
\STATE <text>
\IF{<condition>} \STATE{<text>} \ENDIF
\FOR{<condition>} \STATE{<text>} \ENDFOR
\FOR{<condition> \TO <condition> } \STATE{<text>} \ENDFOR
\FORALL{<condition>} \STATE{<text>} \ENDFOR
\WHILE{<condition>} \STATE{<text>} \ENDWHILE
\REPEAT \STATE{<text>} \UNTIL{<condition>}
\LOOP \STATE{<text>} \ENDLOOP
\REQUIRE <text>
\ENSURE <text>
\RETURN <text>
\PRINT <text>
\COMMENT{<text>}
\AND, \OR, \XOR, \NOT, \TO, \TRUE, \FALSE
对比看一下,下面是algorithmicx包的基本命令
\State <text>
\If{<condition>} <text> \EndIf
\If{<condition>} <text> \Else <text> \EndIf
\If{<condition>} <text> \ElsIf{<condition>} <text> \Else <text> \EndIf
\For{<condition>} <text> \EndFor
\ForAll{<condition>} <text> \EndFor
\While{<condition>} <text> \EndWhile
\Repeat <text> \Until{<condition>}
\Loop <text> \EndLoop
\Require <text>
\Ensure <text>
\Function{<name>}{<params>} <body> \EndFunction
\State \Return <text>
\Comment{<text>}
另外,还有3个修改algorithm标签,require标签,ensure标签显示的三个命令:
\floatname{algorithm}{算法}
\renewcommand{\algorithmicrequire}{\textbf{输入:}}
\renewcommand{\algorithmicensure}{\textbf{输出:}}
ctrl+R 替换
本文主要围绕LaTeX展开,介绍了在LaTeX中打出波浪线的方式、使连续参考文献用破折号连接的方法,强调伪代码中for、while要加{}。重点整理了LaTeX描写算法的包,如algorithmic和algorithmicx,还给出了这两个包的基本命令及修改标签显示的命令。
1621

被折叠的 条评论
为什么被折叠?



