Opened 8 years ago

Closed 8 years ago

# (LaTeX)-typesetting of multi-character variables wrong

Reported by: Owned by: dkrenn major sage-6.2 user interface latex, variable Daniel Krenn Andrey Novoseltsev N/A 8655a9a 8655a9a8f5278d055f5ea033110360ea55cbc67e

### Description

We have

sage: abc = var('abc')
sage: latex((abc/(abc+1)+42)/(abc-1))
\frac{\frac{\mbox{abc}}{\mbox{abc} + 1} + 42}{\mbox{abc} - 1}


The \mbox here is wrong because of the following two reasons:

• In the example above \mbox{abc} has normal size, whereas the +1 is typeset in subscriptsize (or so). You can see this by view((abc/(abc+1)+42)/(abc-1)).
• Variables are written in italic.

Therefore \mbox should be replaced by \mathit (which solves both problems mentioned above).

### comment:1 Changed 8 years ago by dkrenn

• Component changed from PLEASE CHANGE to user interface
• Summary changed from typesetting of multi-character variables wrong to (LaTeX)-typesetting of multi-character variables wrong
• Type changed from PLEASE CHANGE to defect

### comment:3 follow-up: ↓ 4 Changed 8 years ago by ppurka

The whole point of not writing it directly as abc is probably to avoid italics. So, a proper fix would be to use \text instead of \mbox. You can compare the output as follows

view(LatexExpr(r'\frac{\frac{\text{abc}}{\text{abc} + 1} + 42}{\text{abc} - 1}'))
view(LatexExpr(r'\frac{\frac{\mathit{abc}}{\mathit{abc} + 1} + 42}{\mathit{abc} - 1}'))


### comment:4 in reply to: ↑ 3 Changed 8 years ago by dkrenn

The whole point of not writing it directly as abc is probably to avoid italics. So, a proper fix would be to use \text instead of \mbox.

\text is not correct for variables. They have to be written italic.

### comment:5 Changed 8 years ago by dkrenn

• Authors set to Daniel Krenn
• Branch set to u/dkrenn/ticket/15870
• Commit set to 8655a9a8f5278d055f5ea033110360ea55cbc67e
• Status changed from new to needs_review

I've changed the source so that multi-character variables are printed correctly.

The LaTeX-output of infinite polynomial ring variables was also adapted to support multi-character variables correctly. Thereby, this output is now generated using the standard tools of latex.py.

New commits:

 ​f27545b changed latex-output of multi-character variables to \mathit{...} ​3b1d8fd latex_variable_name('') now returns '' instead of '\\mathit{}' (or '\\mbox{}' in the old code) ​fb93330 inserted doctests for \mathit in infinite_polynomial_ring ​7dddc9d added ast, bullet, circ, times, star to common_varnames ​20b5e57 simplified _latex_ of infinite_polynomial_ring; it now uses latex_variable_name ​8655a9a doctest for trac #15870 added

### comment:6 Changed 8 years ago by novoselt

• Reviewers set to Andrey Novoseltsev
• Status changed from needs_review to positive_review

### comment:7 Changed 8 years ago by vbraun

• Branch changed from u/dkrenn/ticket/15870 to 8655a9a8f5278d055f5ea033110360ea55cbc67e
• Resolution set to fixed
• Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.