I am trying to use pweave with LaTeX for reproducible research. I am seeing weird behavior trying to display the value of a variable in a code chunk. I hope someone can explain what is happening.
When calling print() within a code chunk, depending on what is to be printed, pweave sometimes produces a verbatim section in the markup file for the code, but not for the output of the code.
The environment is Ubuntu 18.04, python 3.6.8, and python-pweave 0.25-1 from the Ubuntu repositories. (This is the latest version available.)
I have experimented with a number of variations to determine what works and what doesn't. The problem seems to occur, or not, depending on the number of lines or characters that would be printed by the code chunk.
I am using the pweave.weave() function with the noweb format as follows:
pweave.weave( filename, doctype='tex', informat='noweb', output=outfile )
The following code chunk works "correctly".
<<>>=
x = 3.14
print( x )
@
It produces the following in the .tex file:
\begin{verbatim}
x = 3.14
print( x )
\end{verbatim}
\begin{verbatim}
3.14
\end{verbatim}
There are separate verbatim sections for the code chunk and the interpreter output.
On the other hand, this code chunk doesn't work.
<<>>=
x = 3
print( x )
@
It produces the following output:
\begin{verbatim}
x = 3
print( x )
\end{verbatim}
There is no verbatim section for the output of the interpreter.
Another example that works is this.
<<>>=
x = 33
print( x )
print( "Something else" )
@
It produces this output:
\begin{verbatim}
x = 33
print( x )
print( "Something else" )
\end{verbatim}
\begin{verbatim}
33
Something else
\end{verbatim}
Again, there are two separate verbatim sections.
This however does not work.
<<>>=
X = 33
print( x )
@
It produces this output.
\begin{verbatim}
X = 33
print( x )
\end{verbatim}