@@ -208,7 +208,7 @@ public function getElement(): ?AbstractDBElement
208208 */
209209 #[Groups(['parameter:read ' , 'full ' ])]
210210 #[SerializedName('formatted ' )]
211- public function getFormattedValue (): string
211+ public function getFormattedValue (bool $ latex_formatted = false ): string
212212 {
213213 //If we just only have text value, return early
214214 if (null === $ this ->value_typical && null === $ this ->value_min && null === $ this ->value_max ) {
@@ -218,19 +218,19 @@ public function getFormattedValue(): string
218218 $ str = '' ;
219219 $ bracket_opened = false ;
220220 if ($ this ->value_typical ) {
221- $ str .= $ this ->getValueTypicalWithUnit ();
221+ $ str .= $ this ->getValueTypicalWithUnit ($ latex_formatted );
222222 if ($ this ->value_min || $ this ->value_max ) {
223223 $ bracket_opened = true ;
224224 $ str .= ' ( ' ;
225225 }
226226 }
227227
228228 if ($ this ->value_max && $ this ->value_min ) {
229- $ str .= $ this ->getValueMinWithUnit ().' ... ' .$ this ->getValueMaxWithUnit ();
229+ $ str .= $ this ->getValueMinWithUnit ($ latex_formatted ).' ... ' .$ this ->getValueMaxWithUnit ($ latex_formatted );
230230 } elseif ($ this ->value_max ) {
231- $ str .= 'max. ' .$ this ->getValueMaxWithUnit ();
231+ $ str .= 'max. ' .$ this ->getValueMaxWithUnit ($ latex_formatted );
232232 } elseif ($ this ->value_min ) {
233- $ str .= 'min. ' .$ this ->getValueMinWithUnit ();
233+ $ str .= 'min. ' .$ this ->getValueMinWithUnit ($ latex_formatted );
234234 }
235235
236236 //Add closing bracket
@@ -344,25 +344,25 @@ public function getValueTypical(): ?float
344344 /**
345345 * Return a formatted version with the minimum value with the unit of this parameter.
346346 */
347- public function getValueTypicalWithUnit (): string
347+ public function getValueTypicalWithUnit (bool $ with_latex = false ): string
348348 {
349- return $ this ->formatWithUnit ($ this ->value_typical );
349+ return $ this ->formatWithUnit ($ this ->value_typical , with_latex: $ with_latex );
350350 }
351351
352352 /**
353353 * Return a formatted version with the maximum value with the unit of this parameter.
354354 */
355- public function getValueMaxWithUnit (): string
355+ public function getValueMaxWithUnit (bool $ with_latex = false ): string
356356 {
357- return $ this ->formatWithUnit ($ this ->value_max );
357+ return $ this ->formatWithUnit ($ this ->value_max , with_latex: $ with_latex );
358358 }
359359
360360 /**
361361 * Return a formatted version with the typical value with the unit of this parameter.
362362 */
363- public function getValueMinWithUnit (): string
363+ public function getValueMinWithUnit (bool $ with_latex = false ): string
364364 {
365- return $ this ->formatWithUnit ($ this ->value_min );
365+ return $ this ->formatWithUnit ($ this ->value_min , with_latex: $ with_latex );
366366 }
367367
368368 /**
@@ -441,11 +441,18 @@ public function setValueText(string $value_text): self
441441 /**
442442 * Return a string representation and (if possible) with its unit.
443443 */
444- protected function formatWithUnit (float $ value , string $ format = '%g ' ): string
444+ protected function formatWithUnit (float $ value , string $ format = '%g ' , bool $ with_latex = false ): string
445445 {
446446 $ str = sprintf ($ format , $ value );
447447 if ($ this ->unit !== '' ) {
448- return $ str .' ' .$ this ->unit ;
448+
449+ if (!$ with_latex ) {
450+ $ unit = $ this ->unit ;
451+ } else {
452+ $ unit = '$\mathrm{ ' .$ this ->unit .'}$ ' ;
453+ }
454+
455+ return $ str .' ' .$ unit ;
449456 }
450457
451458 return $ str ;
0 commit comments