Reputation: 67
I seek a good way to present text side-by-side both in the Org Mode buffer and also in the exported document. Here is an example showing two approaches that I have tried:
#+options: html-postamble:nil
#+options: toc:nil num:nil tags:nil ^:{}
* if statements
- Presented as an Org mode =example=:
#+begin_example
Ada | C | Pascal | Lisp
=== | = | ====== | ====
if B1 then | if (B1) { | if B1 then | (if B1 (progn
S1; | S1; | S1 | (S1))
elsif B2 then | } else { | else | (if B2 (progn
S2; | if (B2) { | if B2 then | (S2))
else | S2; | S2 | (S3)))
S3; | } else { | else |
end if; | S3; | S3 |
| } | end |
| } | end |
#+end_example
- Presented as an Org mode =table=:
#+macro: lf @@latex:\hspace{0pt}\\@@ @@html:<br>@@
#+macro: nbsp @@latex:\hspace{1em}@@ @@html: @@
#+macro: indent {{{nbsp}}}{{{nbsp}}}
| Ada | C | Pascal | Lisp |
| <l> | <l> | <l> | <l> |
|---------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------|
| / | < | < | < |
| if B1 then{{{lf}}}{{{indent}}}S1;{{{lf}}}elsif B2 then{{{lf}}}{{{indent}}}S2;{{{lf}}}else{{{lf}}}{{{indent}}}S3;{{{lf}}}end if; | if (B1) {{{{lf}}}{{{indent}}}S1;} else {{{{lf}}}{{{indent}}}if (B2) {{{{lf}}}{{{indent}}}{{{indent}}}S2;{{{lf}}}{{{indent}}}} else {{{{lf}}}{{{indent}}}{{{indent}}}S3;{{{lf}}}{{{indent}}}}{{{lf}}}} | if B1 then{{{lf}}}{{{indent}}}S1{{{lf}}}else{{{lf}}}{{{indent}}}if B2 then{{{lf}}}{{{indent}}}{{{indent}}}S2{{{lf}}}{{{indent}}}else{{{lf}}}{{{indent}}}{{{indent}}}S3{{{lf}}}{{{indent}}}end{{{lf}}}end | (if B1 (progn{{{lf}}}{{{indent}}}(S1)){{{lf}}}{{{indent}}}(if B2 (progn{{{lf}}}{{{indent}}}{{{indent}}}(S2)){{{lf}}}{{{indent}}}{{{indent}}}(S3))) |
Surely no one would want to write that second version.
Here is how the document looks exported as HTML:
Is there a better way to do this?
Upvotes: 2
Views: 338