Lua 宏用于检查大于的值

Lua 宏用于检查大于的值

有没有办法让 lua 宏 checka 和 checkb 具有更通用的格式?输入值、名称和数字:value1、value2、name1、name2、dig1、dig2

Lua 宏用于检查大于的值

\documentclass[12pt]{article}

\usepackage{bbding}                 % check marks
\usepackage{tikz}                   % check marks
\usepackage{luacode}                % for calculations
\usepackage{amssymb}                % for calculations

\newcommand{\cmark}{\checkmark}     % PASSED from bbding
\newcommand{\xmark}{\XSolidBrush}   % FAILED from bbding
 
\begin{luacode*}
    function checka (value1, value2) 
        local UC = value1/value2
        if UC < 1 then
            format1 = "%1.2f < %1.2f\\hspace{5pt};\\textbf{\\textcolor{blue}{PASSED}}"
        else
            format1 = "%1.2f > %1.2f\\hspace{5pt};\\textbf{\\textcolor{red}{FAILED}}"
        end
        tex.sprint(string.format(format1, value1, value2))
    end

    function checkb (value1, value2) 
        local UC = value1/value2
        if UC < 1 then
            format2 = "t_{req} < t\\hspace{5pt}\\textbf{\\textcolor{blue}{\\cmark}}"
        else
            format2 = "t_{req} < t\\hspace{5pt}\\textbf{\\textcolor{red}{\\xmark}}"
        end
        tex.sprint(string.format(format2, value1, value2))
    end

\end{luacode*}

\begin{document}

\def\t{3}
\def\treq{1.5}

Format1: $\luadirect{tex.print(checka(\treq,\t ))}$ \\

Format2: $\luadirect{tex.print(checkb(\treq,\t ))}$

\end{document}

相关内容