3

Can I use style pygmentize with Pygments at PythonTeX. Let MWE like this :

\documentclass{article}
\usepackage{pythontex}
\begin{document}
\begin{pygments}[style= murphy]{python} % murpyhy is style from pygmentize
#!/usr/bin/env python
import Tkinter as tk
class Application(tk.Frame):
def __init__(self, master=None):
tk.Frame.__init__(self, master)
self.grid()
self.createWidgets()
def createWidgets(self):
self.quitButton = tk.Button(self, text='Quit',
command=self.quit)
self.quitButton.grid()
app = Application()
app.master.title('Sample application')
app.mainloop()
\end{pygments} 
\end{document}

And I will get style Pygmentize like this :

\documentclass{article}
\usepackage{minted}
\usemintedstyle{murphy}
\begin{document}
\begin{minted}[mathescape]{python}
#!/usr/bin/env python
import Tkinter as tk
class Application(tk.Frame):
def __init__(self, master=None):
tk.Frame.__init__(self, master)
self.grid()
self.createWidgets()
def createWidgets(self):
self.quitButton = tk.Button(self, text='Quit',
command=self.quit)
self.quitButton.grid()
app = Application()
app.master.title('Sample application')
app.mainloop()
\end{minted}
\end{document}

The result above it, use minted package but i need use pythontex package because simple with my document and the screenshoot the result :

minted style

Any solution to solve it ?

4

I don't know if the style can be changed mid document, but this works:

\documentclass{article}
\usepackage[pygopt={style=murphy}]{pythontex}
\begin{document}

\begin{pygments}{python}
#!/usr/bin/env python
import Tkinter as tk
class Application(tk.Frame):
def __init__(self, master=None):
tk.Frame.__init__(self, master)
self.grid()
self.createWidgets()
def createWidgets(self):
self.quitButton = tk.Button(self, text='Quit',
command=self.quit)
self.quitButton.grid()
app = Application()
app.master.title('Sample application')
app.mainloop()
\end{pygments}
\end{document}

enter image description here

  • What is pygopt ? Where can i found more documentation about pygments style at pythontex like listing package ? Such as : line color, background color, line number ,etc – Hirwanto Dec 18 '14 at 14:31
  • @Hirwanto I found it in the documentation of PythonTeX. – egreg Dec 18 '14 at 14:32
  • ouwh, ok , sorry , i have old documentation pythontex, thank for your information. – Hirwanto Dec 18 '14 at 14:39
  • I tried to compile your code but got as a result ??PythonTex?? - I installed python-pygments. Do I need anything else? – Adam Nov 6 '15 at 9:36
  • @adam Did you do pdflatex pythontex pdflatex? – egreg Nov 6 '15 at 9:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.