From: Rasmus <rasmus@gmx.us>
To: emacs-orgmode@gnu.org
Subject: Re: Question about the math mode table exporting for latex and html
Date: Sat, 18 Jan 2014 21:40:25 +0100 [thread overview]
Message-ID: <87ioth6n2e.fsf@gmx.us> (raw)
In-Reply-To: <8738kzd9w5.fsf@gmail.com> (Nicolas Goaziou's message of "Tue, 07 Jan 2014 17:39:06 +0100")
[-- Attachment #1: Type: text/plain, Size: 1220 bytes --]
Hi,
>> Perhaps something like the following would be OK? Nicholas?
>>
>> #+ATTR_HTML: :mode latex
>> #+ATTR_LATEX: :mode math :environment pmatrix :math-prefix \mathbf{H}=
>> | \vdots | 0 | \vdots |
>> | \vdots | H | \vdots |
>> | \vdots | 0 | \vdots |
>>
>> This would tell ox-html.el to transcode the table via ox-latex-tabel
>> and feed the string via org-html-format-latex (assuming latex-frag is
>> a string).
>
> FWIW, I think it's worth trying. I'm Cc'ing Rick Frankel for his
> opinion.
>
>> Of course ox-html could also check out ATTR_LATEX but this
>> would lead to a spurious solution since LaTeX ≠ HTML IMO.
>
> I agree.
>
>> Nicholas, if you want I can look into this.
>
> Certainly. Thank you.
I have attached a rough proof-of-concept that will export the above
table correctly with mathjax. But I guess it will also have to handle
it correctly in the case of static png images.
I'm not sure how to handle captions. I guess the most natural way is
to let org-latex-table handle is. Let me know if something like this
is OK in which case I can polish it up and add documentation.
–Rasmus
--
. . . It begins of course with The Internet. A Net of Peers.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-latex-html-output-tables-as-latex.patch --]
[-- Type: text/x-diff, Size: 4745 bytes --]
From 036c06fc9f577b3d17e9caf7db366267bb4d28de Mon Sep 17 00:00:00 2001
From: Rasmus <w530@pank.eu>
Date: Sat, 18 Jan 2014 20:48:28 +0100
Subject: [PATCH] latex-html output tables as latex
---
lisp/ox-html.el | 105 +++++++++++++++++++++++++++++++-------------------------
1 file changed, 58 insertions(+), 47 deletions(-)
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 8ea9e65..80ce53c 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -3286,54 +3286,65 @@ contextual information."
(table.el (org-html-table--table.el-table table info))
;; Case 2: Standard table.
(t
- (let* ((label (org-element-property :name table))
- (caption (org-export-get-caption table))
- (number (org-export-get-ordinal
- table info nil 'org-html--has-caption-p))
- (attributes
- (org-html--make-attribute-string
- (org-combine-plists
- (and label (list :id (org-export-solidify-link-text label)))
- (and (not (org-html-html5-p info))
- (plist-get info :html-table-attributes))
- (org-export-read-attribute :attr_html table))))
- (alignspec
- (if (and (boundp 'org-html-format-table-no-css)
- org-html-format-table-no-css)
- "align=\"%s\"" "class=\"%s\""))
- (table-column-specs
- (function
- (lambda (table info)
- (mapconcat
- (lambda (table-cell)
- (let ((alignment (org-export-table-cell-alignment
- table-cell info)))
- (concat
- ;; Begin a colgroup?
- (when (org-export-table-cell-starts-colgroup-p
- table-cell info)
- "\n<colgroup>")
- ;; Add a column. Also specify it's alignment.
- (format "\n%s"
- (org-html-close-tag
- "col" (concat " " (format alignspec alignment)) info))
- ;; End a colgroup?
- (when (org-export-table-cell-ends-colgroup-p
- table-cell info)
- "\n</colgroup>"))))
- (org-html-table-first-row-data-cells table info) "\n")))))
- (format "<table%s>\n%s\n%s\n%s</table>"
- (if (equal attributes "") "" (concat " " attributes))
- (if (not caption) ""
- (format (if org-html-table-caption-above
- "<caption class=\"t-above\">%s</caption>"
- "<caption class=\"t-bottom\">%s</caption>")
+ (let ((mode (member :mode (org-export-read-attribute :attr_html table))))
+ (cond
+ ((member-ignore-case "latex" mode)
+ (org-html-table--as-latex table contents info))
+ (t
+ (let* ((label (org-element-property :name table))
+ (caption (org-export-get-caption table))
+ (number (org-export-get-ordinal
+ table info nil 'org-html--has-caption-p))
+ (attributes
+ (org-html--make-attribute-string
+ (org-combine-plists
+ (and label (list :id (org-export-solidify-link-text label)))
+ (and (not (org-html-html5-p info))
+ (plist-get info :html-table-attributes))
+ (org-export-read-attribute :attr_html table))))
+ (alignspec
+ (if (and (boundp 'org-html-format-table-no-css)
+ org-html-format-table-no-css)
+ "align=\"%s\"" "class=\"%s\""))
+ (table-column-specs
+ (function
+ (lambda (table info)
+ (mapconcat
+ (lambda (table-cell)
+ (let ((alignment (org-export-table-cell-alignment
+ table-cell info)))
(concat
- "<span class=\"table-number\">"
- (format (org-html--translate "Table %d:" info) number)
- "</span> " (org-export-data caption info))))
- (funcall table-column-specs table info)
- contents)))))
+ ;; Begin a colgroup?
+ (when (org-export-table-cell-starts-colgroup-p
+ table-cell info)
+ "\n<colgroup>")
+ ;; Add a column. Also specify it's alignment.
+ (format "\n%s"
+ (org-html-close-tag
+ "col" (concat " " (format alignspec alignment)) info))
+ ;; End a colgroup?
+ (when (org-export-table-cell-ends-colgroup-p
+ table-cell info)
+ "\n</colgroup>"))))
+ (org-html-table-first-row-data-cells table info) "\n")))))
+ (t (format "<table%s>\n%s\n%s\n%s</table>"
+ (if (equal attributes "") "" (concat " " attributes))
+ (if (not caption) ""
+ (format (if org-html-table-caption-above
+ "<caption class=\"t-above\">%s</caption>"
+ "<caption class=\"t-bottom\">%s</caption>")
+ (concat
+ "<span class=\"table-number\">"
+ (format (org-html--translate "Table %d:" info) number)
+ "</span> " (org-export-data caption info))))
+ (funcall table-column-specs table info)
+ contents)))))))))
+
+(defun org-html-table--as-latex (table contents info)
+ "Transcode TABLE into LaTeX code.
+Suitable for transcoding Org tables into math matrices. "
+ (require 'ox-latex)
+ (org-latex-table table contents info))
;;;; Target
--
1.8.5.3
next prev parent reply other threads:[~2014-01-18 20:36 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-07 9:47 Question about the math mode table exporting for latex and html bsun
2014-01-07 11:14 ` Rasmus
2014-01-07 16:39 ` Nicolas Goaziou
2014-01-07 21:17 ` Rick Frankel
2014-01-09 10:53 ` Nicolas Goaziou
2014-01-18 20:40 ` Rasmus [this message]
2014-01-21 17:48 ` Nicolas Goaziou
2014-01-07 12:55 ` puzzling org-mime-htmlize Joseph Vidal-Rosset
2014-01-07 13:37 ` Nick Dokos
2014-01-07 13:49 ` Joseph Vidal-Rosset
2014-01-08 7:28 ` Fwd: " Joseph Vidal-Rosset
2014-01-08 12:13 ` Nick Dokos
2014-01-08 12:56 ` Joseph Vidal-Rosset
2014-01-08 15:29 ` Nick Dokos
2014-01-08 15:43 ` Josiah Schwab
2014-01-08 17:42 ` Joseph Vidal-Rosset
2014-01-08 17:46 ` Bastien
2014-01-08 17:55 ` Joseph Vidal-Rosset
2014-01-08 23:41 ` Bastien
2014-01-09 9:03 ` Joseph Vidal-Rosset
2014-01-08 18:52 ` Nick Dokos
2014-01-08 18:50 ` Joseph Vidal-Rosset
2014-01-08 18:56 ` Joseph Vidal-Rosset
2014-01-08 19:23 ` Nick Dokos
2014-01-08 20:19 ` Joseph Vidal-Rosset
2014-01-08 20:36 ` Joseph Vidal-Rosset
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ioth6n2e.fsf@gmx.us \
--to=rasmus@gmx.us \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).