From charlesreid1

(Created page with "A guide to using the Algorithm package from LyX. =Important Note!= It is important for you to note: if you are getting errors when using the algorithm module/package, it may no...")
 
Line 81: Line 81:
=Errors=
=Errors=


When I first  
When I first used the algorithm package, I saw a list of errors that looked like this:


<pre>
<pre>
Line 201: Line 201:
                      
                      
*** (job aborted, no legal \end found)
*** (job aborted, no legal \end found)
</pre>
This was caused by the fact that I was opening algorithm statements with keywords like "if" and "while" without properly closing those loops with their corresponding keywords ("endif" or "endwhile"). Algorithm is picky about this, and it doesn't explain the problem clearly when you do it wrong.
Try entering the following algorithm test text, which uses the proper Algorithm format, to ensure you are properly testing your Algorithm package install:
<pre>
repeat {first comment}
  if something true {second comment}
    * action 1 {third comment}
  else
    * last possible action
  endif
until it is still true {the big loop condition}
</pre>
</pre>

Revision as of 16:20, 27 June 2013

A guide to using the Algorithm package from LyX.

Important Note!

It is important for you to note: if you are getting errors when using the algorithm module/package, it may not be a problem with the installation of the package - it may be a problem with how you're using it! The algorithm package is particularly picky about matching statements like "if" with "else" and "endif" - if you open an "if" and don't close with an "endif", algorithm WILL throw errors, and they will NOT clearly state that the problem is with "if" not being closed with an "endif".

See the #Errors section below for details.

Using Algorithm Package from LyX on Mac (Mountain Lion)

Step 1: Get It

Download the algo for LyX package from here: http://bgu.perso.libertysurf.fr/

It is a zip file containing the following files:

Readme.txt
algo.lyx
algo.ps
algo.tex
algolyx.sty
algorithm.inc
article-algo.layout
examples
lang
readme.lyx

Step 2: Copy necessary files

You'll need to copy the layout and inc files to LyX's layouts directory:

$ cp article-algo.layout ~/Library/Application\ Support/LyX-2.0/layouts/.

 $ cp algorithm.inc ~/Library/Application\ Support/LyX-2.0/layouts/.

and put the algorithm style file where LaTeX

$ cp algolyx.sty ~/Library/texmf/tex/latex/.

Step 3: Reconfigure LyX

The last step is to reconfigure LyX. Once you do this,

Using the Algorithm Package from Arbitrary LaTeX Classes

If you follow the instructions above (from the website http://bgu.perso.libertysurf.fr/), you'll see that the only way you can use the Algorithm package is by using the "Article (algo)" class that is provided. This is a problem if, say, you are using a custom class, for your thesis or for a technical report.

This is easy to fix - simply add the following line to your LyX .layout file:

# Use LyX algorithm definitions
Input algorithm.inc

(Note that the layout file is a LyX wrapper for a LaTeX class file; see LyX#Layouts_vs._Classes for details.)

Using the Algorithm Package from LyX

To use the algorithm package, start by inserting an algorithm float, via Insert > Float > Algorithm:

AlgoFloat.png

Next, to put algorithm-style text into the algorithm float, change the text layout style (using the upper-left-hand drop-down menu) to "Algorithm":

AlgorithmLayout.png

Finally, enter some test text:

AlgorithmTestLyx.png

which should result in the following algorithm in your PDF file:

AlgorithmTestPdf.png

Errors

When I first used the algorithm package, I saw a list of errors that looked like this:

! LaTeX Error: \begin{ALC@g} on input line 87 ended by \end{algorithmic}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.118 
      
Your command was ignored.
Type  I <command> <return>  to replace it with another command,
or  <return>  to continue without it.


! LaTeX Error: \begin{ALC@rpt} on input line 87 ended by \end{algor}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.118 
      
Your command was ignored.
Type  I <command> <return>  to replace it with another command,
or  <return>  to continue without it.

! Extra }, or forgotten \endgroup.
\@endfloatbox ...pagefalse \outer@nobreak \egroup 
                                                  \color@endbox 
l.118 
      
I've deleted a group-closing symbol because it seems to be
spurious, as in `$x}$'. But perhaps the } is legitimate and
you forgot something else, as in `\hbox{$x}'. In such cases
the way to recover is to insert both the forgotten and the
deleted material, e.g., by typing `I$}'.

! Extra }, or forgotten \endgroup.
\color@endbox ->\color@endgroup \egroup 
                                        
l.118 
      
I've deleted a group-closing symbol because it seems to be
spurious, as in `$x}$'. But perhaps the } is legitimate and
you forgot something else, as in `\hbox{$x}'. In such cases
the way to recover is to insert both the forgotten and the
deleted material, e.g., by typing `I$}'.


! LaTeX Error: \begin{algorithmic} on input line 86 ended by \end{algorithm}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.118 
      
Your command was ignored.
Type  I <command> <return>  to replace it with another command,
or  <return>  to continue without it.


! LaTeX Error: Not in outer par mode.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.121 \begin
            {algor}
You've lost some text.  Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.


! LaTeX Error: \begin{algor} on input line 85 ended by \end{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.333 \end{document}
                    
Your command was ignored.
Type  I <command> <return>  to replace it with another command,
or  <return>  to continue without it.

(./siluria_algo.aux)

LaTeX Warning: There were undefined references.

! You can't use `\end' in internal vertical mode.
\enddocument ... \endgroup \deadcycles \z@ \@@end 
                                                  
l.333 \end{document}
                    
Sorry, but I'm not programmed to handle this case;
I'll just pretend that you didn't ask for it.
If you're in the wrong mode, you might be able to
return to the right one by typing `I}' or `I$' or `I\par'.


! LaTeX Error: \begin{algor} on input line 85 ended by \end{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.333 \end{document}
                    
Your command was ignored.
Type  I <command> <return>  to replace it with another command,
or  <return>  to continue without it.

)
! Emergency stop.
<*> siluria_algo.tex
                    
*** (job aborted, no legal \end found)

This was caused by the fact that I was opening algorithm statements with keywords like "if" and "while" without properly closing those loops with their corresponding keywords ("endif" or "endwhile"). Algorithm is picky about this, and it doesn't explain the problem clearly when you do it wrong.

Try entering the following algorithm test text, which uses the proper Algorithm format, to ensure you are properly testing your Algorithm package install:

repeat {first comment}
  if something true {second comment}
    * action 1 {third comment} 
  else
    * last possible action
  endif
until it is still true {the big loop condition}