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.Mon, 08 Mar 2021 14:06:24 +0100Customizing sage objects latex behaviourhttps://ask.sagemath.org/question/56055/customizing-sage-objects-latex-behaviour/I'm a recent user of Sage, and am really enjoing it. I use it through jupyter, mixing a lot of markdown/latex and computations.
After this initial period, I have one major annoyance:
In some cases it would be really nice to be able to modify the latex representation of built-in objects.
I am fully aware one can easily create functions that create the desired latex from an object, but this requires you to type this function every time the given datatype is in play which is impractical. This becomes even worse when using the %display text latex cell magic.
I have two concrete examples to show what kind of behaviour change I'm after:
1. Typeset vectors as column vectors rather than row vectors.
2. Typeset RealField numbers similar to what you would get from 1.23.str(skip_zeroes=True, truncate=True)
I have googled quite a bit but always come up short, but I am new to sage and might be missing something.
Some select elements can be configured, such as the RealField.scientific_notation method or the latex.matrix_delimiters, but wrapping or modifying the _latex_ method or something to the same effect would be much more flexible, albeit one could argue it would also be more _hacky_ ;)
Thanks for your help!Felix BlixMon, 08 Mar 2021 14:06:24 +0100https://ask.sagemath.org/question/56055/Typesetting in latex giving this error.https://ask.sagemath.org/question/51581/typesetting-in-latex-giving-this-error/ if i remove typeset' latex' everything is working.jadhavboysWed, 27 May 2020 14:19:42 +0200https://ask.sagemath.org/question/51581/Can't get typeset equations. No MathJax?https://ask.sagemath.org/question/38441/cant-get-typeset-equations-no-mathjax/ I installed Sage yesterday on Ubuntu. I downloaded the latest version from the website. When I enter formulas I just get an ASCII text. I thought that Sage was supposed to use MathJax to produce nice-looking typset formulas, but I see nothing of the sort. I have spent a lot of time searching for a solution and found nothing. I recompiled Sage, but that made no difference. The Sage distribution seems to include MathJax,
% cd path/to/sage
% find . -name mathjax
./local/share/mathjax
./local/share/jupyter/nbextensions/mathjax
./local/lib/python2.7/site-packages/sagenb/data/mathjax
./build/pkgs/mathjax
I have looked through the documentation and through the UI and found nothing. Can someone please tell me what I need to do to make Sage look decent? I don't know if it matters, but I want to use Maxima. But the problem appears with the plain Sage backend too.
Cheers,
Daniel.DanielCSat, 29 Jul 2017 21:25:37 +0200https://ask.sagemath.org/question/38441/complex normhttps://ask.sagemath.org/question/38289/complex-norm/As a newbie, I must be missing something, but here is the question:
With this setup:
var('a', domain=CC)
a.norm()
a.norm().simplify()
The last line displays as a^2, but should be |a|^2 .
What am I missing?normvcrMon, 17 Jul 2017 22:33:41 +0200https://ask.sagemath.org/question/38289/typeset complex norm is missing absolute valuehttps://ask.sagemath.org/question/38288/typeset-complex-norm-is-missing-absolute-value/ As a newbie, I must be missing something, but here is the question:
With this setup:
var('a', domain=CC)
a.norm()
a.norm().simplify()
The last line displays as a^2, but should be |a|^2 .
What am I missing?normvcrMon, 17 Jul 2017 22:32:20 +0200https://ask.sagemath.org/question/38288/Automatic typesetting in Jupyterhttps://ask.sagemath.org/question/31710/automatic-typesetting-in-jupyter/When using the Jupyter notebook I always have to type
%display typeset
as my first line so as to enable typesetting.
Is there any way to avoid it and have the answers typeset automatically?
I'm using sagemath-upstream-binary from the PPA and Linux Mint 17.3 Cinnamon.marmistrzSun, 20 Dec 2015 13:18:13 +0100https://ask.sagemath.org/question/31710/Sage-mode typesetting problemhttps://ask.sagemath.org/question/26632/sage-mode-typesetting-problem/I am trying to start using emacs with sage-mode.
After editing .emacs file to enable sage-mode and typsetting, I can see that even though the shell is working, the 'sage-view' option is not working propperly.
In example, when typing the following text into the shell:
f(x) = x^2 ; f
The output is :
\newcommand{\Bold}[1]{\mathbf{#1}}x \ {\mapsto}\ x^{2}
I am a completley noob regarding emacs, and I have a feeling that the answer is somewhat very simple, but i couldn't find it on the web =/
Thanks in advance,
David
OaaHFri, 24 Apr 2015 00:01:23 +0200https://ask.sagemath.org/question/26632/typesetting simple nth root using radicalhttps://ask.sagemath.org/question/24836/typesetting-simple-nth-root-using-radical/is there a way to ask sage to typeset $$\sqrt[3]{x}$$ rather than $$x^{1/3}$$
`latex(sqrt(x))` does fine but I cant fingure out the general nth root radical notation command
thxuserXTue, 11 Nov 2014 20:10:50 +0100https://ask.sagemath.org/question/24836/Typesetting Simple Student Worksheet Question & need to defer computationhttps://ask.sagemath.org/question/24637/typesetting-simple-student-worksheet-question-need-to-defer-computation/ I have
eq1=2*(x+10)/5==3*(6-5*x)/7
the command
print latex(eq1)
simplifies the equation to $$\frac{2}{5} x + 4 = -\frac{15}{7} x + \frac{18}{7}$$
is there something like latex(eq1.hold()) that would produce
$$\frac{2(x+3)}{5}=\frac{3(6-5x)}{7}$$
edit:
I must apologize in advanced as my code may seem infantile but I am very new to this and trying to learn. That said, I was able to get something going but it seems to me there must be a million better ways to do this. Can you point me in the right direction to generalize this process and improve this code. Keep in mind the point of this is to write a student worksheet with problem sets and solutions. can be seen here [link text](https://sagecell.sagemath.org/?z=eJydUk2P2jAQvSPxHywXae18LeHrQJuVeqmE1ENBvREOXnDAlbFZ27Rmq_3vHQfYBKRKVS_O8ObNmzfDGIEKJNn-ecOQT05ThCqptSFGH9WGGKY2ek9oRE6pp7Gn9GO3s-EVVDjuvwrrZgSq6BQZ7o5GIZxlWYLjU_ZDC0VwD8fWGVKzCaM0BgRV2iCGhEKgiBMowCD6Lnhn51-VkABTXBFPn_qIS8sRwkqDLSaR1fLohFY2NGL2711QaBHU0X9JC7sIWCM9Rd_NkYf6WiCowwqLovmRGX6QbM0JFjhBWAiBW9gsYLPZDIOjuvEXBu_lL2CHg9GetJaPliwzO0topshGbIWzxYQ2k5xWUPkB5k1ei5_MEOzRCb1iWqPgej5fPviHVdbvdhbZJ_8E0DctT0rvBZMLobZkPg9kaSGzNIKk4yTNaQJRngzr7yDJx00Q-pkrGZB-nUqH16p0kqSDW3oYrD4ExZn5TFzrsnplWRm2_t0-BLfsr8ItlKXklSO3qbxOxbfgoAZ9WRqx3Tn6dic3rNNvPXzxYtmWt834y-Zga-9bDyaiul8c9CNPH4MQKHQ7_CWH-VsTSQv6BY5bkLFhq_xlAMx2P6AWRRu4EodABHok13sgQavEhPecHBVASH0E7-UY1ppXlVgLrhxcXE0aA2mUEngyGTg0s8dn64Q7Ok580acX8xPgjSOSP8LnzLxTOxO7nZ3bS5DLabdjd_oXhIMmHDbhqAnHTTihQeMPn4JaLg==&lang=sage)
ri = lambda x,y: floor(round(random()*(y-x)+x)); #random integer from x to y
ls = [ri(-5,-1),ri(1,3),ri(2,15),ri(2,15)];
rs = [ri(2,10),ri(-3,-1),ri(-6,-2),ri(2,15)];
def texLinearA(t): return "$\\frac{"+str(latex(t[0]))+"\\left("+str(latex(t[1]))+"+"+str(latex(t[2]))+"x\\right)}{"+str(latex(t[3]))+"}$";
def sageLinearA(t): x=var("x"); return t[0]*(t[1]+t[2]*x)/t[3];
eq1 = texLinearA(ls)+"="+texLinearA(rs);
eq2 = sageLinearA(ls)==sageLinearA(rs);
eq3 = eq2*lcm(ls[3],rs[3]);
eq4=eq3-x*eq3.rhs().coefficient(x);
eq5=eq4-(eq4.lhs()).substitute(x=0);
eq6=eq5*(1/eq5.lhs().coefficient(x));
html(eq1);
show(eq2);
show(eq3);
show(eq4);
show(eq5);userXMon, 27 Oct 2014 04:02:29 +0100https://ask.sagemath.org/question/24637/diacritical marks?https://ask.sagemath.org/question/23281/diacritical-marks/How do we do diacritical marks in Sage? They don't work in math mode in LaTeX, so I don't see how to get them in Sage and google doesn't turn up any results more recent than a 2008 complaint. smbelcasTue, 08 Jul 2014 21:55:27 +0200https://ask.sagemath.org/question/23281/Typesetting of help output in notebook?https://ask.sagemath.org/question/10918/typesetting-of-help-output-in-notebook/I am busily getting a brand new ubuntu 12.04 installation up and running, including sage 6.0, which I compiled from source. The only problem I currently have is that in the notebook (running in firefox), outputs of help are not properly typeset: there's overwriting and in general it's impossible to read. I have a java plugin installed (which "about:plugins" shows is there and enabled), and mathematics output displays fine - it's just the help output which doesn't display properly.
What do I need to do to fix this?AlasdairWed, 15 Jan 2014 18:53:54 +0100https://ask.sagemath.org/question/10918/Typesetting environment in notebookhttps://ask.sagemath.org/question/8788/typesetting-environment-in-notebook/I tried to edit the following notebook [here](http://sagenb.org/home/pub/4688/). On editing it seems to have a rich text formatting environment of its own - how do i get it?d3banjanSun, 15 Apr 2012 19:09:11 +0200https://ask.sagemath.org/question/8788/firefox on MS Windows fails to show matrix parentheseshttps://ask.sagemath.org/question/9906/firefox-on-ms-windows-fails-to-show-matrix-parentheses/In our labs we have firefox 19 installed on MS Windows computers. When accessing our sage server and trying to show 3by3 matrices in typeset form, firefox does not show proper parentheses but cryptic symbols (it seems that it fails to use the correct font). Everything works fine if one uses chrome.
Is this a known problem with firefox or a known configuration error on our part?
Thank youAndreasJGWed, 13 Mar 2013 11:13:27 +0100https://ask.sagemath.org/question/9906/Messy typesetting problemhttps://ask.sagemath.org/question/9030/messy-typesetting-problem/If I enter the followng in a sage notebook, the typeset output is correct but for h(r) is unreadable, is there someway to coerce sage to output a reasonable representation?
The desired expression is
$$h(r) = {1\over{r^2 \sqrt{ \frac{1}{b^2} - (1 - \frac{d}{r}) \frac{1}{r^2}}}}$$
f(r) looks good, g(r) is poor and confusing, h(r) is unreadable.
var ('r, b, d')
f(r) = r^2 * sqrt(1/b^2)
print(f)
f.show()
g(r) = r^2 * sqrt(1/b^2 - 1)
print(g)
g.show()
h(r) = 1 / (r^2 * sqrt (1/b^2 - (1 - d/r)*1/r^2))
print (h)
h.show()bobcatMon, 04 Jun 2012 20:06:45 +0200https://ask.sagemath.org/question/9030/Typesetting problems in 5.0 notebookhttps://ask.sagemath.org/question/9012/typesetting-problems-in-50-notebook/I installed Sage 5.0 a few days ago. When I choose the typesetting option in a new worksheet Sage no longer typesets its output in the worksheet itself. In stead, a new window opens for each cell that I evaluate seperately (it's the DVI-viewer on my system that is launched).
The server at alpha.sagenb.org (also a 5.0 notebook server) on the other hand still prettyprints as it used to in 4.7, i.e. in the worksheet itself.
- Could this be a side effect of patching Sage in order to install the single cell server?
- Is there a way to reinstate the correct prettyprinting behaviour?
ThanksDirk DanckaertMon, 28 May 2012 14:54:06 +0200https://ask.sagemath.org/question/9012/How to do latex typesetting in asksagehttps://ask.sagemath.org/question/8160/how-to-do-latex-typesetting-in-asksage/I've seen questions here with typeset expressions. But I can't find out how to do it. I searched for the strings "latex", "markdown", "mathjax", "typesetting" but can't find what I want.
Thanks in advance.omoplataSat, 18 Jun 2011 17:09:58 +0200https://ask.sagemath.org/question/8160/I need help with Sagetex/Sage (normal form&data file useage)https://ask.sagemath.org/question/7739/i-need-help-with-sagetexsage-normal-formdata-file-useage/Greetings!
I have two questions.
The easier is, how can i "ask" Sagemath to numerically calculate, and use normal form. For example i would like to see sqrt{2}/10 as 1.41 * 10^{-1}. It would be useful to always get the same precision. Like 2/10 as 2.00 * 10^{-1}
The harder question is, i want to make several calculations with the same data (about 10-20 lines, every line with 2-4 records). It is possible to copy and paste it every time, but i rather do it an easier way. Is it possible?
DanielDaniel BalogWed, 27 Oct 2010 19:19:13 +0200https://ask.sagemath.org/question/7739/