LaTeX中算法环境设置
来源:互联网 发布:淘宝卖家公益怎么收费 编辑:程序博客网 时间:2024/06/06 10:51
http://tex.stackexchange.com/questions/82888/algorithmic-arbitrary-names-for-algorithms
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:
Algorithm MyAlgo
and \ref{...}
will appear like MyAlgo
.
Next code is (by cmhughes) puts A in front of a number:
\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
start a bounty
1 Answer
activeoldestvotes
up vote6down vote
Is this what you want to achieve?
\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}
0 0
- LaTeX中算法环境设置
- Latex中设置字体大小
- latex中输入算法
- Latex中设置字体颜色
- LaTeX技巧003:enumerate环境设置缩进
- Latex中如何编辑算法
- latex中定理定义等数学环境下的字体设置
- 在Sublime中配置LaTeX编写环境
- latex中局部使用中文环境
- [转]LaTeX中字体设置总结
- Windows Latex 中日文字体设置例
- Latex 设置字体和名称中文化
- LaTeX中字体设置总结 (1)
- 在latex中画算法流程图
- Latex:算法
- latex 中equation环境中\label的用法
- Latex中如何放两列算法在框架中
- latex调整item距离,数学环境中使用粗斜体
- 用GetAdaptersInfo()获取本机的MAC地址
- Linux提权后获取敏感信息的方法与途径
- 三大报表的关系
- FI/CO模块的一些基本概念
- Tomcat7 采用service.bat 注册window服务
- LaTeX中算法环境设置
- rman中如何制定删除某段时间的归档日志
- 纯php多文件上传
- Binary Tree Maximum Path Sum (LeetCode)
- Ceres solver中几种常用算法介绍
- IOS源码分享
- 新浪微薄像个傻逼一样
- boost::bind函数原理和使用
- linux下创建和删除软、硬链接
\renewcommand{\thealgorithm}{MyAlgo\arabic{algorithm}}
? – Peter GrillNov 15 '12 at 20:24Algorithm A1
insteadAlgorithm 1 A1
. Now I want to give arbitrary names to algorithms. – msh Nov 15 '12 at 20:28