• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

stevengj/LaTeXStrings.jl: convenient input and display of LaTeX equation strings ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

stevengj/LaTeXStrings.jl

开源软件地址:

https://github.com/stevengj/LaTeXStrings.jl

开源编程语言:

Julia 100.0%

开源软件介绍:

Build Status

LaTeXStrings

This is a small package to make it easier to type LaTeX equations in string literals in the Julia language, written by Steven G. Johnson.

With ordinary strings in Julia, to enter a string literal with embedded LaTeX equations you need to manually escape all backslashes and dollar signs: for example, $\alpha^2$ is written \$\\alpha^2\$. Also, even though IJulia is capable of displaying formatted LaTeX equations (via MathJax), an ordinary string will not exploit this. Therefore, the LaTeXStrings package defines:

  • A LaTeXString class (a subtype of String), which works like a string (for indexing, conversion, etcetera), but automatically displays as text/latex in IJulia.

  • L"..." and L"""...""" string macros which allow you to enter LaTeX equations without escaping backslashes and dollar signs (and which add the dollar signs for you if you omit them).

FAQ: Not a LaTeX renderer

LaTeXStrings does not do any rendering — its sole purpose is to make it easier to enter LaTeX-rendered strings without typing a lot of backslash escapes, as well as providing a type to tell display backends to use LaTeX rendering if possible.

Other packages like plotting software, Jupyter notebooks, Pluto, etcetera, are responsible for the LaTeX rendering (if any). For example, they might use MathJax, MathTeXEngine.jl, or other renderers. LaTeXStrings only provides the LaTeX text to these backend, and has no influence on what LaTeX features (if any) are supported.

Usage

After installing LaTeXStrings with Pkg.add("LaTeXStrings") in Julia, run

using LaTeXStrings

to load the package. At this point, you can construct LaTeXString literals with the constructor L"..." (and L"""...""" for multi-line strings); for example L"1 + \alpha^2" or L"an equation: $1 + \alpha^2$". (Note that $ is added automatically around your string, i.e. the string is interpreted as an equation, if you do not include $ yourself.)

If you want to perform string interpolation (inserting the values of other variables into your string), use %$ instead of the plain $ that you would use for interpolation in ordinary Julia strings. For example, if x=3 is a Julia variable, then L"y = %$x" will produce L"y = 3".

You can also use the lower-level constructor latexstring(args...), which works much like string(args...) except that it produces a LaTeXString result and automatically puts $ at the beginning and end of the string if an unescaped $ is not already present. Note that with latexstring(...) you do have to escape $ and \: for example, latexstring("an equation: \$1 + \\alpha^2\$"). Note that you can supply multiple arguments (of any types) to latexstring, which are converted to strings and concatenated as in the string(...) function.

Finally, you can use the lowest-level constructor LaTeXString(s). The only advantage of this is that it does not automatically put $ at the beginning and end of the string. So, if for some reason you want to use text/latex display of ordinary text (with no equations or formatting), you can use this constructor. (Note that IJulia only formats LaTeX equations; other LaTeX text-formatting commands like \emph are ignored.)

Author

This package was written by Steven G. Johnson, and is distributed under the MIT/expat license (see the LICENSE.md file).




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap