我使用的是LyX+TeXLive。
LyX界面直观,类似于Word。可以把精力更多集中在内容,而不是在代码上。
TeXLive库齐全。
安装
安装TeXLiveIndex of /tex-archive/systems/texlive/Imagesmirror.las.iastate.edutexlive-0410.iso (~3.3G)
双击打开iso,加载到虚拟光驱。运行install-tl-advanced.bat,按提示安装。
2. 安装LyX
/Download
安装Installer,即LyX-2352-Installer-4.exe (~58 MB)
latex.exe选择TexLive latex.exe所在文件夹
3. 配置中文环境
运行LyX,文档→首选项
文档类:Chinese Article (CTex)语言:中文(繁体),文件编码:Unicode(XeTeX)(utf8)Formats 输出格式 PDF(XeTeX)
LyX自带拼写检查:工具→首选项→语言设置,拼写检查器,勾选spellcheck continuously。切换拼写检查默认语言:文档→首选项→语言 。拼写检查扩充词库
/Windows/SpellChecker
4. Enjoy
Note
1. TeXLive必要宏包
documentclass{article}
usepackage{ctex}
usepackage[namelimits]{amsmath}
usepackage{amssymb}
usepackage{amsfonts}
usepackage{mathrsfs}
usepackage{algpseudocode,algorithm,algorithmicx}
2. 论文模板
TeXLive自带大量宏包,比如prl的RevTeX,直接调用即可,但仍推荐去官网下载完整版,可参考其模板改写。编译格式为pdfLaTeX,需要将LyX文件导出为tex(pdfLaTeX)格式
/revtex
3. 数学符号
数学公式用$ $括住
常用数学符号:
<=leq 或 le>=geq 或 ge<<ll>>gg≠neq 或者 ne∈in不属于notin×times±pm/info/symbols/symbols.htm/gsww404/article/details/78684278
4. 算法模板
使用algorithmicx宏包生成伪代码算法图
完整教程:
/macros/latex/contrib/algorithmicx/algorithmicx.pdf
4.1 第一例
在TeXworks中使用pdfLaTeX或XeLaTeX执行编译,编译效果:
documentclass{article}usepackage{algpseudocode,algorithm,algorithmicx}
newcommand*DNA{textsc{dna}}
newcommand*Let[2]{State #1 $gets$ #2}
algrenewcommandalgorithmicrequire{textbf{Precondition:}}
algrenewcommandalgorithmicensure{textbf{Postcondition:}}
begin{document}
begin{algorithm}
caption{Counting mismatches between two packed DNA{} strings
label{alg:packed-dna-hamming}}
begin{algorithmic}[1]
Require{$x$ and $y$ are packed DNA{} strings of equal length $n$}
Statex
Function{Distance}{$x, y$}
Let{$z$}{$x oplus y$} Comment{$oplus$: bitwise exclusive-or}
Let{$delta$}{$0$}
For{$i gets 1 textrm{ to } n$}
If{$z_i neq 0$}
Let{$delta$}{$delta + 1$}
EndIf
EndFor
State Return{$delta$}
EndFunction
end{algorithmic}
end{algorithm}
end{document}
以上来源自Sam Estep的回答:
/questions/1375/what-is-a-good-package-for-displaying-algorithms
注1:可利用以下代码实现Input/Output
algrenewcommandalgorithmicrequire{textbf{Input:}}
algrenewcommandalgorithmicensure{textbf{Output:}}
注2:可使用State、Statex实现代码带编号/不带编号换行。
4.2 第二例
在TeXworks中使用pdfLaTeX或XeLaTeX执行编译,编译效果:
documentclass{article}usepackage{algorithm} % float wrapper for algorithms.
usepackage{algpseudocode} % layout for algorithmicx
usepackage{amsmath} % AMS mathematical facilities for LATEX
% Nice looking for empty set
usepackage{amssymb} % provides an extended symbol collection
letoldemptysetemptyset
letemptysetvarnothing
begin{document}
% algorithm
begin{algorithm}
begin{algorithmic}%[1]
caption{CDS with betweenness centrality} label{algorithm: cds bw}
Require A connected graph $G(V, E)$
State $d gets {v : bw(v)}, v in V$, sort by BW on ascending order
State $V' gets emptyset$, connected dominating sets
ForAll{$v$ : $bw(v), v notin V'$}
If{$bw(v) = 0$ OR $G(V-{v})$ is connected}
State $V' gets V' cup MAX-BW(N(v))$
Else
State $V' gets V' cup {v}$
EndIf
State $V gets V-{v}$
EndFor
end{algorithmic}
end{algorithm}
end{document}
以上来源自论坛
LaTeX Application Notes: Pseudocode (with examples) | | Spark & Shine