Skip to content

Commit

Permalink
remove $$ from result of to_latex
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Rehner committed Jul 15, 2021
1 parent 1071825 commit 70b9fc1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/pyquantity/sinumber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl pyo3::class::basic::PyObjectProtocol for PySINumber {
#[pymethods]
impl PySINumber {
fn _repr_latex_(&self) -> String {
self._data.to_latex()
format!("${}$", self._data.to_latex())
}
}

Expand Down
18 changes: 9 additions & 9 deletions src/si_fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,22 @@ impl SINumber {
let prefix = 10.0f64.powi(e as i32);
if let Some(e) = PREFIX_SYMBOLS.get(&e) {
return format!(
"${}\\,{}",
"{}\\,{}",
float_to_latex(value / prefix),
&unit_to_latex(symbols, exponents, Some(e))[1..]
&unit_to_latex(symbols, exponents, Some(e))
);
}
}
format!(
"${}\\,{}",
"{}\\,{}",
float_to_latex(value),
&unit_to_latex(symbols, exponents, None)[1..]
&unit_to_latex(symbols, exponents, None)
)
} else {
format!(
"${}\\,{}",
"{}\\,{}",
float_to_latex(self.value),
&self.unit.to_latex()[1..]
&self.unit.to_latex()
)
}
}
Expand Down Expand Up @@ -166,9 +166,9 @@ fn unit_to_latex(symbols: &[&str], exponents: &[i8], prefix: Option<&str>) -> St
let den_st = unit_to_latex_product(den);
match (num_st, den_st) {
(None, None) => format!(""),
(Some(num), None) => format!("$\\mathrm{{{}}}$", num),
(None, Some(den)) => format!("$\\mathrm{{\\frac{{1}}{{{}}}}}$", den),
(Some(num), Some(den)) => format!("$\\mathrm{{\\frac{{{}}}{{{}}}}}$", num, den),
(Some(num), None) => format!("\\mathrm{{{}}}", num),
(None, Some(den)) => format!("\\mathrm{{\\frac{{1}}{{{}}}}}", den),
(Some(num), Some(den)) => format!("\\mathrm{{\\frac{{{}}}{{{}}}}}", num, den),
}
}

Expand Down

0 comments on commit 70b9fc1

Please sign in to comment.