Math & ScienceTexVar - Simple Algebra System for LuaLaTeX

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

TexVar - Simple Algebra System for LuaLaTeX

Post by Specht08 »

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.

Code: Select all

\documentclass{article}
%
\usepackage{luacode}
\usepackage[fleqn]{amsmath}
% create commands for units (not needed but good practice) 
\newcommand{\msKpW}{\tfrac{m^2K}{W}}
\newcommand{\WpmsK}{\tfrac{W}{m^2K}}
\newcommand{\WpmK}{\tfrac{W}{mK}}
\newcommand{\m}{m}
%
\begin{document}
Calculating the U-Value for an element with two layers and resistance of surface internal and external.\\

\begin{luacode}
	-- load tVar library
	require("tVar/init.lua")

	-- global Definitions
	tVar.outputMode = "RES_EQ_N"
	tVar.numFormat = "%.2f"
	tVar.numeration = true
		
	-- define variables
	tex.print("\\noindent Resistance of surface")
	R_se = tVar:New(0.04,"R_{se}"):setUnit("\\msKpW"):outRES()
	R_si = tVar:New(0.13,"R_{si}"):setUnit("\\msKpW"):outRES()
	
	tex.print("Parameters for elements")
	d_1 = tVar:New(0.2,"d_1"):setUnit("\\m"):outRES()
	lambda_1 = tVar:New(0.035,"\\lambda_1"):setUnit("\\WpmK"):outRES()
	
	d_2 = tVar:New(0.1,"d_2"):setUnit("\\m"):outRES()
	lambda_2 = tVar:New(0.5,"\\lambda_2"):setUnit("\\WpmK"):outRES()
	
	tex.print("Calculate thermal resistance")
	R = (R_se + d_1/lambda_1 + d_2/lambda_2 + R_si):setName("R"):setUnit("\\msKpW"):print():clean()
	
	tex.print("Calculate U-Value")
	U=(1/R):setName("U"):setUnit("\\WpmsK"):print()
\end{luacode}
\end{document}
Attachments
Example 1.pdf
sample output
(51.59 KiB) Downloaded 481 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

TexVar - Simple Algebra System for LuaLaTeX

Post by Johannes_B »

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: 10340
Joined: Mon Mar 10, 2008 9:44 pm

Re: TexVar - Simple Algebra System for LuaLaTeX

Post by Stefan Kottwitz »

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
LaTeX.org admin
Specht08
Posts: 2
Joined: Thu Aug 27, 2015 3:06 pm

TexVar - Simple Algebra System for LuaLaTeX

Post by Specht08 »

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
Post Reply