[sage-devel] Re: \Bold command definition in every LaTeX output

2021-12-23 Thread Eric Gourgoulhon
Le jeudi 23 décembre 2021 à 03:16:13 UTC+1, John H Palmieri a écrit :

> Sure, that sounds like a good idea.
>
>
In the above example, I used LatexExpr  as a place holder for 
_bold_command, but maybe there is a better way (at least, LatexExpr has the 
advantage to not require any new injection in the global namespace).

Eric.
 

> - John
>
> On Wednesday, December 22, 2021 at 3:05:44 AM UTC-8 Eric Gourgoulhon wrote:
>
>> Le mercredi 22 décembre 2021 à 00:26:58 UTC+1, John H Palmieri a écrit :
>>
>>> I have no objection to this, but the purpose for using \Bold{...} was to 
>>> make its behavior easily customizable, since some people might want 
>>> \mathbf{...} and some might want \mathbb{...}. 
>>>
>>
>> The customization could be performed at the Python level, instead of the 
>> LaTeX one, e.g.  something like:
>>
>> def _latex_(self):
>> return LatexExpr.bold_command() + r"{Q}"
>>
>> with bold_command() being a static method of LatexExpr that returns the 
>> class attribute _bold_command. The latter would be initialized to 
>> r"\mathbf" and could be customized by the end user thanks to some 
>> static/class method of LatexExpr, e.g. 
>>
>> sage: LatexExpr.set_bold_command("mathbb")
>>
>> Eric.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/1f9a5ff7-11f0-4cc5-a7c8-bf0bb0521382n%40googlegroups.com.


[sage-devel] Re: \Bold command definition in every LaTeX output

2021-12-22 Thread John H Palmieri
Sure, that sounds like a good idea.

- John

On Wednesday, December 22, 2021 at 3:05:44 AM UTC-8 Eric Gourgoulhon wrote:

> Le mercredi 22 décembre 2021 à 00:26:58 UTC+1, John H Palmieri a écrit :
>
>> I have no objection to this, but the purpose for using \Bold{...} was to 
>> make its behavior easily customizable, since some people might want 
>> \mathbf{...} and some might want \mathbb{...}. 
>>
>
> The customization could be performed at the Python level, instead of the 
> LaTeX one, e.g.  something like:
>
> def _latex_(self):
> return LatexExpr.bold_command() + r"{Q}"
>
> with bold_command() being a static method of LatexExpr that returns the 
> class attribute _bold_command. The latter would be initialized to 
> r"\mathbf" and could be customized by the end user thanks to some 
> static/class method of LatexExpr, e.g. 
>
> sage: LatexExpr.set_bold_command("mathbb")
>
> Eric.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/faf43380-4bb6-4d2d-8e38-255f1af00671n%40googlegroups.com.


[sage-devel] Re: \Bold command definition in every LaTeX output

2021-12-22 Thread Matthias Koeppe
On Tuesday, December 21, 2021 at 3:26:58 PM UTC-8 John H Palmieri wrote:

> I have no objection to this, but the purpose for using \Bold{...} was to 
> make its behavior easily customizable, since some people might want 
> \mathbf{...} and some might want \mathbb{...}. 
>

If we are keeping \Bold for this purpose, perhaps we should change 
\newcommand to \providecommand, which would fix OP's issue 
 

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/b915d9df-6ee1-46d3-99b8-3a1c7f62843dn%40googlegroups.com.


[sage-devel] Re: \Bold command definition in every LaTeX output

2021-12-22 Thread Eric Gourgoulhon

Le mercredi 22 décembre 2021 à 00:26:58 UTC+1, John H Palmieri a écrit :

> I have no objection to this, but the purpose for using \Bold{...} was to 
> make its behavior easily customizable, since some people might want 
> \mathbf{...} and some might want \mathbb{...}. 
>

The customization could be performed at the Python level, instead of the 
LaTeX one, e.g.  something like:

def _latex_(self):
return LatexExpr.bold_command() + r"{Q}"

with bold_command() being a static method of LatexExpr that returns the 
class attribute _bold_command. The latter would be initialized to 
r"\mathbf" and could be customized by the end user thanks to some 
static/class method of LatexExpr, e.g. 

sage: LatexExpr.set_bold_command("mathbb")

Eric.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/7000414b-6437-46af-9061-c03087c9f976n%40googlegroups.com.


[sage-devel] Re: \Bold command definition in every LaTeX output

2021-12-21 Thread John H Palmieri
I have no objection to this, but the purpose for using \Bold{...} was to 
make its behavior easily customizable, since some people might want 
\mathbf{...} and some might want \mathbb{...}. Are you suggesting replacing 
\Bold in the latex() method for the object, or keeping it but doing the 
redefinition as \mathbf using Python/Sphinx rather than in LaTeX?

-- 
John



On Tuesday, December 21, 2021 at 8:54:56 AM UTC-8 Matthias Koeppe wrote:

> On Tuesday, December 21, 2021 at 2:49:11 AM UTC-8 Eric Gourgoulhon wrote:
>
>> Unless there might be a reason for it, why not replacing lines like
>> return r"\Bold{Q}"
>> by
>> return r"\mathbf{Q}"
>> in the relevant  _latex_ methods ? 
>>
>
> +1
>
>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/b894b35c-d7f5-487a-8346-6d976dc24aa7n%40googlegroups.com.


[sage-devel] Re: \Bold command definition in every LaTeX output

2021-12-21 Thread Matthias Koeppe
On Tuesday, December 21, 2021 at 2:49:11 AM UTC-8 Eric Gourgoulhon wrote:

> Unless there might be a reason for it, why not replacing lines like
> return r"\Bold{Q}"
> by
> return r"\mathbf{Q}"
> in the relevant  _latex_ methods ? 
>

+1

 

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/f4ae357d-244c-4e53-84f1-c0cda7d8a16fn%40googlegroups.com.


Re: [sage-devel] Re: \Bold command definition in every LaTeX output

2021-12-21 Thread Dima Pasechnik
I would vote for updating our LaTeX methods to use more standard macros.

On Tue, 21 Dec 2021, 10:49 Eric Gourgoulhon,  wrote:

> Hi,
>
> Le lundi 20 décembre 2021 à 12:06:05 UTC+1, AlbertHilb a écrit :
>
>> Problem solved! Thank you very much!
>>
>
> That being said, it seems to me that these \newcommand{Bold} in each LaTeX
> output (!) are  an unnecessary pollution of  the Jupyter notebooks in
> %display latex mode. Unless there might be a reason for it, why not
> replacing lines like
> return r"\Bold{Q}"
> by
> return r"\mathbf{Q}"
> in the relevant  _latex_ methods ? (the above example is line 279 of
> src/sage/rings/rational_field.py)
>
> Eric.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-devel+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-devel/d56a3258-a95e-49b4-beb8-b38ed7493014n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/CAAWYfq0mbzu0xbjfoNUwotC_6_nJK%2BfzGEPBujOBfi6FdkgWeQ%40mail.gmail.com.


[sage-devel] Re: \Bold command definition in every LaTeX output

2021-12-21 Thread Eric Gourgoulhon
Hi,

Le lundi 20 décembre 2021 à 12:06:05 UTC+1, AlbertHilb a écrit :

> Problem solved! Thank you very much!
>

That being said, it seems to me that these \newcommand{Bold} in each LaTeX 
output (!) are  an unnecessary pollution of  the Jupyter notebooks in 
%display latex mode. Unless there might be a reason for it, why not 
replacing lines like
return r"\Bold{Q}"
by
return r"\mathbf{Q}"
in the relevant  _latex_ methods ? (the above example is line 279 of 
src/sage/rings/rational_field.py) 

Eric.


-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/d56a3258-a95e-49b4-beb8-b38ed7493014n%40googlegroups.com.


[sage-devel] Re: \Bold command definition in every LaTeX output

2021-12-20 Thread AlbertHilb
Problem solved! Thank you very much!

Il giorno domenica 19 dicembre 2021 alle 21:55:55 UTC+1 
dmo...@deductivepress.ca ha scritto:

> Yes, this is the intended behaviour.  If you don't like it, then, as a 
> workaround, you could try to clear the variable called 
> "sage_configurable_latex_macros".  YMMV, but this works for me in a fresh 
> sage session:
> sage: from sage.misc.latex_macros import sage_configurable_latex_macros
> sage: global sage_configurable_latex_macros
> sage: 
> sage_configurable_latex_macros.remove("\\newcommand{\\Bold}[1]{\\mathbf{#1}}")
> If I now type "html(x)", then the result is "\[x\]", instead 
> of "\[\newcommand{\Bold}[1]{\mathbf{#1}}x\]".
>
> If that gives errors due to a bad definition of "\\Bold", then maybe you 
> should also do:
> sage: 
> sage_configurable_latex_macros.append("\\renewcommand{\\Bold}[1]{\\mathbf{#1}}")
>
> On Sunday, December 19, 2021 at 7:34:13 AM UTC-7 AlbertHilb wrote:
>
>> Hi all. 
>>
>> I noted every command LaTeX output is prefaced by the definition of a 
>> \Bold newcommand even if the \Bold command is not really used in the 
>> output.
>> For example, if I type "1" and press return I get
>>
>> \newcommand{\Bold}[1]{\mathbf{#1}}1
>>
>> Is this intended?
>>
>> Among other things, the presence of the newcommand definition prevent me 
>> from using KaTeX as LaTeX renderer because it complains \Bold command 
>> already exists and \renewcommand should be used to redefine it.
>>
>> I use SageMath 9.4 binary for Ubuntu 20.04 64 bit with jupyterlab 3.2.4 
>> as frontend.
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/05779db3-5581-4ac7-8212-4191f1f34078n%40googlegroups.com.


[sage-devel] Re: \Bold command definition in every LaTeX output

2021-12-19 Thread dmo...@deductivepress.ca
Yes, this is the intended behaviour.  If you don't like it, then, as a 
workaround, you could try to clear the variable called 
"sage_configurable_latex_macros".  YMMV, but this works for me in a fresh 
sage session:
sage: from sage.misc.latex_macros import sage_configurable_latex_macros
sage: global sage_configurable_latex_macros
sage: 
sage_configurable_latex_macros.remove("\\newcommand{\\Bold}[1]{\\mathbf{#1}}")
If I now type "html(x)", then the result is "\[x\]", instead 
of "\[\newcommand{\Bold}[1]{\mathbf{#1}}x\]".

If that gives errors due to a bad definition of "\\Bold", then maybe you 
should also do:
sage: 
sage_configurable_latex_macros.append("\\renewcommand{\\Bold}[1]{\\mathbf{#1}}")

On Sunday, December 19, 2021 at 7:34:13 AM UTC-7 AlbertHilb wrote:

> Hi all. 
>
> I noted every command LaTeX output is prefaced by the definition of a 
> \Bold newcommand even if the \Bold command is not really used in the 
> output.
> For example, if I type "1" and press return I get
>
> \newcommand{\Bold}[1]{\mathbf{#1}}1
>
> Is this intended?
>
> Among other things, the presence of the newcommand definition prevent me 
> from using KaTeX as LaTeX renderer because it complains \Bold command 
> already exists and \renewcommand should be used to redefine it.
>
> I use SageMath 9.4 binary for Ubuntu 20.04 64 bit with jupyterlab 3.2.4 as 
> frontend.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/d11dda6a-0d10-4b68-a2ea-edcba6043ddan%40googlegroups.com.