Ask Your Question
0

Add a text in Latex in front of a result

asked 2019-09-19 19:31:46 +0200

Cyrille gravatar image

updated 2020-04-23 05:23:13 +0200

%display latex var('A, x, y, l, alpha, beta, R, p_x, p_y'); U= Ax^(alpha)y^(beta); show(U)

this print U. But I would like to see "U(x) = ..." in a larger font that the standard one which is too small printed on a large device. More generaly , I would like to print some sentences before to disply a result

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2019-09-19 21:12:45 +0200

Emmanuel Charpentier gravatar image

That's two (very different) questions in one.

1) To concatenate various $\LaTeX$ (math) elements, the LatexExp function is well suited. In your case,

LatexExpr("U(x)="+latex(U))

yelds:

$$U(x)= A x^{\alpha} y^{\beta}$$.

2) "I would like to print some sentences before to display a result".

Your best bet is to write your text in $\LaTeX$, using Sagetex macros to insert relevant Sage snippets and their results.

This needs some learning ; I'd recommend reading "The not so short introduction to $\LaTeX2\epsilon$" tor deciding if $\LaTeX$ is for you. If you intend to spend more than a few weeks in your life using mathematics or writing structured texts (i. e. witth explicit outlines, cross-references and/or citations, etc..), it is probably worth it.

An alternative solution is to use Sage's Jupyter notebook. This will allow you to intersspede math or graphics "cells" between tet cells, that can receive some Markdown formatting. Markdown is much lighter than $\LaTeX$, therefore faster to learn, and might be sufficient for quick n' dirty tasks. But its possibilities are much more limited.

edit flag offensive delete link more

Comments

I use BakomaTeX since 20 years and before other Latex systems. My question was only for a notebook presentation

Cyrille gravatar imageCyrille ( 2019-09-19 22:22:53 +0200 )edit

I use BakomaTeX since 20 years and before other Latex systems. My question was only for a notebook presentation

You didn't specify that in your question.My answer stands.

Since you already know $\LaTeX$, you might try to (ab)use LatexExpr to create a minipage rendering what you want. But I have trouble seeing the point...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2019-09-20 10:02:25 +0200 )edit
1

answered 2020-04-23 14:59:21 +0200

Juanjo gravatar image

updated 2020-04-23 16:20:28 +0200

You may use something like this:

var('A, x, y, alpha, beta')
U = A*x^(alpha)*y^(beta)
text = fr"""
<h3>This is a title</h3>
<p>This is some text explaining several
interesting things. <strong>HTML</strong> can be used
to format these lines.</p>
<p>Now we write an inline mathematical expression
$U(x,y)={latex(U)}$, as well as a displayed one:
$$\frac{{\partial^2 U}}{{\partial x \partial y}}(x,y)=
  {latex(diff(U,x,y))}$$</p>
"""
show(html(text))

The result is similar to:


This is a title

This is some text explaining several interesting things. HTML can be used to format these lines.

Now we write an inline mathematical expression $U(x,y)=A x^{\alpha} y^{\beta}$ as well as a displayed one: $$\frac{{\partial^2 U}}{{\partial x \partial y}}(x,y)=A \alpha \beta x^{\alpha - 1} y^{\beta - 1}$$


edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-09-19 19:31:46 +0200

Seen: 1,199 times

Last updated: Apr 23 '20