
Embedded latex not formatting correctly
Reported by Richard Funderburk | July 2nd, 2009 @ 06:53 AM
If there are no spaces before and after '=' in a latex style equation the output is incorrect.
==\ensuremath{y = \sqrt{4}}==
generates the latex code:
\ensuremath{y = \sqrt{4}}
But:
==\ensuremath{y=\sqrt{4}}==
generates the latex code:
==\textbackslash{}ensuremath{y=\textbackslash{}sqrt{4}}==
Comments and changes to this ticket
-
stef October 14th, 2010 @ 05:45 AM
- Tag changed from latex to latex, notextile
- Milestone order changed from 0 to 0
The prob looks more general to me, the '==' operator does not work
when one or more spaces follow opening initial '==' or occur immediately
before the closing '=='.== This is not strong but flanked by asterix ==
to_html produces:
== his is not strong but flanked by asterix ==
to_latex:
== \textbf{his is not strong but flanked by asterix} ==
I can't figure out what I need to override at present to correct this.
where is the code handling the '==' ... '=='? I just see:def ignore(opts)
opts:[text] end
alias_method :notextile, :ignorein base.rb.
Any pointers??
-
stef October 14th, 2010 @ 07:00 AM
Ok, the parsing seems to be in the C-code, so here a fix
avoiding going near that:module RedCloth::Formatters::LATEX # Redefine empty before_transform in Base.rb to strip # the unwanted spaces in Latex convertions. def before_transform text.gsub!( /==\s*(.*?)\s*==/, '==\1==' ) end end
Note - the same move for the html formatter did not work,
but then that Formatter already re-implements the empty
base class function ... not sure if that's the reason. -
stef October 14th, 2010 @ 09:05 AM
... and yet another update: text inside each == .. == needs to be escaped:
module RedCloth::Formatters::LATEX # Redefine empty before_transform in Base.rb to strip # the unwanted spaces in Latex convertions. def before_transform text.gsub!( /==\s*(.*?)\s*==/ ) do |m| m = escape "==#{$1}==" end end end
-
stef October 14th, 2010 @ 09:10 AM
I think there's a dilemma here:
In this example we'd need to escape:
== expect asterisk in my pdf ==
In this example would not escape:
== \textbf{my latex code} ==
Nice one to sort out!
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
RedCloth is a Ruby library for converting Textile into HTML