I am trying to adapt this example How to iterate over a comma separated list? as my base. Except, rather than display all values, I actually want to iterate through all the values and only return / display the largest one.
The list of numbers I actually want to pass to a custom function will actually be glossaries labels. I have tested it and I can insert \gls{label} into a command like
\clist_map_inline:nn { #1 } {\glsentryname{##1} } This works right away to display a list of my expanded values (which are actually numbers) so I am not worried about this part.
I haven't been able to figure out yet:
How can I stop this function from typsetting the text, but rather allow me to iterate through the list update a variable only displaying the final value?
- For example at the start of the loop I would set a dummy value such as -100000
- and the comparison would compare
##1iteratively with the dummy variable. - With a function call such as a call to my macro
\pickGEincluded below I would then return and update the value if the value in the list is greater than the dummy.
What approach would be appropriate to setup a dummmy variable that can be updated in this context
- How would I finally report this final selected value.
- I would like to wrap this final value in a
\num[scientific-notation = fixed, fixed-exponent = 0, group-digits=false]{}call.
- I would like to wrap this final value in a
The complete MWE I want to insert
\documentclass{article}
\usepackage{fp}
\usepackage{siunitx}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\findLargest}{ m }
{
\begin{enumerate}
\clist_map_inline:nn { #1 } { \item \fbox{##1} }
\end{enumerate}
}
\ExplSyntaxOff
\newcommand{\pickGE}[2]{%
\ifboolexpr{test {\ifdimgreater{{#1} pt}{{#2} pt}}}%
{%
\FPeval{result}{{#1}}%
}% true
{%
\FPeval{result}{{#2}}%
}% false
}
\begin{document}
\findLargest{1, 2 ,3 6, 3,1}
\end{document}
Limitations
- I am committed to using
XeLaTeX - I may be misremembering but I also have a vague recollection that
siunitxhad something to do this directly... - I am happy to use any other package or approach much like the one employed here (that I wasn't able to make work with my glossaries labels Iterating through comma-separated arguments
- I am not limited to only comma separated lists but based on the shear volume of questions this looked like a good way to go.

