Skip to content

Commit ae417bb

Browse files
author
Release Manager
committed
gh-35353: Replace \mbox by \text in manifolds <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> ### 📚 Description vscode uses katex to render the latex output of jupyter cells. However, katex doesn't support mbox (see KaTeX/KaTeX#2050). Thus we replace `\mbox` with `\text`. <!-- Describe your changes here in detail --> <!-- Why is this change required? What problem does it solve? --> <!-- If it resolves an open issue, please link to the issue here. For example "Closes #1337" --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [x] I have made sure that the title is self-explanatory and the description concisely explains the PR. - [ ] I have linked an issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open pull requests that this PR logically depends on --> <!-- - #xyz: short description why this is a dependency - #abc: ... --> URL: #35353 Reported by: Tobias Diez Reviewer(s): Eric Gourgoulhon
2 parents 05e6b0a + 86bfee4 commit ae417bb

17 files changed

+41
-36
lines changed

src/sage/manifolds/chart.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2165,7 +2165,7 @@ def _display_coord_range(self, xx, rtxt, rlatex):
21652165
rlatex += r"\right]"
21662166
if bounds[1][1] == 'periodic':
21672167
rtxt += " (periodic)"
2168-
rlatex += r"\mbox{(periodic)}"
2168+
rlatex += r"\text{(periodic)}"
21692169
else:
21702170
rtxt += ")"
21712171
rlatex += r"\right)"

src/sage/manifolds/continuous_map.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ def _latex_(self):
505505
506506
"""
507507
if self._latex_name is None:
508-
return r'\mbox{' + str(self) + r'}'
508+
return r'\text{' + str(self) + r'}'
509509
else:
510510
return self._latex_name
511511

@@ -1119,7 +1119,7 @@ def display(self, chart1=None, chart2=None):
11191119
11201120
sage: latex(Phi.display(c_xy, c_cart))
11211121
\begin{array}{llcl} \Phi:& S^2 & \longrightarrow & \RR^3
1122-
\\ \mbox{on}\ U : & \left(x, y\right) & \longmapsto
1122+
\\ \text{on}\ U : & \left(x, y\right) & \longmapsto
11231123
& \left(X, Y, Z\right) = \left(\frac{2 \, x}{x^{2} + y^{2} + 1},
11241124
\frac{2 \, y}{x^{2} + y^{2} + 1},
11251125
\frac{x^{2} + y^{2} - 1}{x^{2} + y^{2} + 1}\right)
@@ -1176,7 +1176,7 @@ def display(self, chart1=None, chart2=None):
11761176
2*y/(x**2 + y**2 + 1), (x**2 + y**2 - 1)/(x**2 + y**2 + 1))
11771177
sage: latex(Phi.display(c_xy, c_cart))
11781178
\begin{array}{llcl} \Phi:& S^2 & \longrightarrow & \RR^3
1179-
\\ \mbox{on}\ U : & \left(x, y\right) & \longmapsto
1179+
\\ \text{on}\ U : & \left(x, y\right) & \longmapsto
11801180
& \left(X, Y, Z\right) = \left(\frac{2 x}{x^{2} + y^{2} + 1},
11811181
\frac{2 y}{x^{2} + y^{2} + 1},
11821182
\frac{x^{2} + y^{2} - 1}{x^{2} + y^{2} + 1}\right)
@@ -1212,7 +1212,7 @@ def _display_expression(self, chart1, chart2, result):
12121212
result._latex += ' & '
12131213
else:
12141214
result._txt += 'on ' + chart1._domain._name + ': '
1215-
result._latex += r'\mbox{on}\ ' + latex(chart1._domain) + \
1215+
result._latex += r'\text{on}\ ' + latex(chart1._domain) + \
12161216
r': & '
12171217
result._txt += repr(coords1) + ' ' + unicode_mapsto + ' '
12181218
result._latex += latex(coords1) + r'& \longmapsto & '

src/sage/manifolds/differentiable/curve.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class DifferentiableCurve(DiffMap):
186186
187187
sage: c = M.curve([sin(t), sin(2*t)/2], (t, 0, 2*pi))
188188
sage: latex(c)
189-
\mbox{Curve in the 2-dimensional differentiable manifold M}
189+
\text{Curve in the 2-dimensional differentiable manifold M}
190190
sage: c = M.curve([sin(t), sin(2*t)/2], (t, 0, 2*pi), name='c')
191191
sage: latex(c)
192192
c

src/sage/manifolds/differentiable/diff_form_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ def _latex_(self):
498498
499499
"""
500500
if self._latex_name is None:
501-
return r'\mbox{' + str(self) + r'}'
501+
return r'\text{' + str(self) + r'}'
502502
else:
503503
return self._latex_name
504504

src/sage/manifolds/differentiable/metric.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def _new_instance(self):
447447
"""
448448
return type(self)(self._vmodule, 'unnamed metric',
449449
signature=self._signature,
450-
latex_name=r'\mbox{unnamed metric}')
450+
latex_name=r'\text{unnamed metric}')
451451

452452
def _init_derived(self):
453453
r"""
@@ -2706,7 +2706,7 @@ def _new_instance(self):
27062706
"""
27072707
return type(self)(self._vmodule, 'unnamed metric',
27082708
signature=self._signature,
2709-
latex_name=r'\mbox{unnamed metric}')
2709+
latex_name=r'\text{unnamed metric}')
27102710

27112711
def signature(self):
27122712
r"""

src/sage/manifolds/differentiable/mixed_form.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def _latex_(self):
346346
347347
"""
348348
if self._name is None:
349-
return r'\mbox{' + repr(self) + r'}'
349+
return r'\text{' + repr(self) + r'}'
350350
else:
351351
return self._latex_name
352352

@@ -548,7 +548,7 @@ def display(self):
548548
else:
549549
resu_txt += self[0]._name
550550
if self[0]._latex_name is None:
551-
resu_latex += r"\mbox{(unnamed scalar field)}"
551+
resu_latex += r"\text{(unnamed scalar field)}"
552552
else:
553553
resu_latex += latex(self[0])
554554
# Differential forms:
@@ -558,7 +558,7 @@ def display(self):
558558
else:
559559
resu_txt += " + " + self[j]._name
560560
if self[j]._latex_name is None:
561-
resu_latex += r"+\mbox{(unnamed " + str(j) + r"-form)}"
561+
resu_latex += r"+\text{(unnamed " + str(j) + r"-form)}"
562562
else:
563563
resu_latex += r"+" + latex(self[j])
564564
return FormattedExpansion(resu_txt, resu_latex)

src/sage/manifolds/differentiable/multivector_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ def _latex_(self):
444444
445445
"""
446446
if self._latex_name is None:
447-
return r'\mbox{' + str(self) + r'}'
447+
return r'\text{' + str(self) + r'}'
448448
else:
449449
return self._latex_name
450450

src/sage/manifolds/differentiable/symplectic_form.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def _new_instance(self):
185185
return type(self)(
186186
self._vmodule,
187187
"unnamed symplectic form",
188-
latex_name=r"\mbox{unnamed symplectic form}",
188+
latex_name=r"\text{unnamed symplectic form}",
189189
)
190190

191191
def _init_derived(self):

src/sage/manifolds/differentiable/tensorfield.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ class TensorField(ModuleElementWithMutability):
109109
110110
.. MATH::
111111
112-
t(p):\ \underbrace{T_q^*M\times\cdots\times T_q^*M}_{k\ \; \mbox{times}}
113-
\times \underbrace{T_q M\times\cdots\times T_q M}_{l\ \; \mbox{times}}
112+
t(p):\ \underbrace{T_q^*M\times\cdots\times T_q^*M}_{k\ \; \text{times}}
113+
\times \underbrace{T_q M\times\cdots\times T_q M}_{l\ \; \text{times}}
114114
\longrightarrow K,
115115
116116
where `T_q^* M` is the dual vector space to `T_q M` and `K` is the
@@ -590,7 +590,7 @@ def _latex_(self):
590590
591591
"""
592592
if self._latex_name is None:
593-
return r'\mbox{' + str(self) + r'}'
593+
return r'\text{' + str(self) + r'}'
594594
else:
595595
return self._latex_name
596596

src/sage/manifolds/differentiable/tensorfield_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ def _latex_(self):
520520
521521
"""
522522
if self._latex_name is None:
523-
return r'\mbox{' + str(self) + r'}'
523+
return r'\text{' + str(self) + r'}'
524524
else:
525525
return self._latex_name
526526

src/sage/manifolds/differentiable/tensorfield_paral.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ class TensorFieldParal(FreeModuleTensor, TensorField):
355355
356356
.. MATH::
357357
358-
t(p):\ \underbrace{T_q^*M\times\cdots\times T_q^*M}_{k\ \; \mbox{times}}
359-
\times \underbrace{T_q M\times\cdots\times T_q M}_{l\ \; \mbox{times}}
358+
t(p):\ \underbrace{T_q^*M\times\cdots\times T_q^*M}_{k\ \; \text{times}}
359+
\times \underbrace{T_q M\times\cdots\times T_q M}_{l\ \; \text{times}}
360360
\longrightarrow K,
361361
362362
where `T_q^* M` is the dual vector space to `T_q M` and `K` is the

src/sage/manifolds/differentiable/vector_bundle.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,8 @@ class TensorBundle(DifferentiableVectorBundle):
362362
363363
.. MATH::
364364
365-
t:\ \underbrace{T_q^*N\times\cdots\times T_q^*N}_{k\ \; \mbox{times}}
366-
\times \underbrace{T_q N\times\cdots\times T_q N}_{l\ \; \mbox{times}}
365+
t:\ \underbrace{T_q^*N\times\cdots\times T_q^*N}_{k\ \; \text{times}}
366+
\times \underbrace{T_q N\times\cdots\times T_q N}_{l\ \; \text{times}}
367367
\longrightarrow K
368368
369369
(`k` is called the *contravariant* and `l` the *covariant* rank of the
@@ -464,7 +464,7 @@ def __init__(self, base_space, k, l, dest_map=None):
464464
else:
465465
name = self._dest_map._name + "^*"
466466
if self._dest_map._latex_name is None:
467-
latex_name = r'\mbox{(unnamed map)}^* '
467+
latex_name = r'\text{(unnamed map)}^* '
468468
else:
469469
latex_name = self._dest_map._latex_name + r'^* '
470470
else:
@@ -1356,8 +1356,8 @@ def local_frame(self, *args, **kwargs):
13561356
13571357
.. MATH::
13581358
1359-
p \mapsto \Big(\underbrace{e^*(p), \dots, e^*(p)}_{k\ \; \mbox{times}},
1360-
\underbrace{e(p), \dots, e(p)}_{l\ \; \mbox{times}}\Big) \in
1359+
p \mapsto \Big(\underbrace{e^*(p), \dots, e^*(p)}_{k\ \; \text{times}},
1360+
\underbrace{e(p), \dots, e(p)}_{l\ \; \text{times}}\Big) \in
13611361
T^{(k,l)}_q N ,
13621362
13631363
with `q=\Phi(p)`, defines a basis at each point `p \in U` and

src/sage/manifolds/differentiable/vectorfield_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def _latex_(self):
396396
397397
"""
398398
if self._latex_name is None:
399-
return r'\mbox{' + str(self) + r'}'
399+
return r"\text{" + str(self) + r"}"
400400
else:
401401
return self._latex_name
402402

src/sage/manifolds/manifold_homset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def _latex_(self):
207207
\mathrm{Hom}\left(M,N\right)
208208
"""
209209
if self._latex_name is None:
210-
return r'\mbox{' + str(self) + r'}'
210+
return r'\text{' + str(self) + r'}'
211211
else:
212212
return self._latex_name
213213

src/sage/manifolds/point.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def _latex_(self):
250250
sage: X.<x,y> = M.chart()
251251
sage: p = M((2,-3))
252252
sage: p._latex_()
253-
'\\mbox{Point on the 2-dimensional topological manifold M}'
253+
'\\text{Point on the 2-dimensional topological manifold M}'
254254
sage: p = M((2,-3), name='p')
255255
sage: p._latex_()
256256
'p'
@@ -262,7 +262,7 @@ def _latex_(self):
262262
263263
"""
264264
if self._latex_name is None:
265-
return r'\mbox{' + str(self) + r'}'
265+
return r'\text{' + str(self) + r'}'
266266
return self._latex_name
267267

268268
def coordinates(self, chart=None, old_chart=None):

src/sage/manifolds/scalarfield.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,18 @@
4040
# https://www.gnu.org/licenses/
4141
# *****************************************************************************
4242

43-
from typing import Optional
43+
from __future__ import annotations
44+
from typing import Optional, TYPE_CHECKING
4445
from sage.structure.element import (CommutativeAlgebraElement,
4546
ModuleElementWithMutability)
4647
from sage.symbolic.expression import Expression
4748
from sage.manifolds.chart_func import ChartFunction
4849
from sage.misc.cachefunc import cached_method
4950

51+
if TYPE_CHECKING:
52+
from sage.tensor.modules.format_utilities import FormattedExpansion
53+
from sage.manifolds.chart import Chart
54+
5055
class ScalarField(CommutativeAlgebraElement, ModuleElementWithMutability):
5156
r"""
5257
Scalar field on a topological manifold.
@@ -1499,7 +1504,7 @@ def _latex_(self):
14991504
sage: X.<x,y> = M.chart()
15001505
sage: f = M.scalar_field({X: x+y})
15011506
sage: f._latex_()
1502-
'\\mbox{Scalar field on the 2-dimensional topological manifold M}'
1507+
'\\text{Scalar field on the 2-dimensional topological manifold M}'
15031508
sage: f = M.scalar_field({X: x+y}, name='f')
15041509
sage: f._latex_()
15051510
'f'
@@ -1511,7 +1516,7 @@ def _latex_(self):
15111516
15121517
"""
15131518
if self._latex_name is None:
1514-
return r'\mbox{' + str(self) + r'}'
1519+
return r'\text{' + str(self) + r'}'
15151520
else:
15161521
return self._latex_name
15171522

@@ -2096,7 +2101,7 @@ def set_restriction(self, rst):
20962101
self._express[chart.restrict(intersection)] = expr
20972102
self._is_zero = False # a priori
20982103

2099-
def display(self, chart=None):
2104+
def display(self, chart: Optional[Chart]=None) -> FormattedExpansion:
21002105
r"""
21012106
Display the expression of the scalar field in a given chart.
21022107
@@ -2149,7 +2154,7 @@ def display(self, chart=None):
21492154
f: M → ℝ
21502155
on U: (x, y) ↦ y^2
21512156
sage: latex(f.display())
2152-
\begin{array}{llcl} f:& M & \longrightarrow & \mathbb{R} \\ \mbox{on}\ U : & \left(x, y\right) & \longmapsto & y^{2} \end{array}
2157+
\begin{array}{llcl} f:& M & \longrightarrow & \mathbb{R} \\ \text{on}\ U : & \left(x, y\right) & \longmapsto & y^{2} \end{array}
21532158
21542159
"""
21552160
from sage.misc.latex import latex
@@ -2176,7 +2181,7 @@ def _display_expression(self, chart, result):
21762181
result._latex += " & "
21772182
else:
21782183
result._txt += "on " + chart.domain()._name + ": "
2179-
result._latex += r"\mbox{on}\ " + latex(chart.domain()) \
2184+
result._latex += r"\text{on}\ " + latex(chart.domain()) \
21802185
+ r": & "
21812186
result._txt += repr(coords) + " " + unicode_mapsto + " " \
21822187
+ repr(expression) + "\n"

src/sage/manifolds/section.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ def _latex_(self):
345345
346346
"""
347347
if self._latex_name is None:
348-
return r'\mbox{' + str(self) + r'}'
348+
return r'\text{' + str(self) + r'}'
349349
else:
350350
return self._latex_name
351351

0 commit comments

Comments
 (0)