diff --git a/src/Entity/Parameters/AbstractParameter.php b/src/Entity/Parameters/AbstractParameter.php index eee0a030..c77707d5 100644 --- a/src/Entity/Parameters/AbstractParameter.php +++ b/src/Entity/Parameters/AbstractParameter.php @@ -449,15 +449,10 @@ abstract class AbstractParameter extends AbstractNamedDBElement implements Uniqu if (!$with_latex) { $unit = $this->unit; } else { - // if chars occur that will mess up the latex formatting, display them plain, regardless of the desired output - if (str_contains($this->unit, '~') || str_contains($this->unit, '^') || str_contains($this->unit, '\\')) - { - $unit = $this->unit; - } - else // otherwise, style the chars with latex, but escape latex special chars - { - $unit = '$\mathrm{'.$this->latexEscape($this->unit).'}$'; - } + //Escape the percentage sign for convenience (as latex uses it as comment and it is often used in units) + $escaped = preg_replace('/(\%)/', "\\\\$1", $this->unit); + + $unit = '$\mathrm{'.$escaped.'}$'; } return $str.' '.$unit; @@ -466,14 +461,6 @@ abstract class AbstractParameter extends AbstractNamedDBElement implements Uniqu return $str; } - /** - * Return a latex escaped string - */ - protected function latexEscape(string $latex): string - { - return preg_replace('/(\&|\%|\$|\#|\_|\{|\})/', "\\\\$1", $latex); - } - /** * Returns the class of the element that is allowed to be associated with this attachment. * @return string