首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场

到LaTeX
EN

Stack Overflow用户
提问于 2016-12-11 22:00:42
回答 1查看 1.4K关注 0票数 1

我试图让平纹生成一个非逐字形式的LaTeX文件,这样我就可以向文档中添加一些特性(徽标、脚注等)。

虽然我爱平纹是为了方便使用,但我一直无法做到这一点。

Python3.5.2 (v3.5.2:4def2a2901a5,2016年6月26日,10:47:25) GCC 4.2.1 (苹果公司构建5666) (点3)在达尔文pweave.version上是'0.25‘

有人想要线索吗?

代码示例(均为Pweave,用于说明目的):

代码语言:javascript
运行
复制
#' let's print
[print (i) for i in range(10)]

#' let's plot
#' we import the modules
import matplotlib.pyplot as plt
import numpy as np

#' we set the var x and y
x = np.arange(1,10,1)
y = x**2

#' we plot!
plt.plot(x,y, color= 'red')
plt.show()

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-12-12 01:36:59

我从您的代码库中创建了源文件示例:一个是基于逐字的输出,另一个是使用薄荷包进行语法高亮显示,这样您就可以看到不同之处。唯一的区别仅在于在源代码中的其他包中添加\usepackage{minted}。

使用逐字: test_pweave_verbatim.texw

代码语言:javascript
运行
复制
\documentclass[a4paper,11pt,final]{article}
\usepackage{fancyvrb, color, graphicx, hyperref, amsmath, url}
\usepackage{palatino}
\usepackage[a4paper,text={16.5cm,25.2cm},centering]{geometry}

\hypersetup
{   pdfauthor = {Name Surname},
  pdftitle={Simple test with Python and Matplotlib},
  colorlinks=TRUE,
  linkcolor=black,
  citecolor=blue,
  urlcolor=blue
}

\setlength{\parindent}{0pt}
\setlength{\parskip}{1.2ex}



\title{Simple test with Python and Matplotlib}
\author{Name Surname}
\date{12nd December 2016}

\begin{document}
\maketitle

\section{Introduction}

Just a simple example!


Plot stuff.

<<caption="Test!">>=
#' let's print
[print (i) for i in range(10)]

#' let's plot
#' we import the modules
import matplotlib.pyplot as plt
import numpy as np
#' we set the var x and y
x = np.arange(1,10,1)
y = x**2

#' we plot!
plt.plot(x,y, color= 'red')
plt.show()
@

\section{End}

A simple end.

\end{document}

使用薄荷用于语法高亮显示: test_pweave_minted.texw

代码语言:javascript
运行
复制
\documentclass[a4paper,11pt,final]{article}
\usepackage{fancyvrb, color, graphicx, hyperref, amsmath, url}
\usepackage{minted}
\usepackage{palatino}
\usepackage[a4paper,text={16.5cm,25.2cm},centering]{geometry}

\hypersetup
{   pdfauthor = {Name Surname},
  pdftitle={Simple test with Python and Matplotlib},
  colorlinks=TRUE,
  linkcolor=black,
  citecolor=blue,
  urlcolor=blue
}

\setlength{\parindent}{0pt}
\setlength{\parskip}{1.2ex}



\title{Simple test with Python and Matplotlib}
\author{Name Surname}
\date{12nd December 2016}

\begin{document}
\maketitle

\section{Introduction}

Just a simple example!


Plot stuff.

<<caption="Test!">>=
#' let's print
[print (i) for i in range(10)]

#' let's plot
#' we import the modules
import matplotlib.pyplot as plt
import numpy as np
#' we set the var x and y
x = np.arange(1,10,1)
y = x**2

#' we plot!
plt.plot(x,y, color= 'red')
plt.show()
@

\section{End}

A simple end.

\end{document}

现在,使用以下命令生成pdf文件:

  1. 逐字
代码语言:javascript
运行
复制
- pweave -f tex test\_pweave\_verbatim.texw
- pdflatex test\_pweave\_verbatim.tex

  1. 薄荷
代码语言:javascript
运行
复制
- pweave -f texminted test\_pweave\_minted.texw
- pdflatex -shell-escape test\_pweave\_minted.tex

在OSX10.11.4中使用Python2.7.10和Pwee0.25进行测试。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41091618

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档