TeX - LaTeX Asked by PaulJGD on December 25, 2020
Below is an example {calc} of a short engineering calculation.
I want to insert this as a standard calculation input{calc} in a main document.
Sometimes I want to use this multiple times in the main document with different values (t, s, p, etc.).
I made something myself with luacode and marginnote.
But the marginnote does not do what I want. Because when input{calc} in the main document the "marginparwidth" needs to be adjusted temporarily.
Is there someone who can help me with a solid concept for this short engineering calculation?
Many thanks in advance!
documentclass[12pt,a4paper]{article}
usepackage[fleqn]{amsmath}
usepackage{luacode}
usepackage{tabularx}
usepackage{marginnote}
usepackage[left=1.3cm,right=4.6cm,top=1.8cm,bottom=4.0cm,marginparwidth=3.4cm]{geometry}
usepackage{scrextend}
newenvironment{conditions*}
{parvspace{abovedisplayskip}noindent
tabularx{columnwidth}{>{$}l<{$} @{${}={}$} >{raggedrightarraybackslash}X|}}
{endtabularxparvspace{belowdisplayskip}}
begin{luacode}
t = 3
s = 454
p = 4.51
k = 0.00394
w = 7.04
a = 1.5
end{luacode}
begin{luacode*}
sqrt = math.sqrt
treq = function (t, s, p, k, w, a)
return k *s * sqrt(p / w) + a
end
print = function (d,s)
if d == 0 then
format = "%d"
else
format = "%." .. d .. "f"
end
tex.sprint(string.format(format,s));
end
end{luacode*}
defluaprint#1{directlua{tex.print(#1)}}
newcommand{lp}[2][16]{directlua{print(#1,#2)}}
begin{document}
The plating t is to be not less in thickness than that obtained from the following equation:
begin{equation*}
tag{formule 11.1}
begin{split}
t_{req} & = k times s times sqrt{frac{p}{k}}+{a}
& = luaprint{k} times luaprint{s} times sqrt{frac{luaprint{p}}{luaprint{k}}}+{luaprint{a}}
& = lp[2]{treq(luaprint{t}, luaprint{s}, luaprint{p}, luaprint{k}, luaprint{w}, luaprint{a})}
marginnote{$t=luaprint{w}mathrm{mm}$}
end{split}
end{equation*}
where:
begin{conditions*}
t & marginnote{$t=luaprint{t}mathrm{mm}$}
chosen thickness
t_{req} & required thickness
s & marginnote{$s=luaprint{s}mathrm{mm}$}
spacing of stiffeners
p & marginnote{$p=luaprint{p}mathrm{kN.m^{-2}}$}
minimum deck loading
k & marginnote{$k=luaprint{k}mathrm{}$}
factor
w & marginnote{$w=luaprint{w}mathrm{kN.m^{-2}}$}
reference loading
a & marginnote{$a=luaprint{a}mathrm{}$}
corrosion allowance
end{conditions*}
end{document}
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP