Latex Insert Python code

Source: Internet
Author: User

1. Reason: Recently in the use of latex to write undergraduate thesis, in the appendix part of the need to insert Python code, accurately speaking is Ipython code, with the Python Scientific Computing Library Anaconda. Baidu has a lot of solutions, found that there are always some errors, such as improper alphabetic constant, undefined control sequence and so on.

2. Workaround:

  • Https://github.com/olivierverdier/python-latex-highlighting
  • Download the file pythonhighlight.sty and put it in your own. Tex file directory
  • Place the program code source file in the. tex file directory
  • Enter \usepackage{graphicx} \usepackage{pythonhighlight} in the latex introduction area
  • Where the code needs to be inserted
    \inputpython{python_file.py}{start of line} {end Line}

  • This method is higher than the direct output \begin{python}\end{python} success rate
  • But the disadvantage of this method is that there is no Chinese comment

Latex Insert Python code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.