0

I would like to begin taking math class notes in Org mode -- I have thus far used plain LaTeX, but I have found Org has the potential to be much faster for real-time scribing. I already made a custom export class that links to my scribe document class.

I would like to be able to use an Org object (e.g. property, tag) to indicate an environment within which a subtree should be exported. As I show below, this is quite useful for theorem-like environments.

Having to use source blocks or literal LaTeX environments within my Org document annuls much of Org's value for fast, reviewable math notes. I think it would be much better to write this subtree:

* Cosets
** Lagrange's Theorem :theorem:
If $G$ is a finite group and $H$ is a subgroup of $G$, then $|H|\mid|G|$.
*** :proof:
Let $a_1H, a_2H, \cdots, a_rH$ denote the left cosets of $H$ in $G$...

And get this LaTeX out:

\section{Cosets}
\begin{theorem}[Lagrange's Theorem]
  If $G$ is a finite group and $H$ is a subgroup of $G$, then $|H|\mid|G|$.
\end{theorem}
\begin{proof}
  Let $a_1H, a_2H, \cdots, a_rH$ denote the left cosets of $H$ in $G$...
\end{proof}

There are some caveats here, most notably that we must know whether the entire subtree should be wrapped in the environment, or just the content accompanying the subtree's root headline. Minimally, I would like to identify an environment by a headline tag of the same name and set the title passed into the environment to the headline text (where applicable).

Note that I am taking the idea beyond that given in org-mode special blocks latex attribute. The solutions found in Org-mode latex environment in drawer still feel hacky, although the custom link approach is almost there. I want this environmenting to feel as native and Org-semantic as possible.

I don't see any high-level Org functions for wrapping subtrees as I have described. From what I can see, ATTR_LATEX doesn't fit the bill. Thus, I would derive an export backend with a transcoder that does the subtree wrapping, as well as define some other options (like course and professor) that will be exported. I would have a list of valid environment tags that would be active only in a notes Org file -- maybe a minor mode to encapsulate that.

I'm not asking for coding help, but I would like to know if I am I going about this the right way. I've been at Org for two months or so, and it seems to this newbie that if functionality as clearly useful as semantic environmenting hasn't been implemented, it's probably for a good reason.

I have specific questions:

  • Is there some Org mode functionality that I have overlooked that would make this or a similar idea very easy?
  • Are tags the best way to indicate an environment for a subtree as I have described?

Of course, I could just use outline-minor-mode or latex-extras and be largely done with it within LaTeX, but it would be neat to abstract environments into Org in this manner.

1 Answer 1

2

I use drawers (not the property drawer) for cases like this although I am not sure if you can pass options to them. Basically, I do

:proof:
... contents here
:end:

and then define org-latex-format-drawer-function so that it generates the right LaTeX code for the specific drawer type. For instance, for solutions to questions, I use a :solution: drawer and format it as follows:

(setq org-latex-format-drawer-function
      (lambda (name contents)
              (cond ((string= name "solution")
                     (format "\\begin{mdframed}\\paragraph{Solution.} %s\\end{mdframed}" contents))
                    (t (format "\\textbf{%s}: %s" name contents)))))
1
  • Smart idea. I put together a small export backend (ox-scribe) that allows exports of this kind. I read the Beamer export backend, and it has some good methods for converting tags to environments. I might integrate that into the backend.
    – npjg
    Sep 7, 2019 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.