I am trying to perform automated calculations with latex using lualatex. I need to be able to printout calculations like "M = a+b" while maintaining all functionalities and options wihtin the math environment. However, along multiple parts of the document, I need o:
- Declare "a=5" (a = \SI{5}{kilo\newton\metre})
- Declare "b=6" (b = \SI{6}{kilo\newton\metre})
- type "M = a+b"
- Get the automated output M = 5+6 = 11
- Set the unit assigned to the output of the equation ( for example 11 KN . m)
In addition I need to be able to:
- Decide whether a and b are substituted within the equation along with their units or not (for example M = 5 kN . m + 6 kN . m = ...) or just (M = 5 + 6)
- Decide whether the output of the equation is assigned a unit or not
- Set the multiplication symbol to (Asterisk: \ast) or (x: \times) since it is more appropriate to use (Asterisk:\ast) as a symbol for multiplication.
- Maintain the same syntax rules used in the "Math" environment ($......$) when displaying the substituted equation
- I am using siunitx package, need the units to follow its settings.
- Need to be able to set how numbers are displayed using the \num command or math environment commands (\frac{}{}...)
- Using brackets, braces .... and so forth
- setting the variables so that they can be redeined later in the following parts in case the same equation is used multiple times
\documentclass{article}
\usepackage{amsmath}
\usepackage[per-mode=symbol,inter-unit-product = \cdot, exponent-product = \ast, output-product = \ast, group-separator = \text{~}, group-minimum-digits={3}]{
}
\usepackage{luatexbase}
\usepackage{luacode}
\usepackage{lualatex-math}
\usepackage[bidi=basic,layout=lists.tabular]{babel}
\babelprovide[import=en,maparabic,main]{english}
\babelfont[english]{rm}{Times New Roman}
\usepackage{nomencl}
\makenomenclature
\begin{document}
\nomenclature{$a$}{.....}
\nomenclature{$b$}{.....}
\printnomenclature
\begin{gather}
M=a+b
\begin{aligned}
a &=definition + units....
\end{aligned}
\end{gather}
\end{document}
Upon seeing the post Evaluating Mathematical Expressions in Lua I have noticed that it handles solving mathematical equations, however the process of variable declaration is not handled. In addition to Embedding units in the output as well as in the numbers within the equation itself. I am not familiar with lua, so I do not know if there is an easier manner through which equations can be evaluated since I have noticed that too much coding is required for evaluating simple expressions.