zoukankan      html  css  js  c++  java
  • 将Maple输出的LaTex导出到txt文件

    将Maple输出的LaTex导出到txt文件


    1. 生成LATEX
    Maple可以把它的表达式转换成LATEX, 使用latex命令即可:
    > latex(x^2+y^2=z^2);
    {x}^{2}+{y}^{2}={z}^{2}
        还可以将转换结果存为一个文件(LatexFile):
    > latex(x^2 + y^2 = z^2, LatexFile);

    测试通过:
    interface(prettyprint=0);

    > latex(x^2 + y^2 = z^2, res.txt);

    > with(linalg):
    matrix(2,2,[5,4,6,3]);
    latex(subs(LambertW=lambertW,erf=Erf,arctanh=Artanh,[%]),"C:/Users/Bravo/Desktop/test1.txt");

    > latex(BesselK(nu, z)+BesselJ(nu, z), output = string)
    "{{sl K}_{ u}left(z ight)}+{{sl J}_{ u}left(z ight)}"

    注意: LambertW erf arctanh这几个命令会导致Latex命令报错,需要在使用的时候替换掉



    MyLaTeX := module()
    export ModuleApply, ExprsToLaTeX, CleanLaTeX;
    option package;
        ModuleApply := CleanLaTeX;
        ExprsToLaTeX := proc()
            return cat("", `latex/print`(_passed));
        end proc;
        CleanLaTeX := proc(expr, regsubs :: seq(string=string), $)
            return foldr(StringTools:-RegSubs
                         , ExprsToLaTeX(expr)
                         , ListTools:-Reverse([regsubs])[]
                         , "\\!"            = ""      # remove !
                         , "{([0-9])}"        = "\1 "  # strip braces from single digits
                         , "\\_"            = "_"     # change \_ to _
                         , " \\right\)"    = ")"     # remove ight)
                         , " \\left\( "    = "("     # remove left)
                         , "{\\it ([^}]*)}" = "\1"   # remove italics from variables
                         , "\\,"            = " "     # remove
       , "(([a-zA-Z1-9]+))/(([a-zA-Z1-9]+))" = "\\frac {\1} {\3}"
      # , "::" = "->"
                        );
        end proc;
    end module:


    相关链接:

    Better LaTeX output from Maple? - MaplePrimes http://www.mapleprimes.com/posts/43828-Better-LaTeX-Output-From-Maple 


  • 相关阅读:
    scrapy爬虫框架
    运用GRASP原则来做uml交互类图-------pos机实例
    csv文件读取
    文件编码解读
    smtp模块使用
    csv模块简单使用
    用Beautifulsoup 来爬取贴吧图片
    批处理命令——set
    bat批处理教程之for的/f参数
    docker 下 alpine 镜像设置时区的有效办法
  • 原文地址:https://www.cnblogs.com/enjoy233/p/10408794.html
Copyright © 2011-2022 走看看