GeneralInsert and run C++, Java, Python, PHP Code in LaTeX

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
kornaros
Posts: 40
Joined: Wed Nov 30, 2011 12:11 am

Insert and run C++, Java, Python, PHP Code in LaTeX

Post by kornaros »

As I know Lua(LaTeX) could have some parts of a Lua script between \begin and \end{document}. Is it possible to insert C++ (or Java or Python or PHP or Mathematica or etc... ) code in LaTeX? (I am newbie so please answer me by a simple example, if this is possible)


Thanks
Charis.

Recommended reading 2024:

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

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

Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

Insert and run C++, Java, Python, PHP Code in LaTeX

Post by Stefan Kottwitz »

Hi Charis,

with LuaTeX you can load extension modules written in C (for example). The lualatex-platform is such a module. It does not much, just querying system fonts, but could serve as an example.

Stefan
LaTeX.org admin
Montag
Posts: 340
Joined: Wed Jul 15, 2009 9:25 am

Insert and run C++, Java, Python, PHP Code in LaTeX

Post by Montag »

Maybe it is the package listings you are looking for?
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1
User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

Insert and run C++, Java, Python, PHP Code in LaTeX

Post by Stefan Kottwitz »

Hi Charis,

just for clarifying, the recommended listings package is for displaying source code, it offers many features such as language specific syntax highlighting. So it also may answer your question about inserting code.

I just guessed you would like to execute code as well.

Stefan
LaTeX.org admin
Post Reply