ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 11 Dec 2020 02:47:40 +0100color in latex...https://ask.sagemath.org/question/51717/color-in-latex/1) Is it possible to use text colors in `show` specifically with `LatexExpr`.
2) in mathematica, it is possible to insert a result in a text cell. Is it possible in SM markdown ?
3) same question in an HTML table ? SM tables are too basic
4) Need an exemple to localy change the background color of a result.
Thanks by advanceWed, 03 Jun 2020 08:26:15 +0200https://ask.sagemath.org/question/51717/color-in-latex/Comment by slelievre for <p>1) Is it possible to use text colors in <code>show</code> specifically with <code>LatexExpr</code>.</p>
<p>2) in mathematica, it is possible to insert a result in a text cell. Is it possible in SM markdown ?</p>
<p>3) same question in an HTML table ? SM tables are too basic</p>
<p>4) Need an exemple to localy change the background color of a result.</p>
<p>Thanks by advance</p>
https://ask.sagemath.org/question/51717/color-in-latex/?comment=54633#post-id-54633For short we say Sage.Fri, 11 Dec 2020 02:47:40 +0100https://ask.sagemath.org/question/51717/color-in-latex/?comment=54633#post-id-54633Comment by Emmanuel Charpentier for <p>1) Is it possible to use text colors in <code>show</code> specifically with <code>LatexExpr</code>.</p>
<p>2) in mathematica, it is possible to insert a result in a text cell. Is it possible in SM markdown ?</p>
<p>3) same question in an HTML table ? SM tables are too basic</p>
<p>4) Need an exemple to localy change the background color of a result.</p>
<p>Thanks by advance</p>
https://ask.sagemath.org/question/51717/color-in-latex/?comment=51728#post-id-51728"SM"=Sagemath, I suppose ? This abbreviation is a tad ambiguous (unless you really want to suggest that Sagemath==SM=sadomasochism ? This would be questioned by some...).Wed, 03 Jun 2020 19:07:09 +0200https://ask.sagemath.org/question/51717/color-in-latex/?comment=51728#post-id-51728Comment by Cyrille for <p>1) Is it possible to use text colors in <code>show</code> specifically with <code>LatexExpr</code>.</p>
<p>2) in mathematica, it is possible to insert a result in a text cell. Is it possible in SM markdown ?</p>
<p>3) same question in an HTML table ? SM tables are too basic</p>
<p>4) Need an exemple to localy change the background color of a result.</p>
<p>Thanks by advance</p>
https://ask.sagemath.org/question/51717/color-in-latex/?comment=51750#post-id-51750I have had also this idea but I was wondering that I was alone to have a bad spirit. I was using SM as MA for Mathematica. However it seems we need an acronym for Sagemath.Thu, 04 Jun 2020 07:13:00 +0200https://ask.sagemath.org/question/51717/color-in-latex/?comment=51750#post-id-51750Answer by Juanjo for <p>1) Is it possible to use text colors in <code>show</code> specifically with <code>LatexExpr</code>.</p>
<p>2) in mathematica, it is possible to insert a result in a text cell. Is it possible in SM markdown ?</p>
<p>3) same question in an HTML table ? SM tables are too basic</p>
<p>4) Need an exemple to localy change the background color of a result.</p>
<p>Thanks by advance</p>
https://ask.sagemath.org/question/51717/color-in-latex/?answer=51738#post-id-517381) Yes in a Jupyter notebook. See an example below.
2) You have already asked something similar in [this other question](https://ask.sagemath.org/question/51344/code-and-markdown-cell/). I think that the answers there also apply here.
3) Certainly you can put results inside HTML tables generated by code cells. Example:
Degrees = pi/180
angles = [0, 30, 45, 60, 90]
st = "style='text-align: center'"
tb = f"""
<table style='width:50%'>
<tr style='color: white; background: black'>
<th {st}>Angle</th>
<th {st}>Sinus</th>
<th {st}>Cosinus</th>
<th {st}>Tangent</th>
</tr>
"""
for a in angles:
tb += f"<tr><td {st}>${latex(a)}$</td>"
tb += f"<td {st}>${latex(sin(a*Degrees))}$</td>"
tb += f"<td {st}>${latex(cos(a*Degrees))}$</td>"
tb += f"<td {st}>${latex(tan(a*Degrees))}$</td></tr>"
tb += "</table>"
show(html(tb))
To understand the code, google for Python f-string. I provide a screen capture of the result:
![image description](/upfiles/15912080291216253.png)
4) *Voici un exemple*:
Degrees = pi/180
angle = 30
st = "style='background: black; color: white; padding: 0.5em'"
message = fr"The sinus and cosinus of ${latex(angle)}ยบ$ are "
message += fr"<span {st}>${latex(sin(angle*Degrees))}$</span> and "
message += fr"<span {st}>${latex(cos(angle*Degrees))}$</span>"
show(html(message))
And the corresponding screen capture:
![image description](/upfiles/1591208078506611.png)
As you can see, I don't use `LaTeXExpr`, but `latex`. Likewise, formulae are coloured as a whole via CSS. If you need to change the color of only a part of an expression, then you should use the `\color` macro.Wed, 03 Jun 2020 20:27:46 +0200https://ask.sagemath.org/question/51717/color-in-latex/?answer=51738#post-id-51738Answer by Emmanuel Charpentier for <p>1) Is it possible to use text colors in <code>show</code> specifically with <code>LatexExpr</code>.</p>
<p>2) in mathematica, it is possible to insert a result in a text cell. Is it possible in SM markdown ?</p>
<p>3) same question in an HTML table ? SM tables are too basic</p>
<p>4) Need an exemple to localy change the background color of a result.</p>
<p>Thanks by advance</p>
https://ask.sagemath.org/question/51717/color-in-latex/?answer=51730#post-id-517301) Yes in the (Jupyter) notebook (Mathjax happens to understand `\color`...) . No in command-line (or `emacs`), unless you add the relevant `\usepackage{xcolor}` or analogous to the relevant latex preamble (see the docs).
2) Not as far as know. This is much better achieved in a SageTeX (or `org-mode` + `sage-shell-mode` in `emacs`) document (with the right modules in the preamble). Again, see the SageTeX documentation and example.
3) This might be doable by writing Sage code to spit out HTML results. ISTR that Sage has some relevant functions for that, but never used it. See the docs, again. An alternative is `org-mode` with HTML output.
4) is highly dependent of your output mode. There might be some Methjax happenstance, I dunno. See the relevant docs.
sage: r('library("fortunes")')
[1] "fortunes" "tools" "stats" "graphics" "grDevices" "utils"
[7] "datasets" "methods" "base"
sage: r('fortune("RTFM")')
This is all documented in TFM. Those who WTFM don't want to have to WTFM again
on the mailing list. RTFM.
-- Barry Rowlingson
R-help (October 2003)
Wed, 03 Jun 2020 19:28:37 +0200https://ask.sagemath.org/question/51717/color-in-latex/?answer=51730#post-id-51730Comment by ortollj for <p>1) Yes in the (Jupyter) notebook (Mathjax happens to understand <code>\color</code>...) . No in command-line (or <code>emacs</code>), unless you add the relevant <code>\usepackage{xcolor}</code> or analogous to the relevant latex preamble (see the docs).</p>
<p>2) Not as far as know. This is much better achieved in a SageTeX (or <code>org-mode</code> + <code>sage-shell-mode</code> in <code>emacs</code>) document (with the right modules in the preamble). Again, see the SageTeX documentation and example.</p>
<p>3) This might be doable by writing Sage code to spit out HTML results. ISTR that Sage has some relevant functions for that, but never used it. See the docs, again. An alternative is <code>org-mode</code> with HTML output.</p>
<p>4) is highly dependent of your output mode. There might be some Methjax happenstance, I dunno. See the relevant docs.</p>
<pre><code>sage: r('library("fortunes")')
[1] "fortunes" "tools" "stats" "graphics" "grDevices" "utils"
[7] "datasets" "methods" "base"
sage: r('fortune("RTFM")')
This is all documented in TFM. Those who WTFM don't want to have to WTFM again
on the mailing list. RTFM.
-- Barry Rowlingson
R-help (October 2003)
</code></pre>
https://ask.sagemath.org/question/51717/color-in-latex/?comment=53938#post-id-53938the syntax of the Latex \color statement (not quite obvious):
show(LatexExpr( r" {\color{Red} {tagada}}"))Fri, 16 Oct 2020 07:01:58 +0200https://ask.sagemath.org/question/51717/color-in-latex/?comment=53938#post-id-53938