I have a problem with rounding --- I have seen How do I get \pgfmathparse to create value rounded to one decimal place? but still I can't obtain the result I need.

See this MWE:


   % round to 1 digit:
    \pgfkeys{/pgf/number format/precision=1}
   % \pgfmathprintnumber[fixed, precision=1]{\pgfmathresult}
Caph: \prlen{\caph} \the\caph \par
X-He: \prlen{\xlen} \the\xlen \par







which results in:


...and you can see the loss of precision in the division by ten biting me sometime. If I change the definition of \prlen to use \pgfmathprintnumber, like this:

   % round to 1 digit:
    %\pgfkeys{/pgf/number format/precision=1}
    \pgfmathprintnumber[fixed, precision=1]{\pgfmathresult}

I have this, which prints things in math font:

New output

Is there a way to have a correct rounding but using the normal font I am using outside, like in the first case?

1 Answer 1


The macro \pgfmathprintnumber uses math mode for this.

I suggest changing the definition of \prlen:


  \fp_eval:n { round(\dim_to_fp:n { #1 }, 1) }

enter image description here

If you want one decimal digit even if zero, you can do

  ]{\fp_eval:n { \dim_to_fp:n #1 }}

enter image description here

  • Thanks, almost perfect. If only it printed 53.0 instead of 53... ;-)
    – Rmano
    Apr 10, 2016 at 16:49
  • 1
    @Rmano Your wish is my command!
    – egreg
    Apr 10, 2016 at 22:04

You must log in to answer this question.

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