The Docbook XML file generated by a2x contains the Latex math code as CDATA. Unfortunately, when the xhtml format is used with the a2x command the CDATA LaTeX code is purged in the XHTML output document, presumably a consequence of the XSLT process used to convert the Docbook XML to XHTML. This is unfortunate because if the XSLT process preserved this CDATA and tagged it usefully during the tranformation to XHTML at least it could be used by manually inserting the LaTexMathML Javascript or it could be referenced as a link. The same is true if using MathJax. It is the transformation process to XHTML that tosses out the LaTeX code. This does not happen when using dblatex for the conversion because dblatex processes the Docbook XML by converting it to LaTeX then to PDF, so the LaTeX is not lost.
I am not on solid ground with XSLT but it seems to me that the XSL stylesheet being used could be modified to tag the CDATA LaTeX code usefully for XHTML use instead of merely deleting it from the output. I am also not sure that the required <script> reference to the LatexMathML or MathJax Javascripts could be accommodated in some manner by this process or not. The verbatim Javascript code for LatexMathML does not have to be part of the document. It can be referenced as a resource by URL ina <script> element. But at a minimum if the LaTeX code can be preserved and tagged usefully during the transformation process, the the same Asciidoc text file could be used to generate XHTML and PDF using a2x with the LaTeX code preserved in both cases. The worst thing that could happen in this case is that without the <script> reference manually added for LatexMathML or MathJax Javascripts, the LaTeX code would render as plain text, which would be a clue that something more has to be done. As the following reply from Bruce notes using the asciidoc command for XHTML and the a2x command for PDF works as described, but given that the LaTeX code could be processed in either case by the a2x command, then this seems to me to be a subject worth exploring by the Asciidoc developers who are more familiar with the scope and limitations of the XSLT process being used in this case. It could be that this has already been a topic of discussion and been resolved in the form of the present state of affairs. This situation explains why there is Asciidoc 'latexmath' (dblatex and PDF) and 'lathexmathml' (asciidoc, Javascripts, and (X)HTML) references in the User Manual and all the attendant circumlocution necessary. What I am pointing out is that with a some thought and effort, this issue might be resolved to merely Asciidoc 'latexmath' markup and you decide how it will be processed, whether a2x or asciidoc, PDF or (X)HTML and how the output is used and what needs to be done to make is useful. The Asciidoc text source files are yours and if you are happy with unrendered LaTeX code in (X)HTML output, well then that should be an option. You can then do with this as you like. If this means you have to add a little snippet of (X)HTML by manually editing to get something out of it, I say make it so. This is not as elegant or slick as having Asciidoc do all this behind the curtain, but it should work. It is a good thing that Asciidoc does all these neat things automatically, but sometimes this can work against you in that you give up some flexibility. This seems to be one of those instances. There is one point to remember that can't be overcome and that is that dblatex will process math AND text mode LaTeX. The Javascripts only process LaTeX math mode code. So any "one-size-fits-all" paradigm is limited to math expressions. Best wishes, David On May 30, 7:31 pm, Lex Trotman <[email protected]> wrote: > On 31 May 2011 05:53, Bruce Jackson <[email protected]> wrote:> Hi, group, > > Hi Bruce, > > I am no expert on equations but hopefully I can clear up some of your > confusions. > > To answer your last question first, the difference between asciidoc and a2x. > > Asciidoc is a program that translates Asciidoc source to either > Docbook or html or (seehttp://www.methods.co.nz/asciidoc/manpage.html). > > a2x is a wrapper that runs asciidoc to generate docbook then runs a > separate program (xslt, dblatex or FOP) to generate pdf or html or a > bunch of others (seehttp://www.methods.co.nz/asciidoc/a2x.1.html). > > So a2x does define a backend in asciidoc, but its always docbook. So > you have done the right thing using custom attributes (you could use > only one and just select if its defined on not, but two is probably > more descriptive). > > There is one way to generate the same output in html and pdf, that is > the latexmath: macro, if you are using the dblatex toolchain this will > render the equations in pdf, and if you are using the asciidoc html > and define the latexmath attribute asciidoc includes a javascript that > renders the latexmath in the browser. > > See the attached examples created using "a2x latexmath.txt" for pdf > and "asciidoc -a latexmath latexmath.txt" for html. > > That doesn't help you with chunked html though since asciidoc can't > put the javascript in the docbook that gets turned into chunked html > (and the xslt that generates the html wouldn't know what to do with it > if it was included). > > Another option might be to write the equations in mathml and use FOP > which can render mathml as the pdf toolchain, and browsers can also > render it so html should work. I havn't tried this though. (and > mathml is kinda verbose) > > Cheers > Lex > > > > > > > > > I've become a big fan of asciidoc and use it whenever I can. > > > I've spent some time looking through the FAQs, poking through the full > > User's Guide, PowerMan's excellent cheat sheet, and various other > > explanatory pages on the AsciiDoc project website. Possibly due to my > > unfamiliarity with the terms "backends", "filters", "macros" and "pass- > > thru blocks" I have been unable to come up with an easy way to have > > one equation markup generate properly in both HTML and PDF output > > formats. > > > I use a Makefile to generate chunked HTML and PDF; it contains two > > invocations of a2x with custom attributes "formatpdf" or "formathtml" > > which I use inside the source file. (I do this instead of checking the > > "backend" version since a2x doesn't seem to define a "backend"?) > > > make: Orbit.pdf Orbit.html > > > Orbit.pdf: Orbit.txt ${IMAGES} > > a2x -vf pdf -d article -a formatpdf Orbit.txt > > > Orbit.html: Orbit.txt ${IMAGES} > > a2x -vf xhtml -a latex -a formathtml Orbit.txt > > > and the source document Orbit.txt contains, for example, > > > To split the acceleration into two dimensions (X and Y) we can use the > > fact that the portion of force in either dimension is proportional to > > the ratio of distance in that dimension to total distance: > > > // PDF version > > ifdef::formatpdf[] > > [latexmath] > > ++++++ > > \[\frac{F_x}{F} = \frac{R_x}{R}\] > > \[F_x = \frac{R_x F}{R}\] > > ++++++ > > endif::formatpdf[] > > > // HTML version > > ifndef::formatpdf[] > > ["latex","ex3_2a.png",{eqndpi}] > > $\frac{F_x}{F} = \frac{R_x}{R}$ > > > ["latex","ex3_2b.png",{eqndpi}] > > $F_x = \frac{R_x F}{R}$ > > endif::formatpdf[] > > > Surely there is a simpler way that lets me use one latex markup style > > but supports both soft and hardcopy output formats. Also, is there > > some way the source document can know at processing time which output > > it is intended for, if a2x is used instead of asciidoc? (I don't > > really understand why there exist both asciidoc and a2x; they seem to > > do the same thing but have different command syntaxes). > > > Thanks from a n00b. > > > -- Bruce Jackson > > > -- > > You received this message because you are subscribed to the Google Groups > > "asciidoc" group. > > 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 > > athttp://groups.google.com/group/asciidoc?hl=en. > > latexmath.txt > < 1KViewDownload > > latexmath.html > 90KViewDownload > > latexmath.pdf > 54KViewDownload -- You received this message because you are subscribed to the Google Groups "asciidoc" group. 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/asciidoc?hl=en.
