I want to draw vertical line by using \SetAlgoLined
, but LaTeX told me Undefined control sequence
.
Then I add \usepackage{algorithm2e}
to the end of my preamble. Then it said Command
\algorithmalready defined
.
\usepackage{graphicx}
\usepackage{xthesis}
\usepackage{xtocinc}
\usepackage{mystyle}
\usepackage{url}
\usepackage{subfigure}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage[printonlyused]{acronym}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{float}
\usepackage{epstopdf}
\usepackage{amssymb,amsmath}
\usepackage{graphicx,epsfig}
\usepackage{multicol}
\usepackage{ifthen}
\usepackage{algorithm2e}
I'm using Window 7 + TexWorks. I have another paper works perfect with algorithm2e
and \SetAlgoLined
:
\usepackage{cite}
\usepackage{url}
\usepackage{ifthen}
\usepackage{multicol}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{graphicx,epsfig}
\usepackage{amssymb,amsmath}
\usepackage{subfigure}
\usepackage{epstopdf}
\usepackage{float}
\usepackage{algorithm2e}
\usepackage{multirow}
Just had no idea why it happened? Please help.
Best Answer
Since the
algorithm
andalgorithm2e
packages both define analgorithm
environment, simply loading both with no extra precaution will cause a name clash like you experienced.However, you can still use both packages (if you really need both), but you need to pass the option
algo2e
toalgorithm
:This option changes the name of the environment
algorithm
from thealgorithm2e
package intoalgorithm2e
and so avoids the conflict with the package which already define analgorithm
environment; the option also changes the command name for the list of algorithms to\listofalgorithmes
.A complete example: