LaTeX中算法环境设置
2014-01-26 12:44
651 查看
http://tex.stackexchange.com/questions/82888/algorithmic-arbitrary-names-for-algorithms
activeoldestvotes
algorithmic,
arbitrary names for algorithms
up vote7down votefavorite 1 | The question is advanced version of my previous one. I need to name algorithms (package algorithmic) with arbitrary names so it appears like: [code]Algorithm MyAlgo and \ref{...}will appear like MyAlgo. Next code is (by cmhughes) puts A in front of a number: [code]\documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} \renewcommand{\thealgorithm}{A\arabic{algorithm}} \begin{document} \begin{algorithm} \caption{Euclid’s algorithm} \label{alg:euclid} \begin{algorithmic}[1] \Procedure{Euclid}{$a,b$}\Comment{The g.c.d. of a and b} \State $r\gets a\bmod b$ \While{$r\not=0$}\Comment{We have the answer if r is 0} \State $a\gets b$ \State $b\gets r$ \State $r\gets a\bmod b$ \EndWhile\label{euclidendwhile} \State \textbf{return} $b$\Comment{The gcd is b} \EndProcedure \end{algorithmic} \end{algorithm} Test reference: \ref{alg:euclid} \end{document} But how to do it for arbitrary algorithm name? EDIT: Maybe I was unclear in my question. What I need is assigning to algorithms arbitrary names without numbering, so that \ref{...}will appear as name of the algorithm. cross-referencing algorithms naming
| ||||||||||||||
comment | |||||||||||||||
start a bounty |
1 Answer
activeoldestvotesup vote6down voteaccepted | Is this what you want to achieve?[code]\documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} \newenvironment{varalgorithm}[1] {\algorithm\renewcommand{\thealgorithm}{#1}} {\endalgorithm} \begin{document} \begin{varalgorithm}{Euclid} \caption{Euclid's algorithm} \label{alg:euclid} \begin{algorithmic}[1] \Procedure{Euclid}{$a,b$}\Comment{The g.c.d. of a and b} \State $r\gets a\bmod b$ \While{$r\not=0$}\Comment{We have the answer if r is 0} \State $a\gets b$ \State $b\gets r$ \State $r\gets a\bmod b$ \EndWhile\label{euclidendwhile} \State \textbf{return} $b$\Comment{The gcd is b} \EndProcedure \end{algorithmic} \end{varalgorithm} \begin{varalgorithm}{Ten} \caption{Count to ten}\label{alg:ten} \begin{algorithmic} \State $x \gets 1$ \While{$x < 10$} \State $x \gets x + 1$ \EndWhile \end{algorithmic} \end{varalgorithm} Test reference: \ref{alg:euclid} Test reference: \ref{alg:ten} \end{document}
| ||
add comment |
Your Answer
相关文章推荐
- latex页面设置、改变长度、环境、图表、标题、文献内容
- LaTeX技巧003:enumerate环境设置缩进
- Vim + LaTeX-Suite + Skim的配置以及中文环境设置
- latex中定理定义等数学环境下的字体设置
- Latex 建立带有竖线和编号的算法环境
- linux 环境变量设置方法总结(PATH/LD_LIBRARY_PATH)
- Mac OS上设置Django开发环境
- Sublime text2 C/C++ 编译环境设置
- android studio linux 环境下网络设置
- Eclipse+JBoss+MySQL开发环境设置
- QT开发环境设置 vs2008
- Linux JDK,TOMCAT安装及环境设置(图文解说)
- zabbix3.0在centos7环境下always_populate_raw_post_data的设置
- Linux环境变量的设置和查看方法
- 环境变量设置
- Linux-oracle环境编码设置步骤
- Oracle编程艺术之设置环境
- JAVA虚拟机环境变量设置
- Hadoop集群(第7期)_Eclipse开发环境设置
- 如何设置vs2005的环境变量