Math & ScienceProblem including algorithm file

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
kotoko
Posts: 12
Joined: Sat Jan 09, 2010 8:33 pm

Problem including algorithm file

Post by kotoko »

Hello!

I'm trying to get to grips with writing algorithms.
I've managed to write a file that compiles but want to transform it into a file to be included in another project.

What happens: if I use just one file all goes well if I put the same code in another file and input it I get

Code: Select all

(/usr/local/texlive/2009/texmf-dist/tex/latex/base/omscmr.fd) (./algoritmos.tex


! LaTeX Error: Can be used only in preamble.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.1 \documentclass
                  [a4paper,portuges]{book}
I don't really understand how just changing the place of the code can have that effect.
I attach a version of the code. If you comment and uncomment the input line you'll se what I mean.
Attachments
template_algoritmos.zip
Code example
(2.49 KiB) Downloaded 188 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

Problem including algorithm file

Post by kaiserkarl13 »

Your document attempts to include itself in the source file, and it's getting stuck at the second appearance of \documentclass.

Change the \input line to include the correct file and you should be fine.
Post Reply