├── LICENSE.txt ├── LaTeX-Alpha-Demo.pdf ├── README.md ├── calc-example.png ├── cloud.m ├── latexalpha.png ├── latexalpha.sty └── pic.png /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Amiel Kollek 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /LaTeX-Alpha-Demo.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Akollek/LaTeX-Alpha/2b8c692d2b883fdb8aef09fde8ed0f198e2e07f2/LaTeX-Alpha-Demo.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ![latexalpha](https://raw.githubusercontent.com/Akollek/LaTeX-Alpha/master/latexalpha.png) 5 | 6 | ======== 7 | 8 | __LaTeX-Alpha is down until the Wolfram Cloud becomes publicly available! Please check back soon!__ 9 | 10 | LaTeX-Alpha is a LaTeX package which incorporates the typesetting ease and control of LaTeX with the power of the Wolfram Language. The goal of LaTeX-Alpha is to provide the most complete, powerful and self-sufficient typesetting environment. 11 | 12 | __Please see LaTeX-Alpha-Demo.pdf for fuller documentation__ 13 | 14 | ### Use Instructions 15 | 16 | 1. Download `latexalpha.sty` and put it in the same directory as your `.tex` document. 17 | 2. Add `\usepackage{latexalpha}` to your preamble. 18 | 3. Compile your document using `pdflatex --shell-escape your-document.tex` (this step requires that `curl` is installed, `wget` compatibility coming soon) 19 | 4. Enjoy cool documents! 20 | 21 | 22 | __LaTeX-Alpha is a work in progress! For now it will only be available for a few months. Please email me with bugs/suggestions/comments!__ 23 | 24 | 25 | ### Commands 26 | 27 | ###### \calc{} 28 | 29 | This command evaluates a mathematical expression, taking Wolfram Language syntax. For example 30 | 31 | ``` \calc{Exp[I*Pi]} ``` 32 | 33 | will compile to 34 | 35 | ![Neg1](https://raw.githubusercontent.com/Akollek/LaTeX-Alpha/master/calc-example.png) 36 | 37 | ###### \graphic{} 38 | 39 | This command generates a graphic. For example, 40 | 41 | ``` \graphic{Plot[Sin[x],{x,0,2 Pi}]}{sin} ``` 42 | 43 | will generate the following graph and make it available to your LaTeX document in the image file `sin.png`. 44 | 45 | \begin{figure} 46 | \centering 47 | \includegraphics[width=0.8\textwidth]{sin.png} 48 | \caption{Plot of sin(x) generated with the Wolfram API} 49 | \end{figure} 50 | 51 | ![Sin](https://raw.githubusercontent.com/Akollek/LaTeX-Alpha/master/pic.png) 52 | 53 | ###### \WolframAlpha{} and \WolframAlphaMath{} 54 | 55 | Take in a Wolfram Alpha query. For example 56 | 57 | ``` $\WolframAlpha{ what is the biggest city in china }$ ``` 58 | 59 | will compile to Shanghai. 60 | 61 | ###### \dataplotTXT{} 62 | 63 | `\dataplotTXT{}` allows for data which is stored in the same directory as a .tex file to be graphed in the compiled document. 64 | 65 | -------------------------------------------------------------------------------- /calc-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Akollek/LaTeX-Alpha/2b8c692d2b883fdb8aef09fde8ed0f198e2e07f2/calc-example.png -------------------------------------------------------------------------------- /cloud.m: -------------------------------------------------------------------------------- 1 | (* ::Package:: *) 2 | 3 | (*URL for graphics*) 4 | CloudDeploy[ 5 | APIFunction[{x->"String"}, 6 | Needs["ErrorBarPlots`"]; 7 | ExportForm[Rasterize[ToExpression[# x]], "PNG"]&],Permissions->"Public"] 8 | 9 | 10 | (*Improved Wolfram Alpha *) 11 | CloudDeploy[APIFunction[{x->"String"}, 12 | (result=WolframAlpha[ # x,"WolframResult" ]; 13 | If[Length[result]==1,ToExpression["TeXForm"][result[[1]]], 14 | output = ToString[result[[1]]]; 15 | For[i = 2, i <= Length[result], i++, 16 | output = output <> " " <> ToString[result[[i]]]]; 17 | Return[ToExpression["TeXForm"][output]]])&],Permissions->"Public"] 18 | 19 | (*Wolfram Alpha Math*) 20 | CloudDeploy[APIFunction[{x->"String"},ToExpression["TeXForm"][WolframAlpha[ # x,"WolframResult" ]]&],Permissions->"Public"] 21 | 22 | 23 | (*Data Plot*) 24 | CloudDeploy[APIFunction[{"x"->"String","list"->"String"},ExportForm[Rasterize[ToExpression[# x][ToExpression[# list]]],"PNG"]&],Permissions->"Public"] 25 | (*Data Plot with Rules*) 26 | CloudDeploy[APIFunction[{"plot"->"String","list"->"String","rules"->"String"}, 27 | (func=ToExpression[# plot]; 28 | data=ToExpression[# list]; 29 | rulesString=StringReplace[# rules,{"("->"{",")"->"}", "'" -> "\""}]; 30 | rules=ToExpression["{"<>rulesString<>"}"]; 31 | ExportForm[Rasterize[func[data, rules ] ],"PNG"])&],Permissions->"Public"] 32 | 33 | 34 | (*Greek Character Support*) 35 | CloudDeploy[APIFunction[{x->"String"}, 36 | (Greek[x_] := Module[{let}, 37 | (let = ToString[x]; 38 | ToExpression["\\"<>"[" <> let <> "]"])]; 39 | ToExpression["TeXForm"][Evaluate[ToExpression[# x]]])&], 40 | Permissions->"Public"] 41 | 42 | 43 | (*for solving equations*) 44 | CloudDeploy[ 45 | APIFunction[{eq->"String",var->"String"},( 46 | Greek[x_] := ToExpression["\\" <> "[" <> ToString[x] <> "]"]; 47 | eq=ToExpression[# eq]; 48 | var=ToExpression[# var]; 49 | print = {"\\begin{flalign*}"}; 50 | rules = Solve[eq, var]; 51 | sol = var /. rules; 52 | For[i = 1, i <= Length[sol], i++, 53 | AppendTo[print, 54 | "&" <> ToString[ToExpression["TeXForm"][var]] <> "=" <> ToString[ToExpression["TeXForm"][sol[[i]]]] <> 55 | "\\\\"] 56 | ]; 57 | AppendTo[print, "\\end{flalign*}"]; 58 | return=""; 59 | For[i = 1, i <= Length[print], i++, 60 | return=return<>print[[i]]]; 61 | ExportForm[return,"Text"])&],Permissions->"Public"] 62 | -------------------------------------------------------------------------------- /latexalpha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Akollek/LaTeX-Alpha/2b8c692d2b883fdb8aef09fde8ed0f198e2e07f2/latexalpha.png -------------------------------------------------------------------------------- /latexalpha.sty: -------------------------------------------------------------------------------- 1 | \NeedsTeXFormat{LaTeX2e}[1994/06/01] 2 | \ProvidesPackage{latexalpha}[2014/03/28 LaTeX-Alpha] 3 | \RequirePackage{graphicx} 4 | \RequirePackage{amsmath} 5 | \RequirePackage{hyperref} 6 | \RequirePackage{ifthen} 7 | 8 | 9 | 10 | %To do - Add option for wget instead of curl 11 | %To do - Add general 3d graphic options 12 | %To do - file upload and import on cloud side, CSV compatability, .m compatability. (POST file. Import on cloud side?) 13 | %To do - initalize could kernel with local .m file to use personally defined functions. More gernally, allow more control over cloud object (DeclareOption initialize=----.m and run it within each command? This might be slow.) 14 | %To do - Set up option to pass Wolfram login info to package and have it run on user's cloud 15 | %To do - Handle uncertainties elegantly (error package completely integrated into LaTeX-Alpha?) 16 | %To do - do data fitting. Non linear, 17 | %To do - some sort of ShowSteps command for assignments. (can I get the show steps info from WolframAlpha?) (Trace?) 18 | %To do - Save previous calculations/graphics so on compile you don't need to curl for a result/graphic that has not changed. 19 | %To do - maybe return solutions to equations as a matrix without brackets so it can be added within math environments. (Will the formatting look bad?) 20 | % To do - !!! Have Wolfram Side errors (bad syntax) be available to users !!! (use trace to find message list?) 21 | % To do - Solve differential equations 22 | % To do - Use subscripts 23 | % To do - texcalc command which takes latex input for simpler calculations (how to deal complex lowercase i's...) - for double backlashes, go to character code, parse for all LaTeX math commands, replace 24 | 25 | \newcommand{\latexalpha}{\href{https://github.com/Akollek/LaTeX-Alpha}{ \textbf{\LaTeX-$\alpha$} }} 26 | 27 | \newcommand{\threeDQuadratic}[1]{ 28 | \href{https://www.wolframcloud.com/app/view/file/52b542b01db84baa8705f6338c449ed2}{#1} 29 | } 30 | 31 | \newcommand{\threeDSphere}[1]{ 32 | \href{https://www.wolframcloud.com/app/view/file/1ab7507480c34bb09c5e73f0b70b2d27}{#1} 33 | } 34 | 35 | \newcommand{\threeDSinusoid}[1]{ 36 | \href{https://www.wolframcloud.com/app/view/file/6314a9dcf1164fd88f49286cae3a8d7c}{#1} 37 | } 38 | 39 | 40 | 41 | \newcommand{\graphic}[2]{ 42 | \immediate\write18{curl "https://www.wolframcloud.com/objects/c6d1dc68-1812-4a20-84da-9c45f68b054b" --data-urlencode "x=#1" > '#2'.png} 43 | } 44 | 45 | 46 | \newcommand{\calc}[1]{ 47 | \immediate\write18{rm -f calc.latexalpha} 48 | \immediate\write18{curl "https://www.wolframcloud.com/objects/a6574816-f940-4975-9c7f-7a1f99099ed4" --data-urlencode "x=#1" > calc.latexalpha} 49 | \input{calc.latexalpha} 50 | \immediate\write18{rm -f calc.latexalpha} 51 | } 52 | 53 | \newcommand{\solve}[2]{ 54 | \immediate\write18{rm -f solve.latexalpha} 55 | \immediate\write18{curl "https://www.wolframcloud.com/objects/a789a339-5784-4823-9dea-cd34d470a08e" --data-urlencode "eq=#1" --data-urlencode "var=#2" > solve.latexalpha} 56 | \input{solve.latexalpha} 57 | \immediate\write18{rm -f solve.latexalpha} 58 | } 59 | 60 | \newcommand{\WolframAlpha}[1]{ 61 | \immediate\write18{rm -f wolfalph.latexalpha} 62 | \immediate\write18{curl "https://www.wolframcloud.com/objects/2d3d3245-0c73-40d2-b91b-29a12142681d" --data-urlencode "x=#1" > wolfalph.latexalpha} 63 | \input{wolfalph.latexalpha} 64 | \immediate\write18{rm -f wolfalph.latexalpha} 65 | } 66 | 67 | \newcommand{\WolframAlphaMath}[1]{ 68 | \immediate\write18{rm -f wolfalphm.latexalpha} 69 | \immediate\write18{curl "https://www.wolframcloud.com/objects/f1bdbc66-04cb-4805-b1a4-19f6ba3ddad6" --data-urlencode "x=#1" > wolfalphm.latexalpha} 70 | \input{wolfalphm.latexalpha} 71 | \immediate\write18{rm -f wolfalphm.latexalpha} 72 | } 73 | 74 | \newcommand{\dataplotTXT}[4]{ 75 | \ifthenelse{\equal{#4}{}}{ 76 | \immediate\write18{List=`cat '#1'` && curl "https://www.wolframcloud.com/objects/5f9af475-d92f-4a89-8273-a661eece50ca" --data-urlencode "x=#2" --data-urlencode "list=$List" > '#3'.png}}{ 77 | \immediate\write18{List=`cat '#1'` && curl "https://www.wolframcloud.com/objects/af778756-3e2e-4a27-af3f-24113ef0cd1e" --data-urlencode "plot=#2" --data-urlencode "list=$List" --data-urlencode "rules=#4" > '#3'.png} 78 | } 79 | } 80 | 81 | 82 | 83 | \endinput 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /pic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Akollek/LaTeX-Alpha/2b8c692d2b883fdb8aef09fde8ed0f198e2e07f2/pic.png --------------------------------------------------------------------------------