Skip to content
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

Specifying executable code chunk in LaTeX with 'exec' inside lstlisting environment causes compilation error #905

Open
fkmendes opened this issue Apr 13, 2021 · 2 comments

Comments

@fkmendes
Copy link
Contributor

fkmendes commented Apr 13, 2021

Currently, executable code chunks in LaTeX are specified like this:

\begin{lstlisting}[language=Python, exec]
# some executable Python code
\end{listing}

this cannot be compiled by LaTeX, however. Here's a possible solution:

% start exec
\begin{lstlisting}[language=Python, exec]
# some executable Python code
\end{listing}
% end exec

Having a start and end string makes parsing easy.
Note that % marks commented for LaTeX (so it doesn't cause compilation errors).

@nokome
Copy link
Member

nokome commented Apr 13, 2021

Thanks @fkmendes . How about % begin instead of % start to be consistent with LaTeX? Also we drop the exec as an option, so...

% begin exec
\begin{lstlisting}[language=Python]
# some executable Python code
\end{lstlisting}
% end exec

Right?

@nokome
Copy link
Member

nokome commented Apr 13, 2021

How would we deal with inline CodeExpressions? The current syntax is An evaluated Python expression \lstinline[language=python exec]{pow(2,2)}.. I feel that we should check to see if alternative language specifications e.g. python-exec are valid before looking for alternatives.

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

2 participants