0

I am trying to present my Python script in latex. I have tried using the pyverbatim environment and the \inputpygments package but neither works, with both yielding the error message "Package PythonTeX Warning: Non-existent Pygments content on input line xx". The compiled document simply typsets ?? PythonTeX ??

\documentclass[letterpaper,11pt]{article}
\usepackage{pythontex}

\begin{document} \begin{pyverbatim} print(“Hello, World!”) \end{pyverbatim} \end{document}

Or try using:

\inputpygments{python}{python.py}

where the file python.py has been uploaded to the project folder in latex.

compiled doc error log

I have also tried including additional packages such as \usepackage[utf8]{inputenc} and \usepackage[T1]{fontenc} that I noticed others used answering other questions about typesetting one's Python script in Latex, but to no avail.

NBur
  • 4,326
  • 10
  • 27
R_Dax
  • 101
  • 1
    do you have pygments installed? – David Carlisle Feb 26 '21 at 13:09
  • Do you run python3 /usr/local/texlive/2020/texmf-dist/scripts/pythontex/pythontex3.py --rerun=always <your file>.tex (depending on your installation, of course) between two pdflatex (or other engine)? Your mwe ouputs correct result here. – NBur Feb 26 '21 at 13:11
  • @NBur I am sorry, I did not fully understand your question. I am not sure what that is that you are asking whether I run or not. I am using the pdf in Overleaf, I am not sure how exactly it compiles the document. – R_Dax Feb 26 '21 at 13:32
  • @DavidCarlisle I did not install pygments separately :s I am working in Overleaf; I have only ever added in packages with \usepackage, not via separate installation. – R_Dax Feb 26 '21 at 13:34
  • I have now managed to print the code in my latex document using the Minted package in Overleaf; I just found out about this now. Should I edit this into the question or close the question? I still have not managed to do it using pygments or pyverbatim as I was originally asking though. – R_Dax Feb 26 '21 at 13:45
  • 1
    I meant the python program not a latex package. but it is on overleaf as you saw. I do not know if overleaf supports pythontex at all though? – David Carlisle Feb 26 '21 at 13:50
  • @DavidCarlisle you are right, it seems that Overleaf does not support pythontex. I will proceed with the minted package. Thanks for your input – R_Dax Feb 26 '21 at 15:25
  • Pythontex use an external python script. As you work on overleaf, I don't know how to proceed (if possible). – NBur Feb 26 '21 at 15:52

0 Answers0