I am using ShareLatex. I have an .tex containing some pseudo code using the algorithm2e package. It is as follows:
\documentclass[11pt, a4paper]{article}
\usepackage[portrait, margin=1in]{geometry}
\usepackage{amsmath}
\usepackage[linesnumbered,ruled]{algorithm2e}
\begin{document}
\begin{algorithm}
\SetKwInOut{Input}{Input}
\SetKwInOut{Output}{Output}
\underline{function AlgoTest} $(G)$\;
\Input{bla}
\Output{blubb}
Let $v$ be a vertice $\in V$\;
\ForEach{Vertex $v \in G$}
{
\tcp{doSth}
}
return $G$\;
\caption{blaBlubb}
\end{algorithm}
\end{document}
It compiles fine and looks like what I want. I now have several of such files containing their own algorithms. I now want to include this code into my work/ prosa text and I want it there to exactly look like the one above. Note that the one above has its own commands like usepackage which is good for doing an error free compile of the single code-file (I mean the above one).
So I am doing like in this tex-file:
\documentclass{article}
\usepackage[subpreambles=true]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{import}
\begin{document}
\import{./}{algotest.tex}
\end{document}
When compiling it also looks fine, no problem but theres an compilation error given by ShareLatex:
/usr/local/texlive/2014/texmf-dist/tex/latex/algorithm2e/algorithm2e.sty, line 1177
Undefined control sequence.
The compiler is having trouble understanding a command you have used. Check that the command is spelled correctly. If the command is part of a package, make sure you have included the package in your preamble using \usepackage{...}. Learn more Was this hint helpful?Yes / No
\SetAlgoLined
l.1177 ...etcount,titlenotnumbered,lined,shortend} % The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g.,
\hobx'), type
I' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined.! Undefined control sequence. \SetAlgoShortEnd
Part of the given log output is as follows:
LaTeX Info: Redefining [ on input line 2665. LaTeX Info: Redefining ] on input line 2666. ) (/usr/local/texlive/2014/texmf-dist/tex/latex/algorithm2e/algorithm2e.sty Package: algorithm2e 2013/01/06 v5.00 algorithms environments \c@AlgoLine=\count107 (/usr/local/texlive/2014/texmf-dist/tex/latex/base/ifthen.sty Package: ifthen 2014/09/29 v1.1c Standard LaTeX ifthen package (DPC) ) ! Undefined control sequence. \SetAlgoLined
l.1177 ...etcount,titlenotnumbered,lined,shortend} % The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g.,
\hobx'), type
I' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined.! Undefined control sequence. \SetAlgoShortEnd
l.1177 ...etcount,titlenotnumbered,lined,shortend} % The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g.,
\hobx'), type
I' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined.(/usr/local/texlive/2014/texmf-dist/tex/latex/tools/xspace.sty Package: xspace 2014/10/28 v1.13 Space after command names (DPC,MH) ) (/usr/local/texlive/2014/texmf-dist/tex/latex/relsize/relsize.sty Package: relsize 2013/03/29 ver 4.1 )
Package `algorithm2e' Release 5.0 -- january 06 2013 -- - [email protected] mailing list for announcement about releases - [email protected] mailing list for discussion about package subscribe by emailing [email protected] with 'subscribe ' - Author: Christophe Fiorio ([email protected])
Hopefully theres a way to solve the compilation error. If there is any information missing, just request for it. Thanks in advance.
\input
mechanism which is much more robust. If youralgorithm
environment was in a separate file you could\input
it into the main document and also into a document that just has the one algorithm\import
or any package to do that, you can just use\input