sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.36k stars 462 forks source link

Fix latex for sech and csch #4499

Closed mwhansen closed 15 years ago

mwhansen commented 15 years ago

Currently, we have

sage: latex(sech)
\sech
sage: latex(csch)
\csch

Apparently \sech and \csch are not recognized in LaTeX. These should be

sage: latex(sech)
\text{sech}
sage: latex(csch)
\text{csch}

Component: misc

Issue created by migration from https://trac.sagemath.org/ticket/4499

mwhansen commented 15 years ago
comment:1

Attachment: trac_4499.patch.gz

7c09a680-e216-4024-bb8e-9bfd4aa7f313 commented 15 years ago
comment:2

I'm using sage-3.1.4 here, so I can't say anything about applying this patch against the latest alpha release of sage-3.2. Perhaps other folks can review the patch using the latest alpha release. Before applying the patch trac_4499.patch against sage-3.1.4, we'd get these:

sage: # sech and arcsech
sage: sech._latex_()
'\\sech'
sage: asech._latex_()
'\\sech^{-1}'
sage: arcsech._latex_()
'\\sech^{-1}'
sage: latex(sech)
\sech
sage: latex(asech)
\sech^{-1}
sage: latex(arcsech)
\sech^{-1}
sage:
sage: # csch and arccsch
sage: csch._latex_()
'\\csch'
sage: acsch._latex_()
'\\csch^{-1}'
sage: arccsch._latex_()
'\\csch^{-1}'
sage: latex(csch)
\csch
sage: latex(acsch)
\csch^{-1}
sage: latex(arccsch)
\csch^{-1}

As far as I know, the returned LaTeX strings would cause tex-live to go berserk and complain about "Undefined control sequence" even if we compile with or without the macro \usepackage{amsmath,amssymb,amsthm} in the preamble of a .tex file.

After applying the patch against sage-3.1.4, we get these:

sage: # sech and arcsech
sage: sech._latex_()
'\\text{sech}'
sage: asech._latex_()
'\\text{sech}^{-1}'
sage: arcsech._latex_()
'\\text{sech}^{-1}'
sage: latex(sech)
\text{sech}
sage: latex(asech)
\text{sech}^{-1}
sage: latex(arcsech)
\text{sech}^{-1}
sage: 
sage: # csch and arccsch
sage: csch._latex_()
'\\text{csch}'
sage: acsch._latex_()
'\\text{csch}^{-1}'
sage: arccsch._latex_()
'\\text{csch}^{-1}'
sage: 
sage: latex(csch)
\text{csch}
sage: latex(acsch)
\text{csch}^{-1}
sage: latex(arccsch)
\text{csch}^{-1}

The returned LaTeX strings now look reasonable to me and work as expected when embedded within math mode and using the macro \usepackage{amsmath}.

williamstein commented 15 years ago
comment:3

Looks good to me too.

f8667504-6eb9-4678-970d-c85e19c6bba2 commented 15 years ago
comment:4

From pure LaTeX typesetting point of view I would except operators to be consistent with standard operators, that's something like \mathop {\operator@font csch}\nolimits instead of \text{csch}, when paper/book is in last stages it might be useful to alter behaviour of \operator@font for example (that's used in all \sin, \cos, etc...) and then \text might be standing out, anyway the \text workaround seems to work if no style changes are applied

85eec1a4-3d04-4b4d-b711-d4db03337c41 commented 15 years ago
comment:5

Merged in Sage 3.1.rc1

85eec1a4-3d04-4b4d-b711-d4db03337c41 commented 15 years ago
comment:6

This should be 3.2.rc1