%!TEX TS-program = sage
\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[francais]{babel}
\usepackage{numprint}
\usepackage{sagetex}
\begin{document}
$\sage{sqrt(3.)}$ % Output is 1.73205080756888, but I would like
1,7320...
$\mathrm{\sage{sqrt(3.)}}$ % Output is 1.73205080756888
$\numprint{12.34567}$ % Ok, outpout is 12,345 67 (with comma)
%$\numprint{\sage{sqrt(3.)}}$ % don't work (bad argument for
numprint)
%\numprint{$\sage{sqrt(3.)}$} % don't work (bad argument for
numprint)
%\numprint{$\mathrm{\sage{sqrt(3.)}}$} % don't work (Generic Error)
\end{document}
Thanks
iDan
Hrm, unfortunately, I don't think this is possible right now.
You can have Sage insert a comma in this way:
sage: x = 1.234
sage: x.str().replace('.', ',')
'1,23400000000000'
so in your TeX file, you could do
$\sage{(sqrt(3)).str().replace('.', ',')}$
which is not very pleasant.
You could define a small function which makes this nicer:
\begin{sagesilent}
def numprint(x):
return x.str().replace('.', ',')
\end{sagesilent}
and then use \sage{numprint(x)}, which is a bit nicer.
Python has a bit of support for locale-dependent printing, which I
should go investigate.
I think the real long-term solution is to change the str() method to
allow commas as the decimal separator and create a configuration option
so that a user can say "use commas always".
Dan
--
--- Dan Drake
----- http://mathsci.kaist.ac.kr/~drake
-------
I've created http://trac.sagemath.org/sage_trac/ticket/8594. Hopefully
we'll include support for this in Sage sometime soon.
And note the difference between $12,13212$ and $12{,}13212$ - the
first one has incorrect spacing in TeX!
Robert
btw: Anyway, we use also comma as separator for decimal places and it
is very uncomfortable in many other situations. My suggestion is to
switch the separator used in France and Czech from comma to dot :)
>
> \begin{sagesilent}
> def numprint(x):
> return x.str().replace('.', ',')
> \end{sagesilent}
>
> and then use \sage{numprint(x)}, which is a bit nicer.
Hi,
Thanks for your suggestion. But,
- this function change the number of significant figures
- \sage{numprint(1.234)} is printed like \texttt{1,234}
Daniel
P.S. : Thanks for the ticket (http://trac.sagemath.org/sage_trac/
ticket/8594)
Hi Robert,
You are right, but there is no difference between $12{,}345$, $
\numprint{12,345}$ and $\DecimalMathComma 12,345$
If you don't have vectors in your document, you can use
\everymath{\DecimalMathComma} and then, $12{,}345$ is the same as
$12,345$.
> <...> My suggestion is to
> switch the separator used in France and Czech from comma to dot :)
Haha, hum... heu... maybe :-) Also
it would be preferable that we all speak chinese,
that we have all blue skin,
that we have all the same religion,
and, finally, that we all use MacOSX :-)
Daniel
sage: locale.localeconv()['decimal_point']
'.'
--Mike
Oscar
Hello,
As a belgian french speaking user of sagetex and a mathematics & physics teacher I needed a "french formated" output.
Indeed,with the above method, the output is then a string. This anoying if you have more complex output (scientific notation, ...)
If you are interested, here is my personnal solution:
It goes through "sagestr":
# Pour adapter la sortie LaTeX de sage aux conventions francaises.
def numprint(x):
x = latex(x)
x = str(x)
x = x.replace('.', ',\!').replace('\\times','\, \ldotp')
x = sage.misc.latex.LatexExpr(x)
return x
#and use \sagestr{numprint(x))}
I join a demo:
demoGenInt000.pdf and demoGenInt000.tex
If you find this useful, thank you to let me know.
(I am new to the group and made a mistake yesterday, sorry for those of you who received this message more than once.)
Yours
--------------------------------------
Yves Delhaye
http://YvesDelhaye.be/
Le binaire divise l'humanité en 10:
Ceux qui le comprennent et les autres.
--------------------------------------