Loading...

sage-support@googlegroups.com

[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: [sage-support] sagetex - result with comma as decimal separator YvesD Sat Jul 23 03:00:54 2011


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/ <http://yvesdelhaye.be/>

Le binaire divise l'humanité en 10:
Ceux qui le comprennent et les autres.
--------------------------------------

-- 
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org
%%
%% Interro Grav Univ
%%

\documentclass[a4paper,12pt]{article}
\usepackage[francais]{babel}

\usepackage{ucs}
\usepackage[utf8x]{inputenc}
%
\usepackage{sagetex}
\usepackage{answers}        % pour utiliser le module answers (inclusion 
\Newassociation{sol}{Solution}{ans}     % pour définir l'étiquette Solution du 
module answers
\newtheorem{ex}{Exercice}               % pour définir l'étiquette Exercice du 
module answers

% \usepackage{YvCtrl}

\begin{document}
% \thispagestyle{empty}

\begin{sagesilent}
  RYVSci = RealField(10,sci_not=true)
  RYVFrac = RealField(10,sci_not=false)
  #  
  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))}
\end{sagesilent}




\section{Exercices (.../10) :}
  \begin{enumerate}
  \item 
\begin{sagesilent}
mS = 75
mA = 65
dAS = 3
G = 6.67*10^(-11)
\end{sagesilent}
   Calculez la force d'attraction entre 2 élèves de la classe: Serge a une 
masse de $\sage{mS}\!$ kg et Alice une masse de $\sage{mA}\!$ kg. la distance 
les séparant  est de $\sage{dAS}\!$ m.
  \begin{sol}\\ \\
  Solution:\\
   $F_{grav} = G \frac{m_1 . m_2}{R^2}$\\
   $F_{grav} = \sagestr{numprint(RYVSci(G))}(N.m^2/kg^2) \frac{\sage{mS} kg 
\cdot \sage{mA} kg }{(\sage{dAS} m)^2}$\\
%    $F_{grav} =  \frac{6,67 \cdot 7 \cdot 6 }{4} . 10^{-9} N$\\
   $F_{grav} =  \sagestr{numprint(RYVSci(G*(mS*mA)/dAS^2))} N$
  \end{sol}





\end{enumerate}


\end{document}