LaTeX forum ⇒ Math & ScienceTexVar - Simple Algebra System for LuaLaTeX

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Specht08
Posts: 2
Joined: Thu Aug 27, 2015 3:06 pm

TexVar - Simple Algebra System for LuaLaTeX

Postby Specht08 » Thu Aug 27, 2015 3:20 pm

Hi,
For a project at university I needed a tool that automatically generates a documentation of calculations.
But I needed more flexibility than with tools like MathCad.
So I started writing my own tool with Lua and LuaLaTex.

During the project I kept on making the tool more user friendly and implementing more functions.
Now I want to know what other people think about it.

The tool is called TexVar (for LaTex Variable) and is hosted on GitLab:

https://gitlab.com/Specht08/TexVar

You can find a documentation in the download folder.
All commands can also be found in the GitLab wiki (https://gitlab.com/Specht08/TexVar/wikis/home) and in the CheatSheet that is included in the download folder.

Before you download the tool and start testing :) I have a short sample code with the output as pdf for you. The example is also included in the download folder.

I’m looking forward to some new input for my project.

  1. \documentclass{article}
  2. %
  3. \usepackage{luacode}
  4. \usepackage[fleqn]{amsmath}
  5. % create commands for units (not needed but good practice)
  6. \newcommand{\msKpW}{\tfrac{m^2K}{W}}
  7. \newcommand{\WpmsK}{\tfrac{W}{m^2K}}
  8. \newcommand{\WpmK}{\tfrac{W}{mK}}
  9. \newcommand{\m}{m}
  10. %
  11. \begin{document}
  12. Calculating the U-Value for an element with two layers and resistance of surface internal and external.\\
  13.  
  14. \begin{luacode}
  15. -- load tVar library
  16. require("tVar/init.lua")
  17.  
  18. -- global Definitions
  19. tVar.outputMode = "RES_EQ_N"
  20. tVar.numFormat = "%.2f"
  21. tVar.numeration = true
  22.  
  23. -- define variables
  24. tex.print("\\noindent Resistance of surface")
  25. R_se = tVar:New(0.04,"R_{se}"):setUnit("\\msKpW"):outRES()
  26. R_si = tVar:New(0.13,"R_{si}"):setUnit("\\msKpW"):outRES()
  27.  
  28. tex.print("Parameters for elements")
  29. d_1 = tVar:New(0.2,"d_1"):setUnit("\\m"):outRES()
  30. lambda_1 = tVar:New(0.035,"\\lambda_1"):setUnit("\\WpmK"):outRES()
  31.  
  32. d_2 = tVar:New(0.1,"d_2"):setUnit("\\m"):outRES()
  33. lambda_2 = tVar:New(0.5,"\\lambda_2"):setUnit("\\WpmK"):outRES()
  34.  
  35. tex.print("Calculate thermal resistance")
  36. R = (R_se + d_1/lambda_1 + d_2/lambda_2 + R_si):setName("R"):setUnit("\\msKpW"):print():clean()
  37.  
  38. tex.print("Calculate U-Value")
  39. U=(1/R):setName("U"):setUnit("\\WpmsK"):print()
  40. \end{luacode}
  41. \end{document}
Attachments
Example 1.pdf
sample output
(51.59 KiB) Downloaded 284 times

Tags:

User avatar
Johannes_B
Site Moderator
Posts: 4077
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Thu Aug 27, 2015 4:04 pm

Also announced at goLaTeX.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

User avatar
Stefan Kottwitz
Site Admin
Posts: 9501
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Thu Aug 27, 2015 9:37 pm

Thank you for the information!

Sounds very interesting. I like to test it, just these days I'm a bit busy. It would be great if you would keep us updated about developments. I used LuaTeX for calculations but not yet as a computer algebra system (CAS).

Stefan
Site admin

Specht08
Posts: 2
Joined: Thu Aug 27, 2015 3:06 pm

Postby Specht08 » Thu Sep 10, 2015 7:34 am

Just to keep you updated:
I made a lot of improvements since my last post.
You can now find the project on my website http://texvar.projectzoo.at. The examples and tutorials are now in blog form at http://texvar.projectzoo.at/category/texvar/.

The biggest change since my last post is a new input mode where you don't need to write any lua code (but you can if you want). The code you write is translated into lua code that can be processed from lualatex. The new input mode is pretty simple and is described here http://texvar.projectzoo.at/example-4-easyinput/.

kind regards


Return to “Math & Science”

Who is online

Users browsing this forum: MSN [Bot] and 1 guest