I want to make a function which take 4 arguments (#1 to #4) and return the size of :
- the size of the longest string between #1 and #2
plus
- the size of the longest string between #3 and #4
For example if I do:
Code: Select all
\myFunction{a}{bc}{def}{g}
I found how to make a function to find the max between to arguments:
Code: Select all
\usepackage{ifthen}
\usepackage{xstring}
\newcommand{\maxL}[2]{
\StrLen{#1}[\lun]
\StrLen{#2}[\ldeux]
\ifthenelse{\lun > \ldeux}{\lun}{\ldeux}
}
Code: Select all
\maxL{#1}{#2}
\maxL{#3}{#4}
\maxL{a}{bc} + \maxL{def}{g}
it will return "2 + 3" instead of the expected 5.I tried without success to use
\setcounter
to convert the values. The following code give me "ERROR: Missing number, treated as zero":
Code: Select all
\newcounter{result}
\newcommand{\test}[2]{\setcounter{result}{\maxL{#1}{#2}}}
...
\test{a}{bc}