• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

gpoore/pythontex: A LaTeX package that executes Python and other code in LaTeX d ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

gpoore/pythontex

开源软件地址(OpenSource Url):

https://github.com/gpoore/pythontex

开源编程语言(OpenSource Language):

Python 53.5%

开源软件介绍(OpenSource Introduction):

PythonTeX

Execute Python and other code in LaTeX documents, or typeset it with syntax highlighting

PythonTeX executes code in LaTeX documents and allows the output to be included in the original document. It supports Python as well as Bash, JavaScript, Julia, Octave, Perl, R, Raku (Perl 6), Ruby, Rust, and SageMath. PythonTeX also provides syntax highlighting for typeset code in LaTeX documents via the Pygments syntax highlighter.

See pythontex_quickstart.pdf to get started, and pythontex_gallery.pdf for examples of what is possible with PythonTeX. PythonTeX is included in TeX Live and MiKTeX and may be installed via the package manager. See pythontex.pdf for detailed installation instructions if you want to install the current development version, or just use the installation script for TeX Live and MiKTeX.

The depythontex utility creates a copy of a PythonTeX document in which all code has been replaced by its output. This plain LaTeX document is more suitable for journal submission, sharing, or conversion to other document formats. See pythontex_gallery.html and the accompanying conversion script for an example of a PythonTeX document that was converted to HTML via depythontex and Pandoc.

Example

  • LaTeX document doc.tex:

    \documentclass{article}
    
    \usepackage{pythontex}
    
    \newcommand{\pymultiply}[2]{\py{#1*#2}}
    
    \begin{document}
    
    \begin{pycode}
    print("Python says ``Hello!''")
    \end{pycode}
    
    $8 \times 256 = \pymultiply{8}{256}$
    
    \end{document}
  • Compiling under Windows:

    pdflatex -interaction=nonstopmode doc.tex
    pythontex doc.tex
    pdflatex -interaction=nonstopmode doc.tex
    
  • Compiling under other operating systems:

    pdflatex -interaction=nonstopmode doc.tex
    pythontex.py doc.tex
    pdflatex -interaction=nonstopmode doc.tex
    
  • Output:

    Python says “Hello!”
    8 × 256 = 2048
    

Notice that there is a three-step compile process. This is what makes possible commands like \pymultiply that use Python or other languages internally. You may want to configure your LaTeX editor with a shortcut for running pythontex or pythontex.py, or configure your LaTeX build system to run pythontex or pythontex.py.

Citing PythonTeX

If you use PythonTeX in your writing and research, please consider citing it in any resulting publications. The best and most recent paper is in Computational Science & Discovery (doi:10.1088/1749-4699/8/1/014010). You may also cite the paper in the 2013 SciPy proceedings.

License

LPPL for LaTeX code and BSD 3-Clause for Python code.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
LukeSmithxyz/latex-templates: My LaTeX templates, bibliography file, etc.发布时间:2022-07-09
下一篇:
udacity/andfun-kotlin-android-trivia发布时间:2022-07-07
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap