Ask Your Question
1

make sage use \dfrac instead of \frac

asked 2019-07-16 02:49:00 +0200

Orange gravatar image

For example:

Is it possible to make latex( (2*x+3) / (2*x) ) return \dfrac{2 \, x + 3}{2 \, x} instead of \frac{2 \, x + 3}{2 \, x} ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-07-16 13:03:08 +0200

dan_fulea gravatar image

Here is a hack for this, use the string s = latex( (2*x+3) / (2*x) ) and replace in it each occurrence of \frac with \dfrac:

sage: s = latex( (2*x+3) / (2*x) )

sage: s.replace( r'\frac', r'\dfrac' )
'\\dfrac{2 \\, x + 3}{2 \\, x}'
sage: print s.replace( r'\frac', r'\dfrac' )
\dfrac{2 \, x + 3}{2 \, x}

sage: import re
sage: re.sub( r'\frac', r'\dfrac', s )
'\\frac{2 \\, x + 3}{2 \\, x}'
sage: print re.sub( r'\frac', r'\dfrac', s )
\frac{2 \, x + 3}{2 \, x}
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-07-16 02:49:00 +0200

Seen: 117 times

Last updated: Jul 16 '19