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.Thu, 01 Apr 2021 04:51:59 +0200Is there a way to specify that `\sqrt{}`s should be avoided in favor of exponents when using the `latex()` function?https://ask.sagemath.org/question/56447/is-there-a-way-to-specify-that-sqrts-should-be-avoided-in-favor-of-exponents-when-using-the-latex-function/**Background:** I'm using Sage to do some computations for a LaTeX document I'm preparing. My preferred approach is to include the script directly in the markup, using SageTeX to parse the code and print the results in TeX-readable form. The computations relevant to this question result in a longish list of numbers, most of which are of the form `something*sqrt(pi)`. My intention is to include this list in a table, which I'm constructing using a little Python script I wrote. The script takes a lists of TeX-formatted strings and returns a string with the markup for a table with those strings as rows.
**The problem:** When I call the `latex()` function on the list elements to prepare them for serialization into the table, I get results like this: `\frac{3}{7} \sqrt{7} \sqrt{\pi}`. This is not at all how I would type this if I were "TeXifying" it myself---I'd much prefer `\frac{3}{7} \sqrt{7 \pi}`. Even `\frac{3}{7} (7 \pi)^{1/2}` would be preferable IMO.
Obviously, I could just generate a table and then copy-paste it into my document, tweaking where necessary. I could also try writing a little Python function to massage the output into the desired form. But it made me wonder if there is any way to control or customize the output of `latex()` beyond the basic delimiter-setting functions I found in the docs, and I think that'd be worthwhile to know in any event.
**Specific question:** Is there a way to "tell" Sage to avoid using `\sqrt{}` in its LaTeX output in favor of fractional exponents?perfectly_oddThu, 01 Apr 2021 04:51:59 +0200https://ask.sagemath.org/question/56447/how to set latex options on graph to make them ultra small ?https://ask.sagemath.org/question/29488/how-to-set-latex-options-on-graph-to-make-them-ultra-small/I am currently playing with functions indexed by unlabeled graphs. The following method (belonging to my parent class which models linear combinations of graphs) tells my parent how to print basis element indexed by a graph m (m is in fact an integer vector modeling a graph up to isomorphism).
def _latex_term(self, m):
r"""
"""
G = m.to_graph()
opt = G.latex_options()
opt.set_option('tkz_style', 'Simple')
opt.set_option('vertex_labels', False)
opt.set_option('scale', 0.25)
opt.set_option('vertex_size', 0.0)
return '\mathcal{M}_{' + latex(G) + '}'
I tried to set the option 'vertex_size' to zero but the size of the vertex was not affected. I realize that some combinations of options can rapidly become incoherent. Currently, I do not manage to do smaller than in the copy-pasted proposition of code.
I just want a very small (but readable) unlabeled graph.nborieFri, 18 Sep 2015 19:06:18 +0200https://ask.sagemath.org/question/29488/