我试图让平纹生成一个非逐字形式的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,用于说明目的):
#' 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()谢谢!
发布于 2016-12-12 01:36:59
我从您的代码库中创建了源文件示例:一个是基于逐字的输出,另一个是使用薄荷包进行语法高亮显示,这样您就可以看到不同之处。唯一的区别仅在于在源代码中的其他包中添加\usepackage{minted}。
使用逐字: test_pweave_verbatim.texw
\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
\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文件:
- pweave -f tex test\_pweave\_verbatim.texw
- pdflatex test\_pweave\_verbatim.tex
- pweave -f texminted test\_pweave\_minted.texw
- pdflatex -shell-escape test\_pweave\_minted.tex
在OSX10.11.4中使用Python2.7.10和Pwee0.25进行测试。
https://stackoverflow.com/questions/41091618
复制相似问题