dangom / org-thesis

Writing a Ph.D. thesis with Org Mode
498 stars 54 forks source link

Better glossary entry insert #3

Open nico202 opened 4 years ago

nico202 commented 4 years ago

Hi! Thanks for this, I'm writing my PhD thesis right now with a (slightly) modified version of this!

One thing I did not like were the acronym and glossaryentry macros (being macros you have to escape commas (\,), and they are a bit difficult to read, and there's no easy way to export them to html.

I wrote the following, maybe it can help somebody else:

* Acronym and Glossary                                             :noexport:

#+name: acronyms
| abbrev | long                   |
|--------+------------------------|
| VE     | Virtual Environment    |
| VR     | Virtual Reality        |
| OSC    | Open Sound Control     |
| UDP/IP | User Datagram Protocol |

#+name: glossary
| ref          | name                   | description                                  | sort                  |
|--------------+------------------------+----------------------------------------------+-----------------------|
| FFD          | Force--Feedback Device | Mechanical devices able to produce forces... | Force-Feedback Device |

* Exporting Acronym and Glossary                                     :ignore:
# Definitions
# glossary: ref, name, description, sort

** Description                                                    :noexport:
The following functions are used to convert the tables (ref:acronyms and
ref:glossary) to latex headers.

** Code                                                             :ignore:
#+name: acronym-from-table
#+begin_src emacs-lisp :var tbl=acronyms :results output drawer :exports results
  (defun acronym-header (l)
    (princ (format "#+latex_header: \\newacronym{%s}{%s}{%s}\n"
                   (nth 0 l) (nth 0 l) (nth 1 l))))
  (mapcar 'acronym-header tbl)
#+end_src

#+begin_src emacs-lisp :var tbl=glossary :results output drawer :exports results
  (defun glossary-header (l)
    (princ (format "#+latex_header: \\newglossaryentry{%s}{name={%s},description={%s},sort={%s}}\n"
                   (nth 0 l) (nth 1 l) (nth 2 l) (nth 3 l))))
   (mapcar 'glossary-header tbl)
#+end_src

Basically are just 2 tables with 2 simple blocks that convert them to the #+latex_header: entry.

Thanks!

dangom commented 4 years ago

Thanks for your comment!

Now that I've finished my thesis, one day I'd like to come back to this repository to clean it up a bit and improve documentation. Hopefully, when I find the time to do so I'll add your suggestion.