ddoc latex/formulas?

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 15 09:35:53 PDT 2016


On 09/15/2016 11:43 AM, Johan Engelen wrote:
> On Thursday, 15 September 2016 at 14:42:37 UTC, Andrei Alexandrescu wrote:
>> On 09/15/2016 10:37 AM, Johan Engelen wrote:
> Btw, Ddoc is perhaps a little more than a macro system, and that's why
> using parameter names in equations is broken. Parameter names are
> replaced by (wait for it) a macro, so disabling that macro "fixes" the
> issue. See the stackoverflow example.
> http://stackoverflow.com/a/39514239/3215806

Thanks for making that point. Does the underscore prefix work? (I'll 
note that DDOC_PARAM is one of those things in the vein that many clamor 
for - do things automatically without a macro in sight...)

> So indeed, the DDoc system does provide a simple way to end up with
> nice-looking equations: "import" MathJax, and just write \(...\).
> Excellent.
>
> - Is there a way to "import" MathJax without having to redefine the DDOC
> macro?(seems a little brittle)

Yah, I think it's suboptimal to have to redefine DDOC (which in serious 
apps has a bunch of stuff) just for a few pages that need certain stuff 
in the html head. (This is a similar issue with various entities adding 
headers to http requests.)

What an application can do is this:

CUSTOM_DDOC =
<!DOCTYPE html>
<html lang="en-US">
<head>
$0
<title>$(TITLE)</title>
</head>
<body><h1>$(TITLE)</h1>$(BODY)</body>
</html>
DDOC = $(CUSTOM_DDOC)

Then, the pages that want mathjax go:

Macros:
DDOC = $(CUSTOM_DDOC <script type="text/javascript" async 
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"></script>)

In fact I think it would be a great idea to do this right now for Phobos 
and mathspecial.

Another solution is to define and use some macro a la DDOC_EXTRA_HEADER 
(and probably DDOC_EXTRA_FOOTER) but probably the one above is simpler 
and better.

> - Perhaps we can "standardize" the MathJax thing for Phobos docs? Would
> be nice for Manu's color lib and for Mir too. (where are the Mir guys
> anyway in this discussion? ;)

Johan, do you think I could impose on you to try your hand? The solution 
would redefine DDOC as above and involve dlang.org and (then) 
std.mathspecial.

> - Also, how about that parameter name problem? Any good fix for that?

Let's see how the underscore does.


Andrei



More information about the Digitalmars-d mailing list