* ox and links to equation @ 2015-02-15 0:27 Rasmus 2015-02-15 9:58 ` Nicolas Goaziou 0 siblings, 1 reply; 12+ messages in thread From: Rasmus @ 2015-02-15 0:27 UTC (permalink / raw) To: emacs-orgmode Hi, I have two issues with linking to equations. Consider the following example: \begin{alinged} \Label{eq:1} \min f(x)\\ \label{eq:2} \st c(x)=0 \end{aligned} Insightful comments on [[eq:1]] and [[eq:2]] * Issue 1 If org-link-search-must-match-exact-headline is nil the links will work in the buffer. However, they will be discarded on export. Eq:1 I can refer to if I give the latex-environment a #+NAME, but I can't refer to eq:2. I think it should be possible to put in a link for eq:2. I don't know if it should depend on org-link-search-must-match-exact-headline or not, probably not. Any ideas how this could be solved and whether it's desirable solving? * Issue 2 (ox-latex specific) Since we now have amsmath in the org-default-package-alist I would like to \eqref{·} to refer to equations. The main difference is that it takes care of the parenthesis automatically. I.e. \ref{eq:2} → 2 and \eqref(eq:2) → (2). Also, mathtools works with \eqref, but not \ref. However, in old document it could lead to ((2)). I have a simple patch that hard-coded equation to \eqref, but I don't know if a more general approach should be taken. Or if it a filter issue. —Rasmus -- The second rule of Fight Club is: You do not talk about Fight Club ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: ox and links to equation 2015-02-15 0:27 ox and links to equation Rasmus @ 2015-02-15 9:58 ` Nicolas Goaziou 2015-02-15 11:30 ` Rasmus 0 siblings, 1 reply; 12+ messages in thread From: Nicolas Goaziou @ 2015-02-15 9:58 UTC (permalink / raw) To: Rasmus; +Cc: emacs-orgmode Rasmus <rasmus@gmx.us> writes: > I have two issues with linking to equations. > > Consider the following example: > > \begin{alinged} > \Label{eq:1} > \min f(x)\\ > \label{eq:2} > \st c(x)=0 > \end{aligned} > Insightful comments on [[eq:1]] and [[eq:2]] > > > * Issue 1 > > If org-link-search-must-match-exact-headline is nil the links will work in > the buffer. However, they will be discarded on export. Eq:1 I can refer > to if I give the latex-environment a #+NAME, but I can't refer to eq:2. I > think it should be possible to put in a link for eq:2. I don't know if it > should depend on org-link-search-must-match-exact-headline or not, > probably not. > > Any ideas how this could be solved and whether it's desirable solving? `org-link-search-must-match-exact-headline' is ignored during export. Since there are other ways to point to a particular location in a document, it is an acceptable limitation. For the problem at hand, you can use \label{eq:2} directly in the document. > * Issue 2 (ox-latex specific) > > Since we now have amsmath in the org-default-package-alist I would like to > \eqref{·} to refer to equations. The main difference is that it takes > care of the parenthesis automatically. I.e. \ref{eq:2} → 2 and > \eqref(eq:2) → (2). Also, mathtools works with \eqref, but not \ref. > However, in old document it could lead to ((2)). > > I have a simple patch that hard-coded equation to \eqref, but I don't know > if a more general approach should be taken. Or if it a filter issue. I'm not sure \eqref is desirable as a default value, (but I don't oppose it if you think it is). OTOH, a filter is easy enough to implement. Regards, ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: ox and links to equation 2015-02-15 9:58 ` Nicolas Goaziou @ 2015-02-15 11:30 ` Rasmus 2015-02-15 12:50 ` Nicolas Goaziou 0 siblings, 1 reply; 12+ messages in thread From: Rasmus @ 2015-02-15 11:30 UTC (permalink / raw) To: emacs-orgmode Nicolas Goaziou <mail@nicolasgoaziou.fr> writes: > For the problem at hand, you can use \label{eq:2} directly in the > document. Less pretty and I can't click on it. [For me a custom link type is fine, but every line of customization makes it harder to reproduce down the road]. Anyway, I found out that mathjax upstream now support labeling to equations using the latex format. Try: In equation \eqref{eq:sample}, we find the value of an interesting integral: \begin{equation} \int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15} \label{eq:sample} \end{equation} #+OPTIONS: html-scripts:nil #+HTML_HEAD: <script type="text/javascript" #+HTML_HEAD: src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> #+HTML_HEAD: </script> #+HTML_HEAD: <script type="text/x-mathjax-config"> #+HTML_HEAD: MathJax.Hub.Config({ #+HTML_HEAD: TeX: { equationNumbers: { autoNumber: "AMS" } } #+HTML_HEAD: }); #+HTML_HEAD: </script> >> * Issue 2 (ox-latex specific) >> >> Since we now have amsmath in the org-default-package-alist I would like to >> \eqref{·} to refer to equations. The main difference is that it takes >> care of the parenthesis automatically. I.e. \ref{eq:2} → 2 and >> \eqref(eq:2) → (2). Also, mathtools works with \eqref, but not \ref. >> However, in old document it could lead to ((2)). b>> >> I have a simple patch that hard-coded equation to \eqref, but I don't know >> if a more general approach should be taken. Or if it a filter issue. > > I'm not sure \eqref is desirable as a default value, (but I don't oppose > it if you think it is). OTOH, a filter is easy enough to implement. I definitely think it is the more proper way to refer to an equation. But it really depends on the document. E.g. mathtools also offer a set of commands for referring to equations. I was considering an alist of (DESTINATION-TYPE REF-CMD-WITH-DESCRIPTION REF-CMD-WITHOUT-DESCRIPTION) But it might be an overkill, especially seeing that mathjax only supports \ref and \eqref out of the box. —Rasmus -- Summon the Mothership! ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: ox and links to equation 2015-02-15 11:30 ` Rasmus @ 2015-02-15 12:50 ` Nicolas Goaziou 2015-02-15 13:01 ` Rasmus 0 siblings, 1 reply; 12+ messages in thread From: Nicolas Goaziou @ 2015-02-15 12:50 UTC (permalink / raw) To: Rasmus; +Cc: emacs-orgmode Rasmus <rasmus@gmx.us> writes: > I definitely think it is the more proper way to refer to an equation. But > it really depends on the document. E.g. mathtools also offer a set of > commands for referring to equations. I was considering an alist of > > (DESTINATION-TYPE REF-CMD-WITH-DESCRIPTION REF-CMD-WITHOUT-DESCRIPTION) > > But it might be an overkill, especially seeing that mathjax only supports > \ref and \eqref out of the box. It really seems overkill. Note that you can write ([[eq1]]), too. Anyway, you can add another case in `org-latex-link' (fuzzy links part) if you think it is important to support \eqref. Regards, ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: ox and links to equation 2015-02-15 12:50 ` Nicolas Goaziou @ 2015-02-15 13:01 ` Rasmus 2015-02-15 16:02 ` Nicolas Goaziou 0 siblings, 1 reply; 12+ messages in thread From: Rasmus @ 2015-02-15 13:01 UTC (permalink / raw) To: emacs-orgmode Nicolas Goaziou <mail@nicolasgoaziou.fr> writes: > It really seems overkill. Note that you can write ([[eq1]]), too. What I tried to say in the first email. If I add my patch, which indeed just adds a clause to org-latex-link, it would break documents which uses the above. Regarding the orgmode.org hosted version of mathjax: who should I ping to update it (or can I do it?), and *why* is orgmode.org hosting it? Privacy? From http://docs.mathjax.org/en/latest/start.html: > We recommend using the CDN service if you can, but you can also install > MathJax on your own server, or locally on your own hard disk. To do so > you will need to do the following things: —Rasmus -- ツ ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: ox and links to equation 2015-02-15 13:01 ` Rasmus @ 2015-02-15 16:02 ` Nicolas Goaziou 2015-02-15 20:37 ` Rasmus 2015-02-16 1:50 ` [patch, ox-html] mathjax changes (was: ox and links to equation) Rasmus 0 siblings, 2 replies; 12+ messages in thread From: Nicolas Goaziou @ 2015-02-15 16:02 UTC (permalink / raw) To: Rasmus; +Cc: emacs-orgmode Rasmus <rasmus@gmx.us> writes: > Nicolas Goaziou <mail@nicolasgoaziou.fr> writes: > >> It really seems overkill. Note that you can write ([[eq1]]), too. > > What I tried to say in the first email. If I add my patch, which indeed > just adds a clause to org-latex-link, it would break documents which uses > the above. It would appear as, e.g., ((2)) indeed. > Regarding the orgmode.org hosted version of mathjax: who should I ping to > update it (or can I do it?) Probably Bastien. > and *why* is orgmode.org hosting it? Privacy? I don't think CDN service was available at the time mathjax support was implemented. IMO, it hardly makes sense to host it now. Regards, ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: ox and links to equation 2015-02-15 16:02 ` Nicolas Goaziou @ 2015-02-15 20:37 ` Rasmus 2015-02-15 20:46 ` Nicolas Goaziou 2015-02-16 1:50 ` [patch, ox-html] mathjax changes (was: ox and links to equation) Rasmus 1 sibling, 1 reply; 12+ messages in thread From: Rasmus @ 2015-02-15 20:37 UTC (permalink / raw) To: emacs-orgmode Nicolas Goaziou <mail@nicolasgoaziou.fr> writes: > It would appear as, e.g., ((2)) indeed. So what's the verdict? The upside is that \eqref{·} is more robust. >> and *why* is orgmode.org hosting it? Privacy? > > I don't think CDN service was available at the time mathjax support was > implemented. IMO, it hardly makes sense to host it now. OK, I'll see if I try to make it point to the mathjax CDN and add the option that enables \ref{·} and \eqref{·}. —Rasmus -- If you can mix business and politics wonderful things can happen! ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: ox and links to equation 2015-02-15 20:37 ` Rasmus @ 2015-02-15 20:46 ` Nicolas Goaziou 2015-02-15 22:31 ` Rasmus 0 siblings, 1 reply; 12+ messages in thread From: Nicolas Goaziou @ 2015-02-15 20:46 UTC (permalink / raw) To: Rasmus; +Cc: emacs-orgmode Rasmus <rasmus@gmx.us> writes: >> It would appear as, e.g., ((2)) indeed. > > So what's the verdict? The upside is that \eqref{·} is more robust. Your call. You face the consequences. Alone. I think this is safe to make the change as long as there is a ORG-NEWS entry. Of course, I never wrote that last sentence. Regards, ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: ox and links to equation 2015-02-15 20:46 ` Nicolas Goaziou @ 2015-02-15 22:31 ` Rasmus 0 siblings, 0 replies; 12+ messages in thread From: Rasmus @ 2015-02-15 22:31 UTC (permalink / raw) To: emacs-orgmode Nicolas Goaziou <mail@nicolasgoaziou.fr> writes: >> So what's the verdict? The upside is that \eqref{·} is more robust. > > Your call. You face the consequences. Alone. > > I think this is safe to make the change as long as there is a ORG-NEWS > entry. Of course, I never wrote that last sentence. Thinking some more about it, it's a bad idea, unless one would be able to tell if it's math environment. Which might require something like texmathp. Which is not part of Emacs-core. —Rasmus -- C is for Cookie ^ permalink raw reply [flat|nested] 12+ messages in thread
* [patch, ox-html] mathjax changes (was: ox and links to equation) 2015-02-15 16:02 ` Nicolas Goaziou 2015-02-15 20:37 ` Rasmus @ 2015-02-16 1:50 ` Rasmus 2015-02-17 18:04 ` [patch, ox-html] mathjax changes Rasmus 1 sibling, 1 reply; 12+ messages in thread From: Rasmus @ 2015-02-16 1:50 UTC (permalink / raw) To: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 680 bytes --] Hi, >> and *why* is orgmode.org hosting it? Privacy? > > I don't think CDN service was available at the time mathjax support was > implemented. IMO, it hardly makes sense to host it now. This patch switches the cdn to upstream and removes a lot of stuff that I believe mathjax will figure out on it own. I'm no mathjax or webs export, though. Notably, mathml stuff is gone. OTOH, I added some display options, which I believe one might care about. If more "user-sensible" options exists I can add them. It would be good if someone who knows MathJax better could reviews this. —Rasmus -- When the facts change, I change my mind. What do you do, sir? [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-ox-html-Use-upstream-MathJax-CDN.patch --] [-- Type: text/x-diff, Size: 11924 bytes --] From baf1f93056feb034c223cc7d7f5234559cd34471 Mon Sep 17 00:00:00 2001 From: Rasmus <rasmus@gmx.us> Date: Mon, 16 Feb 2015 02:04:02 +0100 Subject: [PATCH] ox-html: Use upstream MathJax CDN * ox-html.el (org-html-mathjax-options): Add multlinewidth, autonumber, tagindent and tagside. Remove MathML. Change default indent to correspond to upstream default. Change default MathJax path to point to upstream CDN. (org-html--build-mathjax-config): Remove MathML-related parts. (org-html-mathjax-template): Simplifiy template. * org.texi (@LaTeX{} fragments), (Math formatting in HTML export): Reflect change in default CDN. --- doc/org.texi | 51 ++++++++++++------------- lisp/ox-html.el | 115 ++++++++++++++++++++++++-------------------------------- 2 files changed, 73 insertions(+), 93 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index bec46a9..157f928 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -10258,20 +10258,17 @@ format sub- and superscripts in a WYSIWYM way. Going beyond symbols and sub- and superscripts, a full formula language is needed. Org mode can contain @LaTeX{} math fragments, and it supports ways to process these for several export back-ends. When exporting to @LaTeX{}, -the code is obviously left as it is. When exporting to HTML, Org can invoke -the @uref{http://www.mathjax.org, MathJax library} (@pxref{Math formatting in -HTML export}) to process and display the math@footnote{If you plan to use -this regularly or on pages with significant page views, you should install -@file{MathJax} on your own server in order to limit the load of our server.}. -It can also process the mathematical expressions into images that can be -displayed in a browser (see @pxref{Previewing @LaTeX{} fragments}). +the code is left as it is. When exporting to HTML, Org can use either +@uref{http://www.mathjax.org, MathJax} (@pxref{Math formatting in HTML +export}) or transcode the math into images (see @pxref{Previewing @LaTeX{} +fragments}). @LaTeX{} fragments don't need any special marking at all. The following snippets will be identified as @LaTeX{} source code: @itemize @bullet @item -Environments of any kind@footnote{When @file{MathJax} is used, only the -environments recognized by @file{MathJax} will be processed. When +Environments of any kind@footnote{When MathJax is used, only the +environments recognized by MathJax will be processed. When @file{dvipng} program or @file{imagemagick} suite is used to create images, any @LaTeX{} environment will be handled.}. The only requirement is that the @code{\begin} statement appears on a new line, at the beginning of the line @@ -10307,7 +10304,7 @@ either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \]. @vindex org-export-with-latex @LaTeX{} processing can be configured with the variable @code{org-export-with-latex}. The default setting is @code{t} which means -@file{MathJax} for HTML, and no processing for ASCII and @LaTeX{} back-ends. +MathJax for HTML, and no processing for ASCII and @LaTeX{} back-ends. You can also set this variable on a per-file basis using one of these lines: @@ -11466,25 +11463,23 @@ You could use @code{http} addresses just as well. @cindex imagemagick @LaTeX{} math snippets (@pxref{@LaTeX{} fragments}) can be displayed in two -different ways on HTML pages. The default is to use the -@uref{http://www.mathjax.org, MathJax system} which should work out of the -box with Org mode installation because @uref{http://orgmode.org} serves -@file{MathJax} for Org mode users for small applications and for testing -purposes. @b{If you plan to use this regularly or on pages with significant -page views, you should install@footnote{Installation instructions can be -found on the MathJax website, see -@uref{http://www.mathjax.org/resources/docs/?installation.html}.} MathJax on -your own server in order to limit the load of our server.} To configure -@file{MathJax}, use the variable @code{org-html-mathjax-options} or -insert something like the following into the buffer: - -@example -#+HTML_MATHJAX: align:"left" mathml:t path:"/MathJax/MathJax.js" -@end example +different ways on HTML pages. The default is to use +@uref{http://www.mathjax.org, MathJax} which should work out of the box with +Org@footnote{By default Org loads MathJax from +@uref{http://docs.mathjax.org/en/latest/start.html#using-the-mathjax-content-delivery-network-cdn, +MathJax.org}. A link to the terms of service of the MathJax CDN can be found +in the docstring of @code{org-html-mathjax-options}.}. Some MathJax display +options can be configured via @code{org-html-mathjax-options}, or in the +buffer. For example, with the following settings, +@smallexample +#+HTML_MATHJAX: align: left indent: 5em tagside: left tagindent: 0 +@end smallexample +equation labels will be displayed on the left marign and equations will be +five ems from the left margin. -@noindent See the docstring of the variable -@code{org-html-mathjax-options} for the meaning of the parameters in -this line. +@noindent See the docstring of +@code{org-html-mathjax-options} for all supported variables. The MathJax +template can be configure via @code{org-html-mathjax-template}. If you prefer, you can also request that @LaTeX{} fragments are processed into small images that will be inserted into the browser page. Before the diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 61619e0..b5e2231 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -1064,82 +1064,78 @@ See `format-time-string' for more information on its components." ;;;; Template :: Mathjax (defcustom org-html-mathjax-options - '((path "http://orgmode.org/mathjax/MathJax.js") + '((path "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" ) (scale "100") (align "center") - (indent "2em") - (mathml nil)) + (indent "0em") + (multlinewidth "85%") + (autonumber "AMS") + (tagindent ".8em") + (tagside "right")) "Options for MathJax setup. -path The path where to find MathJax -scale Scaling for the HTML-CSS backend, usually between 100 and 133 -align How to align display math: left, center, or right -indent If align is not center, how far from the left/right side? -mathml Should a MathML player be used if available? - This is faster and reduces bandwidth use, but currently - sometimes has lower spacing quality. Therefore, the default is - nil. When browsers get better, this switch can be flipped. +path The path where to find MathJax +scale Scaling for the HTML-CSS backend, usually between 100 and 133 +align How to align display math: left, center, or right +indent If align is not center, how far from the left/right side? +multlinewidth The width of the multline environment. +autonumber How to number equations: None, all or as AMS Math. +tagindent The amount tags are indented. +tagside Whether tags are shown to the left or right of equations You can also customize this for each buffer, using something like -#+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\"" +#+HTML_MATHJAX: align: left indent: 5em tagside: left + +For further information about MathJax options, see the MathJax documentation: + + http://docs.mathjax.org/ + +Please note that by using the default CDN one must agree with +MathJax CDN Terms of Service. + + http://www.mathjax.org/mathjax-cdn-terms-of-service.html" :group 'org-export-html :type '(list :greedy t - (list :tag "path (the path from where to load MathJax.js)" - (const :format " " path) (string)) + (list :tag "path (the path from where to load MathJax.js)" + (const :format " " path) (string)) (list :tag "scale (scaling for the displayed math)" (const :format " " scale) (string)) (list :tag "align (alignment of displayed equations)" (const :format " " align) (string)) (list :tag "indent (indentation with left or right alignment)" (const :format " " indent) (string)) - (list :tag "mathml (should MathML display be used is possible)" - (const :format " " mathml) (boolean)))) + (list :tag "multlinewidth (width to use for the multline environment)" + (const :format " " multlinewidth) (string)) + (list :tag "autonumber (when should equations be numbered)" + (const :format " " autonumber) + (choice (const "AMS") + (const "None") + (const "All"))) + (list :tag "tagindent (the indentation of tags from left or right)" + (const :format " " tagindent) (string)) + (list :tag "tagside (location of tags)" + (const :format " " tagside) + (choice (const "left") + (const "right"))))) (defcustom org-html-mathjax-template - "<script type=\"text/javascript\" src=\"%PATH\"></script> -<script type=\"text/javascript\"> -<!--/*--><![CDATA[/*><!--*/ + "<script type=\"text/x-mathjax-config\"> MathJax.Hub.Config({ - // Only one of the two following lines, depending on user settings - // First allows browser-native MathML display, second forces HTML/CSS - :MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"], - :MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"], - extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\", - \"TeX/noUndefined.js\"], - tex2jax: { - inlineMath: [ [\"\\\\(\",\"\\\\)\"] ], - displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ], - skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"], - ignoreClass: \"tex2jax_ignore\", - processEscapes: false, - processEnvironments: true, - preview: \"TeX\" - }, - showProcessingMessages: true, displayAlign: \"%ALIGN\", displayIndent: \"%INDENT\", - \"HTML-CSS\": { - scale: %SCALE, - availableFonts: [\"STIX\",\"TeX\"], - preferredFont: \"TeX\", - webFont: \"TeX\", - imageFont: \"TeX\", - showMathMenu: true, - }, - MMLorHTML: { - prefer: { - MSIE: \"MML\", - Firefox: \"MML\", - Opera: \"HTML\", - other: \"HTML\" + \"HTML-CSS\": { scale: %SCALE,}, + TeX: { equationNumbers: {autoNumber: \"%AUTONUMBER\"}, + MultLineWidth: \"%MULTLINEWIDTH\", + TagSide: \"%TAGSIDE\", + TagIndent: \"%TAGINDENT\" } - } - }); -/*]]>*///--> -</script>" - "The MathJax setup for XHTML files." +}); +</script> +<script type=\"text/javascript\" + src=\"%PATH\"></script>" + "The MathJax template. See also `org-html-mathjax-options'." :group 'org-export-html :type 'string) @@ -1691,17 +1687,6 @@ INFO is a plist used as a communication channel." (if (string-match (concat "%" (upcase (symbol-name name))) template) (setq template (replace-match val t t template)))) options) - (setq val (nth 1 (assq 'mathml options))) - (if (string-match (concat "\\<mathml:") in-buffer) - (setq val (car (read-from-string - (substring in-buffer (match-end 0)))))) - ;; Exchange prefixes depending on mathml setting. - (if (not val) (setq x yes yes no no x)) - ;; Replace cookies to turn on or off the config/jax lines. - (if (string-match ":MMLYES:" template) - (setq template (replace-match yes t t template))) - (if (string-match ":MMLNO:" template) - (setq template (replace-match no t t template))) ;; Return the modified template. (org-element-normalize-string template)))) -- 2.3.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [patch, ox-html] mathjax changes 2015-02-16 1:50 ` [patch, ox-html] mathjax changes (was: ox and links to equation) Rasmus @ 2015-02-17 18:04 ` Rasmus 2015-02-27 13:11 ` Rasmus 0 siblings, 1 reply; 12+ messages in thread From: Rasmus @ 2015-02-17 18:04 UTC (permalink / raw) To: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 1034 bytes --] Hi, Rasmus <rasmus@gmx.us> writes: >>> and *why* is orgmode.org hosting it? Privacy? >> >> I don't think CDN service was available at the time mathjax support was >> implemented. IMO, it hardly makes sense to host it now. > > This patch switches the cdn to upstream and removes a lot of stuff that I > believe mathjax will figure out on it own. I'm no mathjax or webs export, > though. Notably, mathml stuff is gone. > > OTOH, I added some display options, which I believe one might care about. > If more "user-sensible" options exists I can add them. > > It would be good if someone who knows MathJax better could reviews this. Added font, better scale support, linebreaks, linebreaks and possibility for the browser to chose MathMl if support is good enough. If you are uncomfortable with Org linking against cdn.mathjax.org it would be good to let me know. If no other inputs, I will install this patch soonish. —Rasmus -- The second rule of Fight Club is: You do not talk about Fight Club [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-ox-html-Use-upstream-MathJax-CDN.patch --] [-- Type: text/x-diff, Size: 14453 bytes --] From bc57c2daa56838487f183931aead4fd9720307d1 Mon Sep 17 00:00:00 2001 From: Rasmus <rasmus@gmx.us> Date: Mon, 16 Feb 2015 02:04:02 +0100 Subject: [PATCH] ox-html: Use upstream MathJax CDN * ox-html.el (org-html-mathjax-options): Add multlinewidth, autonumber, tagindent, font, linebreaks and tagside. Remove MathML. Change default indent to correspond to upstream default. Change default MathJax path to point to upstream CDN. (org-html--build-mathjax-config): Remove MathML-related parts. (org-html-mathjax-template): Simplifiy template. * org.texi (@LaTeX{} fragments), (Math formatting in HTML export): Reflect change in default CDN. --- doc/org.texi | 51 ++++++++--------- lisp/ox-html.el | 168 +++++++++++++++++++++++++++++++------------------------- 2 files changed, 116 insertions(+), 103 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index bec46a9..de79e94 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -10258,20 +10258,17 @@ format sub- and superscripts in a WYSIWYM way. Going beyond symbols and sub- and superscripts, a full formula language is needed. Org mode can contain @LaTeX{} math fragments, and it supports ways to process these for several export back-ends. When exporting to @LaTeX{}, -the code is obviously left as it is. When exporting to HTML, Org can invoke -the @uref{http://www.mathjax.org, MathJax library} (@pxref{Math formatting in -HTML export}) to process and display the math@footnote{If you plan to use -this regularly or on pages with significant page views, you should install -@file{MathJax} on your own server in order to limit the load of our server.}. -It can also process the mathematical expressions into images that can be -displayed in a browser (see @pxref{Previewing @LaTeX{} fragments}). +the code is left as it is. When exporting to HTML, Org can use either +@uref{http://www.mathjax.org, MathJax} (@pxref{Math formatting in HTML +export}) or transcode the math into images (see @pxref{Previewing @LaTeX{} +fragments}). @LaTeX{} fragments don't need any special marking at all. The following snippets will be identified as @LaTeX{} source code: @itemize @bullet @item -Environments of any kind@footnote{When @file{MathJax} is used, only the -environments recognized by @file{MathJax} will be processed. When +Environments of any kind@footnote{When MathJax is used, only the +environments recognized by MathJax will be processed. When @file{dvipng} program or @file{imagemagick} suite is used to create images, any @LaTeX{} environment will be handled.}. The only requirement is that the @code{\begin} statement appears on a new line, at the beginning of the line @@ -10307,7 +10304,7 @@ either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \]. @vindex org-export-with-latex @LaTeX{} processing can be configured with the variable @code{org-export-with-latex}. The default setting is @code{t} which means -@file{MathJax} for HTML, and no processing for ASCII and @LaTeX{} back-ends. +MathJax for HTML, and no processing for ASCII and @LaTeX{} back-ends. You can also set this variable on a per-file basis using one of these lines: @@ -11466,25 +11463,23 @@ You could use @code{http} addresses just as well. @cindex imagemagick @LaTeX{} math snippets (@pxref{@LaTeX{} fragments}) can be displayed in two -different ways on HTML pages. The default is to use the -@uref{http://www.mathjax.org, MathJax system} which should work out of the -box with Org mode installation because @uref{http://orgmode.org} serves -@file{MathJax} for Org mode users for small applications and for testing -purposes. @b{If you plan to use this regularly or on pages with significant -page views, you should install@footnote{Installation instructions can be -found on the MathJax website, see -@uref{http://www.mathjax.org/resources/docs/?installation.html}.} MathJax on -your own server in order to limit the load of our server.} To configure -@file{MathJax}, use the variable @code{org-html-mathjax-options} or -insert something like the following into the buffer: - -@example -#+HTML_MATHJAX: align:"left" mathml:t path:"/MathJax/MathJax.js" -@end example +different ways on HTML pages. The default is to use +@uref{http://www.mathjax.org, MathJax} which should work out of the box with +Org@footnote{By default Org loads MathJax from +@uref{http://docs.mathjax.org/en/latest/start.html#using-the-mathjax-content-delivery-network-cdn, +MathJax.org}. A link to the terms of service of the MathJax CDN can be found +in the docstring of @code{org-html-mathjax-options}.}. Some MathJax display +options can be configured via @code{org-html-mathjax-options}, or in the +buffer. For example, with the following settings, +@smallexample +#+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Euler +@end smallexample +equation labels will be displayed on the left marign and equations will be +five ems from the left margin. -@noindent See the docstring of the variable -@code{org-html-mathjax-options} for the meaning of the parameters in -this line. +@noindent See the docstring of +@code{org-html-mathjax-options} for all supported variables. The MathJax +template can be configure via @code{org-html-mathjax-template}. If you prefer, you can also request that @LaTeX{} fragments are processed into small images that will be inserted into the browser page. Before the diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 61619e0..75bb9f4 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -1064,82 +1064,111 @@ See `format-time-string' for more information on its components." ;;;; Template :: Mathjax (defcustom org-html-mathjax-options - '((path "http://orgmode.org/mathjax/MathJax.js") + '((path "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" ) (scale "100") (align "center") - (indent "2em") - (mathml nil)) + (font "TeX") + (linebreaks "false") + (autonumber "AMS") + (indent "0em") + (multlinewidth "85%") + (tagindent ".8em") + (tagside "right")) "Options for MathJax setup. -path The path where to find MathJax -scale Scaling for the HTML-CSS backend, usually between 100 and 133 -align How to align display math: left, center, or right -indent If align is not center, how far from the left/right side? -mathml Should a MathML player be used if available? - This is faster and reduces bandwidth use, but currently - sometimes has lower spacing quality. Therefore, the default is - nil. When browsers get better, this switch can be flipped. +Alist of the following elements. All values are strings. + +path The path to MathJax. +scale Scaling with HTML-CSS, MathML and SVG output engines. +align How to align display math: left, center, or right. +font The font to use with HTML-CSS and SVG output. As of MathJax 2.5 + the following values are understood: \"TeX\", \"STIX-Web\", + \"Asana-Math\", \"Neo-Euler\", \"Gyre-Pagella\", + \"Gyre-Termes\", and \"Latin-Modern\". +linebreaks Let MathJax perform automatic linebreaks. Valid values + are \"true\" and \"false\". +indent If align is not center, how far from the left/right side? + Valid values are \"left\" and \"right\" +multlinewidth The width of the multline environment. +autonumber How to number equations. Valid values are \"None\", + \"all\" and \"AMS Math\". +tagindent The amount tags are indented. +tagside Which side to show tags/labels on. Valid values are + \"left\" and \"right\" You can also customize this for each buffer, using something like -#+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\"" +#+HTML_MATHJAX: align: left indent: 5em tagside: left + +For further information about MathJax options, see the MathJax documentation: + + http://docs.mathjax.org/ + +Please note that by using the default CDN one must agree with +MathJax CDN Terms of Service. + + http://www.mathjax.org/mathjax-cdn-terms-of-service.html" :group 'org-export-html :type '(list :greedy t - (list :tag "path (the path from where to load MathJax.js)" - (const :format " " path) (string)) - (list :tag "scale (scaling for the displayed math)" - (const :format " " scale) (string)) - (list :tag "align (alignment of displayed equations)" - (const :format " " align) (string)) - (list :tag "indent (indentation with left or right alignment)" - (const :format " " indent) (string)) - (list :tag "mathml (should MathML display be used is possible)" - (const :format " " mathml) (boolean)))) + (list :tag "path (the path from where to load MathJax.js)" + (const :format " " path) (string)) + (list :tag "scale (scaling for the displayed math)" + (const :format " " scale) (string)) + (list :tag "align (alignment of displayed equations)" + (const :format " " align) (string)) + (list :tag "font (used to display math)" + (const :format " " font) + (choice (const "TeX") + (const "STIX-Web") + (const "Asana-Math") + (const "Neo-Euler") + (const "Gyre-Pagella") + (const "Gyre-Termes") + (const "Latin-Modern"))) + (list :tag "linebreaks (automatic line-breaking)" + (const :format " " linebreaks) + (choice (const "true") + (const "false"))) + (list :tag "autonumber (when should equations be numbered)" + (const :format " " autonumber) + (choice (const "AMS") + (const "None") + (const "All"))) + (list :tag "indent (indentation with left or right alignment)" + (const :format " " indent) (string)) + (list :tag "multlinewidth (width to use for the multline environment)" + (const :format " " multlinewidth) (string)) + (list :tag "tagindent (the indentation of tags from left or right)" + (const :format " " tagindent) (string)) + (list :tag "tagside (location of tags)" + (const :format " " tagside) + (choice (const "left") + (const "right"))))) (defcustom org-html-mathjax-template - "<script type=\"text/javascript\" src=\"%PATH\"></script> -<script type=\"text/javascript\"> -<!--/*--><![CDATA[/*><!--*/ + "<script type=\"text/x-mathjax-config\"> MathJax.Hub.Config({ - // Only one of the two following lines, depending on user settings - // First allows browser-native MathML display, second forces HTML/CSS - :MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"], - :MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"], - extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\", - \"TeX/noUndefined.js\"], - tex2jax: { - inlineMath: [ [\"\\\\(\",\"\\\\)\"] ], - displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ], - skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"], - ignoreClass: \"tex2jax_ignore\", - processEscapes: false, - processEnvironments: true, - preview: \"TeX\" - }, - showProcessingMessages: true, displayAlign: \"%ALIGN\", displayIndent: \"%INDENT\", - \"HTML-CSS\": { - scale: %SCALE, - availableFonts: [\"STIX\",\"TeX\"], - preferredFont: \"TeX\", - webFont: \"TeX\", - imageFont: \"TeX\", - showMathMenu: true, - }, - MMLorHTML: { - prefer: { - MSIE: \"MML\", - Firefox: \"MML\", - Opera: \"HTML\", - other: \"HTML\" + \"HTML-CSS\": { scale: %SCALE, + linebreaks: { automatic: \"%LINEBREAKS\" }, + webFont: \"%FONT\" + }, + SVG: {scale: %SCALE, + linebreaks: { automatic: \"%LINEBREAKS\" }, + font: \"%FONT\"}, + NativeMML: {scale: %SCALE}, + TeX: { equationNumbers: {autoNumber: \"%AUTONUMBER\"}, + MultLineWidth: \"%MULTLINEWIDTH\", + TagSide: \"%TAGSIDE\", + TagIndent: \"%TAGINDENT\" } - } - }); -/*]]>*///--> -</script>" - "The MathJax setup for XHTML files." +}); +</script> +<script type=\"text/javascript\" + src=\"%PATH\"></script>" + "The MathJax template. See also `org-html-mathjax-options'." :group 'org-export-html :type 'string) @@ -1680,28 +1709,17 @@ INFO is a plist used as a communication channel." (let ((template (plist-get info :html-mathjax-template)) (options (plist-get info :html-mathjax-options)) (in-buffer (or (plist-get info :html-mathjax) "")) - name val (yes " ") (no "// ") x) + name val x) (mapc (lambda (e) (setq name (car e) val (nth 1 e)) (if (string-match (concat "\\<" (symbol-name name) ":") in-buffer) (setq val (car (read-from-string (substring in-buffer (match-end 0)))))) - (if (not (stringp val)) (setq val (format "%s" val))) - (if (string-match (concat "%" (upcase (symbol-name name))) template) - (setq template (replace-match val t t template)))) + (if (not (stringp val)) (setq val (format "%s" val))) + (while (string-match (concat "%" (upcase (symbol-name name))) template) + (setq template (replace-match val t t template)))) options) - (setq val (nth 1 (assq 'mathml options))) - (if (string-match (concat "\\<mathml:") in-buffer) - (setq val (car (read-from-string - (substring in-buffer (match-end 0)))))) - ;; Exchange prefixes depending on mathml setting. - (if (not val) (setq x yes yes no no x)) - ;; Replace cookies to turn on or off the config/jax lines. - (if (string-match ":MMLYES:" template) - (setq template (replace-match yes t t template))) - (if (string-match ":MMLNO:" template) - (setq template (replace-match no t t template))) ;; Return the modified template. (org-element-normalize-string template)))) -- 2.3.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [patch, ox-html] mathjax changes 2015-02-17 18:04 ` [patch, ox-html] mathjax changes Rasmus @ 2015-02-27 13:11 ` Rasmus 0 siblings, 0 replies; 12+ messages in thread From: Rasmus @ 2015-02-27 13:11 UTC (permalink / raw) To: emacs-orgmode Rasmus <rasmus@gmx.us> writes: > Hi, > > Rasmus <rasmus@gmx.us> writes: > >>>> and *why* is orgmode.org hosting it? Privacy? >>> >>> I don't think CDN service was available at the time mathjax support was >>> implemented. IMO, it hardly makes sense to host it now. >> >> This patch switches the cdn to upstream and removes a lot of stuff that I >> believe mathjax will figure out on it own. I'm no mathjax or webs export, >> though. Notably, mathml stuff is gone. >> >> OTOH, I added some display options, which I believe one might care about. >> If more "user-sensible" options exists I can add them. >> >> It would be good if someone who knows MathJax better could reviews this. > > Added font, better scale support, linebreaks, linebreaks and possibility > for the browser to chose MathMl if support is good enough. > > If you are uncomfortable with Org linking against cdn.mathjax.org it would > be good to let me know. If no other inputs, I will install this patch > soonish. Pushed in 8c54b254b12d07136dc1720d2161b8a6db1f50b9. -- Warning: Everything saved will be lost ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2015-02-27 13:12 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-02-15 0:27 ox and links to equation Rasmus 2015-02-15 9:58 ` Nicolas Goaziou 2015-02-15 11:30 ` Rasmus 2015-02-15 12:50 ` Nicolas Goaziou 2015-02-15 13:01 ` Rasmus 2015-02-15 16:02 ` Nicolas Goaziou 2015-02-15 20:37 ` Rasmus 2015-02-15 20:46 ` Nicolas Goaziou 2015-02-15 22:31 ` Rasmus 2015-02-16 1:50 ` [patch, ox-html] mathjax changes (was: ox and links to equation) Rasmus 2015-02-17 18:04 ` [patch, ox-html] mathjax changes Rasmus 2015-02-27 13:11 ` Rasmus
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).