Python模块,方便从Python脚本输入到LaTex中

python-to-latex的Python项目详细描述


Python到乳胶

这个模块提供了几种将数据从Python解析到LaTeX的方法。在

作者:

  • 索尼娅·斯图德利

安装

pip install --upgrade python_to_latex

使用示例:

下面是一些如何使用提供的函数的小例子。每个功能的详细说明可以通过使用

  import python_to_latex as p2l
  help(p2l.<function_name>)

打印矩阵:

^{pr2}$

这将打印下面的代码块并返回字符串以生成它。在

\begin{bmatrix}
     1 &   0\\ 
     0 &   1\\\end{bmatrix}

打印表输出:

importpython_to_latexasp2lnumeric_list_to_tabularx([[1,2,3],[4,5,6]],heading=['A','B','c'])
The above code will print the code block below and return the string to produce it.
\begin{tabularx}{\linewidth}{S[table-auto-round,table-omit-exponent,fixed-exponent=0]S[table-auto-round,table-omit-exponent,fixed-exponent=0]S[table-auto-round,table-omit-exponent,fixed-exponent=0]}\toprule{A}&{B}&{C}\\\midrule
      1 & 2 & 3\\
      4 & 5 & 6\\\bottomrule\end{tabularx}

保存matplotlib图形:

importpython_to_latexasp2limportnumpyasnpimportmatplotlibimportmatplotlib.pyplotaspltx=np.arange(15)y1=2*xy2=x+5y3=xfig1,plt1=plt.subplots(nrows=1,ncols=2)plt1[0].plot(x,y1)plt1[0].plot(x,y2,'.',label="line a")plt1[1].plot(x,y3,label="line 1")plt1[0].set_ylabel('$\lambda_2$')plt1[1].set_xlabel('$b$')plt1[1].set_ylabel('$\lambda_N$')plt1[1].set_xlabel('$N$')plt1[0].legend(loc=1)plt1[0].set_label("test")fig1.show()fig2pgf(fig1,"test",retain_color=True,retain_linestyle=True)

上面的代码生成一个simgle matplotlib图形,然后将该图形以PGF格式保存在一个名为测试.tikz. 保存的文件可以在LaTex中加载。在

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Jsonify使用Jackson来定义嵌套对象   在Swing中禁用java图形调试   java Selenium Webdriver拖放在Jenkins上不起作用   java我对一个显示器的问题有一个非常不切实际的询问   java增强的“for”循环导致ArrayIndexOutOfBoundsException   ArrayAdapter适用于Java中的安卓编程,字符串数组   linux在Ubuntu上通过PulseAudio播放Java音频文件时出错   java在Spring应用程序中加载内部(类路径)和外部属性文件   java使用Maven连接到mySQL   Java应用程序的设计   websocket在电报api java中与dc的连接   java XMLStreamException,因为xml中的(&N)   java从控制台输出到JTextArea   Java导出文本文件   java实现parseInt方法   java为什么servlet容器会同步对特定资源/servlet的多个请求的访问?   循环中的Java“while”变量   用Java编程一个国际象棋游戏,gameOver布尔不起作用   java如何获得真正的JPanel大小?