# Revision history [back]

1) Yes in a Jupyter notebook. See an example below.

2) You have already asked something similar in this other question. 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]
sth = "style='color: white; background: black'"
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:

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:

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.

1) Yes in a Jupyter notebook. See an example below.

2) You have already asked something similar in this other question. 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]
sth = "style='color: white; background: black'"
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:

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:

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.