Opened 8 years ago

Closed 8 years ago

#15870 closed defect (fixed)

(LaTeX)-typesetting of multi-character variables wrong

Reported by: dkrenn Owned by:
Priority: major Milestone: sage-6.2
Component: user interface Keywords: latex, variable
Cc: Merged in:
Authors: Daniel Krenn Reviewers: Andrey Novoseltsev
Report Upstream: N/A Work issues:
Branch: 8655a9a (Commits, GitHub, GitLab) Commit: 8655a9a8f5278d055f5ea033110360ea55cbc67e
Dependencies: Stopgaps:

Status badges

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).

See also #13543 (Multi-character variables not supported in legend_labels).

Change History (7)

comment:1 Changed 8 years ago by dkrenn

  • Component changed from PLEASE CHANGE to user interface
  • Keywords latex variable added
  • 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: 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

Replying to 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.

\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:

f27545bchanged latex-output of multi-character variables to \mathit{...}
3b1d8fdlatex_variable_name('') now returns '' instead of '\\mathit{}' (or '\\mbox{}' in the old code)
fb93330inserted doctests for \mathit in infinite_polynomial_ring
7dddc9dadded ast, bullet, circ, times, star to common_varnames
20b5e57simplified _latex_ of infinite_polynomial_ring; it now uses latex_variable_name
8655a9adoctest 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.