I am using \usepackage{pythonhighlight}
for python code and this creates a box around the code by default. Is there a way to remove the box?
\begin{python}
def f(x):
return x
\end{python}
Doesn't look like pythonhighlight
has made it possible to add additional options to the python
environment.
One option is to define a new listings
type environment, and allow for style adjustments using the optional argument to the new environment, and add frame=none
there. See PythonA
below.
If you want to remove all frames, add frame=none
to the new style, as with PythonB
below.
A third option is to make a new style and use \begin{lstlisting}[style=stylename]
.
\documentclass[border=2mm]{article}
\usepackage{pythonhighlight}
\lstnewenvironment{PythonA}[1][]{\lstset{style=mypython, #1}}{}
\lstnewenvironment{PythonB}[1][]{\lstset{style=mypython, frame=none, #1}}{}
\lstdefinestyle{Py2}{
style=mypython,
frame=none
}
\begin{document}
\begin{PythonA}[frame=none]
def f(x):
return x
\end{PythonA}
\begin{PythonB}
def f(x):
return x
\end{PythonB}
\begin{lstlisting}[style=Py2]
def f(x):
return x
\end{lstlisting}
\end{document}
\documentclass
to\end{document}