Questions tagged [sagetex]
SageTeX is a package enabling Sage mathematics software to be used from within LaTeX documents in a wide variety of ways, similar to Sweave in R.
112
questions
3
votes
2
answers
147
views
Best Practices for Integrating Computer Algebra Systems (CAS) into LaTeX Documents
I am currently working on enhancing my LaTeX documents to involve complex mathematical equations. Managing these equations manually often leads to errors, especially when changing dependent equations ...
1
vote
1
answer
87
views
Nesting sagetex in animate for tikz (and asymptote) gif - possible or impossible?
I am running Windows 10 or 11 (I don't know), have WSL2 running on my system - Ubuntu distribution, and have SageMath downloaded on my computer. I have successfully established contact between all ...
1
vote
1
answer
42
views
Issue in sagetex with \sagestr
I'm trying to create some maths exercises with SageTeX.
Here's my code:
\documentclass{article}
\usepackage{sagetex}
\begin{document}
\begin{sagesilent}
x=var("x")
A(x)=(x-2)^2-36
B(x)=1-(2*...
1
vote
3
answers
164
views
Why does \hfill work in math mode but not \vfill?
This example writes three lines, each of which have four numbers separated by an equal length of space.
\documentclass{article}
\begin{document}
\noindent
\thispagestyle{empty}%
1\hfill2\hfill3\hfill4\...
0
votes
0
answers
32
views
SageTeX does not work when TABs are used as indents
I wrote two practically identical files that use SageTeX to determine whether a positive integer is odd or even. The first example uses tabs for indentation.
\documentclass{article}
\usepackage{...
1
vote
0
answers
142
views
I installed vanilla TeX Live on Debian but apt still tries to install "texlive-" packages although I tricked packages
I had TeX Live 2022 installed and upgraded to TeX Live 2023. I followed this wonderful guide:
Remove old installation
sudo apt-get purge texlive*
sudo rm -rf /usr/local/texlive/*
sudo rm -rf ~/....
0
votes
0
answers
55
views
Sagetex ignores indents if they are done in tabs insteads of spaces - how to make it recognize tabs?
The following examples are visually identical code. The only difference is that the indents were done differently. Four spaces were used in the first and a tab was used in the second.
1.
\...
0
votes
0
answers
21
views
How to customize behavior of typeset button in GUI editor?
I use TeXworks to turn tex into pdf. There are some cases where I need to compile twice in order to get a complete document, such as referencing a labeled section. Also there are even more complex ...
3
votes
1
answer
174
views
Sage is unable to process .sagetex.sage file created from sagetex
This is a simple .tex file that defines a sage function p(n) that returns 2 raised to the power of n.
\documentclass{article}
\usepackage{sagetex}
\begin{document}
\begin{sagesilent}
def p(n):
...
2
votes
2
answers
64
views
Defining and calling a function in sagetex not working as expected
In the code below I use sagetex to define a function f(n) that returns the nth fibonacci number. I used sagesilent so that the contents of the function are not typeset. Then I call and print the value ...
0
votes
0
answers
72
views
Having trouble with sage
I don't seem to be able to produce a .sty file following the instructions from links given to me in a previous post,
my log file gives me this:
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (MiKTeX ...
1
vote
2
answers
259
views
Trouble using Cocalc with Latex
I am having trouble running the following code, which works in CoCalc but will not work in Latex, even though it is the tex. output not sure what I am doing wrong.
\documentclass[border=1cm]{article}
\...
0
votes
0
answers
85
views
Can print SageMath logo as text in LaTeX?
I know we could use \LaTeX{} to print its logo in text in LaTeX. I wonder whether we can do the same thing for SageMath?
0
votes
1
answer
67
views
Use foreach (pgf) in an itemize environment with sagetex
I want to generate calculations randomly using sagetex, trying to have the simplest code possible. I ended up testing this, with pgf :
\begin{sagesilent}
from random import sample
def alea(n, max):
...
0
votes
2
answers
78
views
Write the result (a fraction) of a calculation with sagetex
I made this code to add two random fractions, and calculate the result with sage, but I don't know how to make the result appear with the form \displaystyle\dfrac{}{}
\begin{sagesilent}
output = r&...
3
votes
0
answers
870
views
How to use sagetex on Overleaf
I know I can download sagetex package from their website and after taking few steps: installing Sagemath, routing sagetex files to Tex, and etc, I can directly run Sage while writing on my tex (or ...
1
vote
0
answers
173
views
LyX and Sagemath: Can't update/export from file using Sage module
I have started to use LyX recently and enjoyed it very much. I became very interested in the possibility of integrating Sage(math) commands into the document. But then I became stuck, unable to export ...
1
vote
1
answer
176
views
Workflow for automatically running sagetex in VSCode
Notes
This is my first post here; however, I have used the answers from here countless times.
I am definitely a beginner with command line/terminal stuff.
I would say I am pretty literate with LaTeX, ...
4
votes
2
answers
496
views
How to Plot General Form of a Linear Regression
I attempted to use both Mathcha which is an online website that assists in constructing topological diagrams and plots and I also tried to use Sage, in order to plot this linear regression figure ...
1
vote
1
answer
134
views
Handling the numerical output of SageTeX with siunitx
Which one of the three methods below is correct to handle the numerical output of sagetex with siunitx? and how to do it correctly?
\documentclass{article}
\usepackage{sagetex,siunitx,mathtools}
\...
2
votes
1
answer
181
views
Automatically obtaining QPA quivers in tikz via Sage
I use the GAP-package QPA to obtain quivers (which are just directed graphs) and the QPA-output of a quiver looks for example as follows:
["v1","v2","v3","v4",&...
0
votes
0
answers
207
views
Impossible to run the command: sage "Sage-example".sagetex.sage (Windows 10)
Good evening guys.
I've a big problem, as to simplify my school report, and don't do stupid mistakes while copy pasting some equations, I decided to try SageTex, and I've been struggling to make it ...
1
vote
0
answers
54
views
%time inside sagecommandline environment
I want to show how to measure time with sage, sagetex and the environment sagecommandline.
Here is a minimal example:
\documentclass[a6paper,DIV=16]{scrartcl}
\pagestyle{empty}
\usepackage{sagetex}
% ...
0
votes
1
answer
228
views
sagetex linebreak
When using the environment sagecommandline of sagetex with long number output, how can I get automatic line breaks?
I already tried to change sagetex.sty (putting breaklines=true at several places), ...
1
vote
1
answer
378
views
sagetex/arara: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
Following up this answer, I have the following error in the arara's log file
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes
in position 2-3: truncated \UXXXXXXXX escape
when ...
3
votes
0
answers
210
views
Texmaker configuration and SageTex
I recently installed SageMath on my linux and tried SageTex on Texmaker as follows:
run pdflatex on Texmaker, run load("example.sagetex.sage") from the build folder with Sage,
and run ...
1
vote
1
answer
415
views
How to automatically ask tikz to produce the coordinates and plot the graph from adjacency matrix
I am curious about the following:
I have an adjacency matrix of a graph of order 36.
It is given by
[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,0,1,0,1,0,1,0,1,0,1,0,...
1
vote
0
answers
133
views
How to plot graphs in Latex using sagetex
Now I have got the file sage-plots-for-example.tex in sage that contains all the plots. Do I also have to put all these .eps and .png into the same folder as the tex file?
0
votes
0
answers
400
views
How to use sagetex?
I am trying to use sagetex. Now in the console in sage it is written:"Sage processing complete. Run LaTeX on Beiapiel5.tex again." But when I compile the latex code again nothing happens. ...
1
vote
1
answer
179
views
\sagestr does not produce plots and sabotages others
For the sake of illustration, I want to plot three functions:
linear with direct \sageplot invocation,
quadratic with \sagestr
and sinusoidal with \sageplot
However, it seems that the \sagestr does ...
1
vote
0
answers
197
views
Eigenvalue in Sagemath [closed]
I tried to obtained the eigenvalues of the matrix below using
sagemath;
sage: var('a b c d e f g h i j k l m n p q r s t u v')
(a, b, c, d, e, f, g, h, i, j, k, l, m, n, p, q, r, s, t, u, v)
sage: m ...
1
vote
1
answer
78
views
sagetex not drawing pictures
Maybe someone aldready asked this, but I have the following problem.
I tried to compile an example I found here https://tex.stackexchange.com/a/483113/217249. I don't get any errors. I have sage ...
0
votes
2
answers
195
views
How to execute SageTeX code multiple times with \loop?
I got the following errors when compiling the following MWE. How to fix it?
Paragraph ended before \verbatim@ was complete. ...
First MWE
\documentclass{article}
\usepackage{sagetex}
\newcount\i
...
0
votes
1
answer
109
views
How to setup TeXnicCenter for compiling SageTeX-based input files?
Having found the solution through a dramatic struggle, I think I need to rephrase the question. Hopefully it is very useful for others with the same issue, nameely:
"How to setup TeXnicCenter for ...
0
votes
1
answer
363
views
sagetex in texstudio : define a new build tool
I am using latex and Sage (and sagetex) through TeXstudio and the terminal. I would like to have a build sequence that would do all the compilations with one signle button. Something like wha tis ...
0
votes
0
answers
50
views
sagetex and mcexam
I would like to use mcexam and sagetex together. I managed to make things almost work. Well, I have the expected output, but I have too many errors, and don't see where do they come from. Here is my ...
0
votes
1
answer
226
views
How do I show Sage results computation in my LaTeX file? [closed]
I am new to SageMath so I apologize in advance if this question is not exactly appropriate for this site but since I don't really have any other way to know the answers, I 'll ask it anyway.
(I am ...
1
vote
2
answers
96
views
passing mathematical function to sage function in sagetex
Would some body please help me in getting the plots, I have tried many things, like creating function('f') and then passing it like Q1 = question(1, f(x+1)) but the thing that only works is: output += ...
1
vote
2
answers
273
views
SageTeX for posets
One can use SAGE to get a LaTeX output for posets. For example entering
u=posets.BooleanLattice(4)
print(display(u),print(latex(u)))
in the sage cell (https://sagecell.sagemath.org/) will display ...
2
votes
1
answer
347
views
latex(VAR) command converts other concatenated strings into mathemode when latex displays it
Using sagetex in latex; it appears that using the latex() command converts any concatenated strings to that term into math-mode, rather than strings. See the MWE below:
\documentclass{article}
\...
4
votes
2
answers
211
views
SageTeX: 1000sep for sage-calculated number (siunitx?)
How to add a '1000 sep' on i.e. \sage{2^333}?
\documentclass{report}
\usepackage{sagetex}
\usepackage{siunitx}
\sisetup{group-separator = \text{\,}}
\begin{document}
Works: \num{9000123}
\begin{...
4
votes
1
answer
1k
views
SageTeX: How to run Sage in the command line
The normal run of a tex-file which contains sagetex, say
\documentclass{report}
\usepackage{sagetex}
\begin{document}
\sage{2^1234}
\end{document}
is
pfdlatex example.tex
sage example.sagetex....
7
votes
1
answer
371
views
arara: sage - A Sage(math)-rule for arara
Completely edited!
The normal run of a tex-file which contains sagetex, say
\documentclass{report}
\usepackage{sagetex}
\begin{document}
\sage{2^1234}
\end{document}
is
pfdlatex example.tex
...
2
votes
2
answers
283
views
Number formatting in PythonTeX with `sage` family
I am trying to get a special number formatting in pythontex with sage family but it doesn't work.
Here is an example which shows how it should look like and what I tried so far.
How can I make it ...
2
votes
1
answer
236
views
How to display the output of a loop in SageTex
I am preparing a class on Sage, and i want the following code on my document.
\documentclass{article}
\usepackage{sagetex}
\begin{document}
\begin{sagecommandline}
sage: for i in range(0,4):
....: ...
1
vote
0
answers
99
views
String check against a sage command, issue of expansion order? [closed]
I am trying to write a macro to do a conditional check against two strings. The problem I'm having is that I want to check the output of a \sage command and do a string comparison without expanding ...
0
votes
0
answers
64
views
SageTex on PC MikTeX issue
I am trying to run the LaTeX/SageTeX code presented in John Palmieri answer. The file compiles, but the output PDF is missing all mathematical Sage answers and yet there are no error messages (e.g, no ...
7
votes
4
answers
3k
views
How to use sagetex package
I'm trying to use sagetex package,
but then I found this kind of problem when running the code,
may anyone help?
Here is the code:
\documentclass{article}
\usepackage{sagetex}
\begin{document}
...
0
votes
1
answer
224
views
Directly input a sage file in a sagetex block
Is there a command similar to \lstinputlisting with sagetex, which would import directly a .sage file in the relevant block, and have it evaluated by sagetex?
If not, how would one write such a ...
0
votes
0
answers
148
views
SageTex installed, but not compiling
I've installed SageTex in my texmf tree. Latex is running using WinEdt and appears to see the style file, as I have the output files example.sagetex.sage from example.tex. My issue is the second ...