I would like to use LaTeX 3 to round up decimal numbers; I want something like the following: If I type


it should return


as output.

Unfortunately, I haven't taken the time to learn the LaTeX 3 syntax yet, so if someone will show me how to define such a function (or tell me what it is if it already exists), I will much appreciate it.


If I try to use Marco Daniel's answer in the following way, it still doesn't work:




\NewDocumentCommand {\RoundUp} { m }
  \fp_eval:n { round+(#1) }


                             ( \RoundUp{\horizontal}, \RoundUp{\vertical})


with the error message

! Undefined control sequence.
<argument> \LaTeX3 error: 
                           Unknown fp word a.
l.28 ...RoundUp{\horizontal}, \RoundUp{\vertical})

2 Answers 2


If you want to use LaTeX3 you can use ceil:


\NewDocumentCommand {\RoundingUpFunction} { m }
  \fp_eval:n { ceil(#1) }

\RoundingUpFunction{1.7}%leads to 2

\RoundingUpFunction{1.2}%leads to 2

\RoundingUpFunction{1}%leads to 1


Related to your update use \DeclareExpandableDocumentCommand instead of \NewDocumentCommand

  • @SvendTveskæg: See update. Jun 3, 2013 at 14:02
  • 1
    With the most recent LaTeX3, round+ should be ceil IIRC. Jul 7, 2014 at 3:20

If you can bear not to use LaTeX 3 then you could use TikZ instead...


  \pgfmathprintnumber[int trunc]{\pgfmathresult}%



  • This is good relativt to what I first asked for. This doesn't work for me however, so I'll edit my question. Jun 3, 2013 at 13:13
  • surely you meant "prepared not to use" rather than "happy not to use" :-) Jun 3, 2013 at 13:25
  • @DavidCarlisle Fixed :-) Jun 3, 2013 at 13:27
  • 3
    Minor detail: You only need pgfmath,pgfkeys (this is fixed so now, in CVS version, only pgfmath is enough). Also you can add int(ceil(#1)) so you can directly type \pgfmathresult
    – percusse
    Jun 3, 2013 at 13:50
  • @percusse Thanks, I've fixed my answer. I thought I didn't need all of TikZ, but when I used just pgfmath it didn't work. I hadn't realised I'd need pgfkeys too. Jun 3, 2013 at 14:07

You must log in to answer this question.

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