代码改变世界

Tex系列: pgfplots安装

2016-06-15 20:59  GarfieldEr007  阅读(815)  评论(0编辑  收藏  举报

(1)  上网下载最新宏包压缩包

    http://sourceforge.net/projects/pgfplots/files/pgfplots/

(2)解压压缩包,把该包下的tex子目录拷贝至D:\texmf\ 下,全部覆盖即可。

(3)重建TeX文件名数据库,执行DOS命令: texhash --admin

 

用pdflatex编译文档的过程中,可能由于绘图数据过多导致内存使用超出TeX内存大小上限,从而编译失败,解决办法就是指定更大的内存空间,步骤如下:

1. 打开DOS命令窗口

2. 在DOS命令窗口中输入

    initexmf --edit-config-file=pdflatex

3. 在自动打开的编辑器中输入

main_memory=20000000

然后存盘文件, 关掉编辑器.

4. 在DOS命令行, 输入

initexmf --dump=pdflatex

注: 同样的办法也适用于latex.

比如编译下面的文档:

[cpp] view plain copy
 
  1. \documentclass[a4paper]{article}  
  2. \usepackage{pgfplots}  
  3. \usepgfplotslibrary{colormaps}  
  4. \pgfplotsset{compat=newest}  
  5. \usepackage[graphics,tightpage,active]{preview}  
  6. \setlength{\PreviewBorder}{5pt} \PreviewEnvironment{tikzpicture}  
  7. \begin{document}  
  8. \begin{tikzpicture}  
  9. \begin{axis}[title=$120 \times 120$ Smooth Surface, xlabel=$x$, ylabel=$y$]  
  10.   \addplot3[surf,samples=120,shader=interp,domain=0:1] {  
  11.     sin(deg(8*pi*x))* exp(-20*(y-0.5)^2) + exp(-(x-0.5)^2*30-  
  12.     (y-0.25)^2 - (x-0.5)*(y-0.25))  
  13.   };  
  14. \end{axis}  
  15. \end{tikzpicture}  
  16. \end{document}    

如果TeX内存上限太小,就会导致编译失败。按上述设置可编译通过。结果如下:

 

from: http://blog.csdn.net/mathsoperator/article/details/6819561