Currently python
environment provided by pythonhighlight
package is defined as
\lstnewenvironment{python}[1][]{\lstset{style=mypython}}{}
which seems buggy: this environment takes one optional argument but never used it. Note the style mypython
contains frame=trbl
, which is the cause of frame around code.
I believe the expected definition should be
\lstnewenvironment{python}[1][]{\lstset{style=mypython,#1}}{}
A straight solution is to redefine lst
-environment python
, but it's actually harder because listings
provides no way to do env redefinition. Thus the easier option is to define a new lst
-environment similarly, with a new name:
\lstnewenvironment{pythonx.y.z}[1][]{\lstset{style=mypython,#1}}{} % just for example
\begin{pythonx.y.z}[frame=none]
<python code>
\end{pythonx.y.z}
Here is an example showing an attempt to provide \lstrenewenvironment
then redefine python
environment:
\documentclass{article}
%some packages are loaded
\usepackage{pythonhighlight} %package to highlight the Python syntax
\makeatletter
\lst@UserCommand\lstrenewenvironment#1#2#{%
\@ifundefined{#1}%
{\PackageError{Listings}{Environment `#1' undefined}\@eha
\@gobbletwo}\relax
\expandafter\let\csname#1\endcsname\relax
\expandafter\let\csname#1@\endcsname\relax
\expandafter\let\csname end#1\endcsname\relax
\let\lst@arg\@empty
\lst@XConvert{#1}\@nil
\expandafter\lstnewenvironment@\lst@arg{#1}{#2}}
\lstrenewenvironment{python}[1][]{\lstset{style=mypython,#1}}{}
\makeatother
\begin{document}
\section{Python code}
\begin{python}[frame=none]
# Importing standard Qiskit libraries and configuring account
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit import execute, Aer, IBMQ
\end{python}
\end{document}