I'm writing a package and I need LaTeX to perform calculations involving floats and fractional parts without them appearing on the pdf, like how you would define a variable in Python without having it printed into the console. The reason I need to do this is that I want to use the result of the calculation in the argument of command. For instance, something like

\textcolor[hsb]{\fractionalpart{\division{11.3}{7.1}}, 1, 1}{I love potatoes}

should be equivalent to

\textcolor[hsb]{.59, 1, 1}{I love potatoes}

I'm using pdfLaTeX and for the purpose of what I'm trying to do, I can't really use anything other than that (so no LuaLaTeX, XeLaTeX, etc. please). I tried a lot of things such as \divide, \numexpr and some other similar commands, but they all seem to print their result in the generated pdf (or just not work at all), which is what I'm trying to avoid.

I'm not very familiar with programming complex LaTeX commands, so if anyone could indicate me how to proceed and/or refer some sort of documentation that I could use to get a better idea of how all of this works, it would really be appreciated.

1 Answer 1


enter image description here


\textcolor[hsb]{\fpeval{round(11.3/7.1,2) -1},1, 1}{I love potatoes}

\textcolor[hsb]{.59, 1, 1}{I love potatoes}
  • Thanks a lot! It really helped me. I didn't such a package existed. I'm definitely going to use it again in the future. Commented Feb 26, 2022 at 20:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .