I mean: when I put some code in my docs I can include it whitout writing all code in main document.

Is there a similar thing for algorithm?

  • 1
    – user31729
    Feb 17, 2016 at 18:12
  • yeah.. it works.
    – clf maris
    Feb 18, 2016 at 21:02

1 Answer 1


Depending on the kind of result expected, there are two solutions:


Using \input(my_file.tex) allows you to append the content of my_file.tex to your main TeX file. You can nest \input comands inside files you call from your main document.


Using \include(my_file.tex) has the same use but forces a page break and doesn't allow nested \include. However, you can still \input a file inside the document you want to \include.

Note that both commands can be used for any type of LaTeX resource, not only for algorithms. See here for further explanation.

  • I don't think \include should even be mentioned in this context.
    – egreg
    Jan 20, 2020 at 16:39
  • @egreg Why? Is there a detail I'm missing about \include or its behavior?
    – William A.
    Jan 21, 2020 at 8:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.