Jason-S-Ross / ox-context

An Org Mode export backend for ConTeXt
13 stars 4 forks source link

slide presentations #1

Open gour opened 3 years ago

gour commented 3 years ago

Hello,

I'm starting with org-roam package for taking notes and would like to be able to produce articles and slide-show (PDF) presentations annotated with bibliography. For quite some time I am considering to use ConTeXt instead of LyX/LaTeX, but never had enough time to make a switch, so wonder whether you consider that ox-context could be used for creating slide-show presentations (ala Beamer) using ConTeXt markup?

I know that org-mode has special support for Beamer presentations, but I usually just used LyX/LaTeX directly...

Jason-S-Ross commented 3 years ago

A quick and dirty way of making a basic presentation is to change some settings with #+CONTEXT_HEADER commands:

#+CONTEXT_HEADER_EXTRA: \setuppapersize [S4]
#+CONTEXT_HEADER_EXTRA: \setupheads[section,subsection][page=yes,number=no]
#+CONTEXT_HEADER_EXTRA: \setuphead[subsection][textcommand=\gobbleoneargument]
#+CONTEXT_HEADER_EXTRA: \setuplist[section][pagecommand=\gobbleoneargument]
#+CONTEXT_HEADER_EXTRA: \setuplist[subsection][pagecommand=\gobbleoneargument]
#+CONTEXT_HEADER_EXTRA: \setupbodyfont[sans]
#+CONTEXT_HEADER_EXTRA: \setupheadertexts[subsection][]
#+CONTEXT_HEADER_EXTRA: \setuppagenumbering[state=stop]
#+CONTEXT_HEADER_EXTRA: \setuplayout[topspace=1ex, backspace=1em, width=middle]
#+CONTEXT_HEADER_EXTRA: \startuniqueMPgraphic{back} fill topboundary Page bottomenlarged 20pt withcolor 0.7white;  setbounds currentpicture to Page; \stopuniqueMPgraphic
#+CONTEXT_HEADER_EXTRA: \defineoverlay[back][\uniqueMPgraphic{back}]
#+CONTEXT_HEADER_EXTRA: \setupbackgrounds[page][background=back]
#+CONTEXT_SNIPPET: title-article

You can also define your own preset as follows:

(add-to-list
 'org-context-presets-alist
 '("presentation" .
   (:literal "\\setuppapersize [S4]
\\setupbodyfont[sans]
\\setupheads[section,subsection][page=yes,number=no]
% subsections go in the header and don't display
\\setuphead[subsection][textcommand=\\gobbleoneargument]
\\setuplist[section][pagecommand=\\gobbleoneargument]
\\setuplist[subsection][pagecommand=\\gobbleoneargument]
\\setupheadertexts[subsection][]
\\setuppagenumbering[state=stop]
\\setuplayout[topspace=1ex, backspace=1em, width=middle]
\\startuniqueMPgraphic{back}
  fill topboundary Page bottomenlarged 20pt withcolor 0.7white;
  setbounds currentpicture to Page;
\\stopuniqueMPgraphic
\\defineoverlay[back][\\uniqueMPgraphic{back}]
\\setupbackgrounds[page][background=back]
"
    :template "article"
    :snippets ("title-article"))))

You would use this preset by adding #+CONTEXT_PRESET: presentation to the document.

The Beamer exporter allows you to change the appearance of exported content using property drawers and the ATTR_BEAMER keyword. I don't currently have a mechanism to use property drawers to customize elements, but I'm considering it for the future. I don't plan to support the ATTR_BEAMER keyword in this extension.

The ConTeXt garden wiki has some good documentation on presentations and there's a bunch of prebuilt presentation styles that ship with ConTeXt. However, I'm not familiar enough with those styles to make any recommendations on how to adapt this exporter to use them.

gour commented 3 years ago

Hello!

I don't currently have a mechanism to use property drawers to customize elements, but I'm considering it for the future.

Thank a lot for your reply!!

I'll try it out, but am I right that you're definitely favouring ConteXt over LyX/LaTeX route?

Jason-S-Ross commented 3 years ago

I'll try it out, but am I right that you're definitely favouring ConteXt over LyX/LaTeX route?

This is an exporter for ConTeXt so you could say I favor it :) Can you tell me more about what Beamer features you're trying to use with this exporter?

gour commented 3 years ago

I'll try it out, but am I right that you're definitely favouring ConteXt over LyX/LaTeX route?

This is an exporter for ConTeXt so you could say I favor it :smile:

:-)

Can you tell me more about what Beamer features you're trying to use with this exporter?

Well, so far, I was only using Beamer from within LyX and not from the org-mode, but after deciding to use org-beam it natural I'd like to do more with the org-mode itself. :wink:

Jason-S-Ross commented 3 years ago

Well, so far, I was only using Beamer from within LyX and not from the org-mode, but after deciding to use org-beam it natural I'd like to do more with the org-mode itself. wink

I'm just not that familiar with the Beamer exporter, so I can't really comment on its advantages and disadvantages versus working in LyX and writing LaTeX. As far as supporting some of the features of the Beamer exporter in ConTeXt, I would like to get this extension to a point where that can be done with a simple preset, but it's not there yet. There are some additional features, like new keywords supported by the Beamer exporter, that would have to be implemented with a derived backend.

The overall objectives of this project are a bit different from the Beamer exporter: this exporter is intended to take a very basic document with no special mark-up and produce a reasonable output - there's a one-to-one correspondence between Org Mode elements and ConTeXt elements. This isn't really the case with the Beamer exporter as far as I can tell - I don't think there's an Org Mode element that corresponds with a Beamer action or note (hence the heavy reliance on property drawers in the Beamer exporter).

gour commented 3 years ago

The overall objectives of this project are a bit different from the Beamer exporter

Just curious if you tried to use Pandoc and export to ConTeXt from org-mode file, iow. what is advantage of ox-context in comparison?

Jason-S-Ross commented 3 years ago

ox-context aims to provide more control of the styling of document elements to the user through plain ConTeXt. For instance, here's a headline with a todo and a closed date:

** DONE [#A] Block Elements
CLOSED: [2021-01-25 Mon 14:57]

Here's how that headline exports to ConTeXt using the pandoc exporter:

\subsection[title={DONE {[}\#A{]} Block Elements},reference={a-block-elements}]

CLOSED: {[}2021-01-25 Mon 14:57{]}

Here's how those same elements are exported with ox-context

\startsubsection[title={\OrgHeadline
   [Todo={DONE},
   Priority={A},
   Text={Block Elements}]},
   list={Block Elements},
   marking={Block Elements},
   bookmark={Block Elements},
   reference={sec:org5cd09a9}]

\OrgPlanning[
ClosedString={CLOSED:},
ClosedTime={\date[d=08,m=01,y=2021]},]

Because ox-context wraps each element in a command defined in the preamble, it's trivial to overwrite the definition of, say, \OrgHeadline, to change how you want headlines to show up. This is conceptually more similar to html+css, where the html just specifies the class of each element and its location in the document structure, while the css controls the styling and formatting of classes of elements.

gour commented 3 years ago

ox-context aims to provide more control of the styling of document elements to the user through plain ConTeXt.

I was exploring some other options as well, but concluded that instead of trying to learn/master Beamer (and resume my LyX/LaTeX knowledge) it might be better to simply use that time for ConTeXt.

Moreover, I've decided to use org-mode as source markup for all my writings including note-taking (org-roam). However, in the past when i tried to settle on Emacs I experienced slight wrist pain, which never happened when using Vim, so considering you are much more experienced with the Emacs/org-mode I wonder:

Jason-S-Ross commented 3 years ago

First of all I'm going to say I am far, far from the most experienced programmer and take anything I say with a grain of salt. This is a learning project for me. I've been using Emacs for less than a year.

would you recommend using evil-mode for writing in org-mode?

So far, I'm pretty pleased with it. The only downside I've experienced is vim's undo system tends to not flow well with how I write prose - I might write a whole paragraph before exiting insert mode, but if I make one mistake, exit undo mode, and hit u it just removes the whole paragraph. There's probably a better way to do it, but I just don't know what that is at the moment.

even when using ox-context there is need to tweak the ConTeXt output

Can you elaborate on what kinds of tweaks you are making?

what do you use for writing [ConTeXt] within Emacs?

I just use AUCTeX. I've also set up a Polymode for syntax highlighting inline lua and metapost code.

I have tried with digestif which has some sort of ConTeXt support, but was not fully satisfied. Is AUCTeX better option?

I'm really the wrong person to ask about this. I'm not very familiar with AUCTeX's capabilities and I've never heard of digestif until today.

gour commented 3 years ago

First of all I'm going to say I am far, far from the most experienced programmer and take anything I say with a grain of salt. OK, no problem - warning accepted!

So far, I'm pretty pleased with it.

Thank you!

The only downside I've experienced is vim's undo system tends to not flow well with how I write prose

I'm glad you write prose since writing code is also not my main objective in using Emacs/org-mode. :-)

  • I might write a whole paragraph before exiting insert mode, but if I make one mistake, exit undo mode, and hit u it just removes the whole paragraph. There's probably a better way to do it, but I just don't know what that is at the moment.

I recently heard that undo-fu is better option than undo-tree, is that what you're using?

Can you elaborate on what kinds of tweaks you are making?

Nothing (yet), but I assume that the conversion might not be perfect and therefore does require some fine-tuning?

I just use AUCTeX. I've also set up a Polymode for syntax highlighting inline lua and metapost code.

Heh, Polymode is something new for me...

I'm really the wrong person to ask about this. I'm not very familiar with AUCTeX's capabilities and I've never heard of digestif until today.

OK. Author of digestif posted in the ConTeXt list some time ago and I heard about researching what support is there intexlab.

Jason-S-Ross commented 3 years ago

Nothing (yet), but I assume that the conversion might not be perfect and therefore does require some fine-tuning?

The conversion from Org to Pdf should be a one-step process. If fine-tuning is required, let me know!

gour commented 3 years ago

The conversion from Org to Pdf should be a one-step process. If fine-tuning is required, let me know!

Ahh, great! Still - have some issue #2.

juh2 commented 3 years ago

When I copy the presentation preset to my configuration I get this error when I export:

let*: Wrong type argument: char-or-string-p, nil

I want to make my own preset to meet special requirements.

Jason-S-Ross commented 3 years ago

This is probably due to some breaking changes in the configuration API since March. I've updated the example code in the original comment and copied it below.

(add-to-list
 'org-context-presets-alist
 '("presentation" .
   (:literal "\\setuppapersize [S4]
\\setupbodyfont[sans]
\\setupheads[section,subsection][page=yes,number=no]
% subsections go in the header and don't display
\\setuphead[subsection][textcommand=\\gobbleoneargument]
\\setuplist[section][pagecommand=\\gobbleoneargument]
\\setuplist[subsection][pagecommand=\\gobbleoneargument]
\\setupheadertexts[subsection][]
\\setuppagenumbering[state=stop]
\\setuplayout[topspace=1ex, backspace=1em, width=middle]
\\startuniqueMPgraphic{back}
  fill topboundary Page bottomenlarged 20pt withcolor 0.7white;
  setbounds currentpicture to Page;
\\stopuniqueMPgraphic
\\defineoverlay[back][\\uniqueMPgraphic{back}]
\\setupbackgrounds[page][background=back]
"
    :template "article"
    :snippets ("title-article"))))