8000 Obtaining the output of an expression when usefamily=jl · Issue #51 · gpoore/pythontex · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Obtaining the output of an expression when usefamily=jl #51

8000
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dmbates opened this issue Nov 11, 2014 · 7 comments
Closed

Obtaining the output of an expression when usefamily=jl #51

dmbates opened this issue Nov 11, 2014 · 7 comments

Comments

@dmbates
Copy link
dmbates commented Nov 11, 2014

I am using PythonTeX to create a document with Julia code. I would like to include the value of the expression as well as the expression itself. A jlblock environment evaluates the expression and prints the expression but not the value. I don't see any Julia equivalent of the pycon family.

Can anyone tell me how to accomplish this?

@gpoore
Copy link
Owner
gpoore commented Nov 11, 2014

Currently, only Python has console emulation. It is still possible to show Julia code with its output; it just won't look like a console.

With the jlblock, you can get the output of the code by using \printpythontex or \stdoutpythontex after the block. For example,

\documentclass{article}

\usepackage[usefamily=jl]{pythontex}

\begin{document}

\begin{jlblock}
a = 1
b = 2
println("\$a + b = ", a+b, "\$")
\end{jlblock}
\printpythontex

\end{document}

will give

screen

If you want the output verbatim, then just use \printpythontex[verbatim].

@dmbates
Copy link
Author
dmbates commented Nov 12, 2014

Thanks for the reply. That's more-or-less what I had expected.

I'll check on the Julia lists to see if there is a way of resetting the REPL to provide auto-printing of results as in the interactive REPL. Then all I need to do is to include the \printpythonptex macro calls when I want the output to be included.

Uh oh!

There was an error while loading. Please reload this page.

@dmbates dmbates closed this as completed Nov 12, 2014
@gpoore
Copy link
Owner
gpoore commented Nov 12, 2014

If you find a way to auto-print things, let me know, and I may be able to add that to the documentation or incorporate it somehow. I don't use Julia much myself at present, so the Julia features are still somewhat basic.

Also, interactive REPL support could be added in the future. I would just need version of the REPL that reads commands a line at a time from a file instead of from user input.

@dmbates
Copy link
Author
dmbates commented Nov 12, 2014

I have a question on the julia-users list about this

https://groups.google.com/forum/#!topic/julia-users/VO0lPBMWxN4

I'm sure it will be possible, I'm just not exactly sure how to do it.

@mlhetland
Copy link

The doctest mechanism of the official documentation package seems to just walk through the lines and use eval, wrapped up in a custom eval_repl function. It may be that a bit of what they do could be avoided if all you need is the output (i.e., not to separate input from output, to check the output, to check exceptions, etc.)?

@gpoore
Copy link
Owner
gpoore commented Jul 24, 2017

@mlhetland The last release added preliminary Julia console support (#98).

@mlhetland
Copy link

Ah, brilliant!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
0