Git Product home page Git Product logo

latex-alpha2's Introduction

LaTeX-α2

CTAN Travis

LaTeX-α2 (latexalpha2) is a LaTeX package that can execute Wolfram Language codes and show the corresponding results inside LaTeX documents.

The package is heavily inspired by LaTeX-Alpha. Unfortunately, LaTeX-Alpha has been down for a while. The aim of this package is to replace LaTeX-Alpha, as well as to provide various new features.

The codes can be executed either locally (via locally installed Mathematica) or on the cloud (via Wolfram Cloud) using the WolframScript interpreter. In addition, you can also use Mathics (a free, open-source alternative to Mathematica) for computations.

The package only supports Unix-like system for now. Pull requests are welcome.

Usage

  • First install WolframScript (or Mathics) if you haven't already done so. You can use type wolframscript or type mathics to check if it's properly installed.

  • Download latexalpha2.sty to the same folder as your .tex file:

curl -O https://raw.githubusercontent.com/stevenliuyi/latex-alpha2/master/latexalpha2.sty

To avoid copying the file every time, please see the installation guide below.

  • Add \usepackage{latexalpha2} to the preamble of your document. All the codes will be run locally by default. If you'd like to run on the cloud, use \usepackage[cloud]{latexalpha2} instead. For the Mathics mode, use \usepackage[mathics]{latexalpha2}.

  • LaTeX must be invoked with the -shell-escape flag in order to run WolframScript (or Mathics). For example: pdflatex -shell-escape example.tex.

Please refer to the documentation for more information.

Examples

\wolfram{}

Input:

$\wolfram{Series[Exp[x],{x,0,5}]}$

Output:

\wolframgraphics{}

Input:

\begin{figure} 
    \wolframgraphics[pdf]{Plot3D[Sin[x]Cos[y], {x, -2Pi, 2Pi}, {y, -2Pi, 2Pi}]}{example}
    \includegraphics{example.pdf}
    \caption{Plot of $f(x,y)=\sin(x)\cos(y)$}
    \centering
\end{figure}

Output:

Example Plot

Input:

\begin{figure} 
    \wolframgraphics[pdf]{GeoGraphics[{Red,Thick,GeoPath["DateLine"]},GeoRange->{All, {90, 270}},GeoGridLines->Quantity[15, "AngularDegrees"]]}{example2}
    \includegraphics{example2.pdf}
    \caption{International Date Line}
    \centering
\end{figure}

Output:

Example Plot 2

\wolframalpha{}

Input:

The population of Shanghai is $\wolframalpha{population of Shanghai}$, which is $\wolframalpha{ratio of Shanghai populatioin and NYC population}$ times the population of New York City.

Output:

The population of Shanghai is 2.415×107 people, which is 2.814 times the population of New York City.

Input:

$\wolframalpha{Compton scattering for electron}$

Output:

\wolframdsolve{}

Input:

\wolframdsolve{y'[x]+y[x]==a*Sin[x]}{y[x]}{x}

Output:

\wolframtable{}

Input:

\begin{tabular}{ccc}
    \hline
    \wolframtable{Join[{{x,x^2,x^3}}, Table[{i,i^2,i^3},{i,5}]]}
    \hline
\end{tabular}

Output:

Example Plot 3

Installation

To avoid copying the latexalpha2.sty file for every new project, you could install the package instead. Just put the .sty file in the texmf/tex/latex folder (for TeX Live, it would be /usr/local/texlive/texmf-local/tex/latex by default), and then run sudo texhash to update the package database. For more information, please refer to LaTeX/Installing Extra Packages.

License

This work is distributed under the LaTeX Project Public License (LLPL), version 1.3c.

latex-alpha2's People

Contributors

haimengzhao avatar stevenliuyi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

latex-alpha2's Issues

[Feature Request] Provide package option to run mathics

First of all, thank you for this package. So far, we didn't really have a seamless way to automatically typeset symbolic math code (sagetex was unsatisfactory).

I'd like to propose a solution that might lift the *nix restriction of the package - support the mathics executable as a package option. mathics is a free, open-source lightweight alternative to mathematica that entirely uses Wolfram syntax. Since you just have to add in a package option, this is likely to be a trivial change, but one that can immensely help those who cannot afford mathematica or are on windows. (mathics is fully cross-platform).

Available compile engine

Is this package only work for the pdflatex engine? I try to compile with xelatex engine but it failed.

error with \wolframalpha

system: macOS Big Sur Version 11.5 Beta
LaTeX: MacTeX 2021
Mathematica version: 12.2.0.0

errors:
Missing $ inserted.
Bad math environment delimiter.

--shell-escape applied

How can I generate a LaTeX file with the expanded results?

There are several situations, where you want to generate a final LaTeX file with the expanded results

  • colleague without Mathematica license
  • submission to a journal
  • post-processing
  • archiving

Compare to similar projects:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.