jkitchin / org-ref

org-mode modules for citations, cross-references, bibliographies in org-mode and useful bibtex tools to go with it.
GNU General Public License v3.0
1.35k stars 242 forks source link

org-ref-glossary.el Doom Emacs Example? #1075

Closed Ma-Nu-El closed 1 year ago

Ma-Nu-El commented 1 year ago

Table of Contents

Doom Emacs Configuration

init.org: nothing

config.org:

`config.org` ```` #+begin_src elisp (use-package! org-ref :after org :commands (org-ref-cite-hydra/body org-ref-bibtex-hydra/body) :init ; code to run before loading org-ref :config (require 'org-ref) (add-hook 'org-export-before-parsing-hook 'org-ref-acronyms-before-parsing 'org-ref-glossary-before-parsing) ) #+end_src ````

packages.org:

#+begin_src elisp
(package! org-ref)
#+end_src

Minimal Example

test.org:

`file.org` ```` #+title: File #+date: #+author: #+LATEX_HEADER: \usepackage{glossaries} #+LATEX_HEADER: \makeglossaries Here I just define keys and labels, but I do not want them exported here. #+name: glossary | label | name | description | |-------+-------+---------------| | tree | Tree | A woody plant | | shrub | Shrub | A woody bush | #+name: acronyms | key | abbreviation | full form | |------+--------------+--------------------------------| | mimo | | multiple-input multiple output | | qos | QoS | quality-of-service | | bb | BB | branch and bound | Below is a test of where I want the table of glossaries and acronyms: - QoS is an acronym for quality-of-service. - Shrub is defined in glossary as A woody bush printglossaries: ````

With expanded links:

file.org:

`file.org` with expanded links ```` #+title: File #+date: #+author: #+LATEX_HEADER: \usepackage{glossaries} #+LATEX_HEADER: \makeglossaries Here I just define keys and labels, but I do not want them exported here. #+name: glossary | label | name | description | |-------+-------+---------------| | tree | Tree | A woody plant | | shrub | Shrub | A woody bush | #+name: acronyms | key | abbreviation | full form | |------+--------------+--------------------------------| | mimo | | multiple-input multiple output | | qos | QoS | quality-of-service | | bb | BB | branch and bound | Below is a test of where I want the table of glossaries and acronyms: - [[acrshort:qos][QoS]] is an acronym for [[acrlong:qos][quality-of-service]]. - [[gls:shrub][Shrub]] is defined in glossary as [[glsdesc:shrub][A woody bush]] [[printglossaries:]] ````

What is working and not working

Working:

Not working:

.tex and .pdf export

`.tex` ```` % Created 2023-04-27 Thu 21:32 % Intended LaTeX compiler: pdflatex \documentclass[11pt]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{graphicx} \usepackage{longtable} \usepackage{wrapfig} \usepackage{rotating} \usepackage[normalem]{ulem} \usepackage{amsmath} \usepackage{amssymb} \usepackage{capt-of} \usepackage{hyperref} \usepackage{glossaries} \makeglossaries \date{} \title{File} \hypersetup{ pdfauthor={}, pdftitle={File}, pdfkeywords={}, pdfsubject={}, pdfcreator={Emacs 28.2 (Org mode 9.6.1)}, pdflang={English}} \begin{document} \maketitle \tableofcontents Here I just define keys and labels, but I do not want them exported here. \begin{table}[htbp] \label{glossary} \centering \begin{tabular}{lll} label & name & description\\[0pt] \hline tree & Tree & A woody plant\\[0pt] shrub & Shrub & A woody bush\\[0pt] \end{tabular} \end{table} \begin{table}[htbp] \label{acronyms} \centering \begin{tabular}{lll} key & abbreviation & full form\\[0pt] \hline mimo & & multiple-input multiple output\\[0pt] qos & QoS & quality-of-service\\[0pt] bb & BB & branch and bound\\[0pt] \end{tabular} \end{table} Below is a test of where I want the table of glossaries and acronyms: \begin{itemize} \item \acrshort{qos} is an acronym for \acrlong{qos}. \item \gls{shrub} is defined in glossary as \glsdesc{shrub} \end{itemize} \printglossaries \end{document} ````
Screenshot 2023-04-27 at 21 50 26

The issue

The tables are being displayed as they are being typed in the orgmode file instead of being displayed according to the position of the [[printglossaries:]] directive. Should I use a #+begin_src latex block instead?

On another note, does anyone know how to activate org-ref keyboard shortcuts in Doom Emacs?

Will update if I come to a solution.

Ma-Nu-El commented 1 year ago

Solution:

It seems like macOS needs a different treatment.

From here I got the solution: https://stackoverflow.com/questions/51084740/latex-printglossaries-not-working-on-mac

And using an example in Overleaf.com https://es.overleaf.com/learn/latex/Glossaries#Terms_and_Acronyms

file.tex ```` \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[acronym]{glossaries} \makeglossaries \newglossaryentry{latex} { name=latex, description={Is a mark up language specially suited for scientific documents} } \newglossaryentry{maths} { name=mathematics, description={Mathematics is what mathematicians do} } \newglossaryentry{formula} { name=formula, description={A mathematical expression} } \newacronym{gcd}{GCD}{Greatest Common Divisor} \newacronym{lcm}{LCM}{Least Common Multiple} \begin{document} The \Gls{latex} typesetting markup language is specially suitable for documents that include \gls{maths}. \Glspl{formula} are rendered properly an easily once one gets used to the commands. Given a set of numbers, there are elementary methods to compute its \acrlong{gcd}, which is abbreviated \acrshort{gcd}. This process is similar to that used for the \acrfull{lcm}. \clearpage \printglossary[type=\acronymtype] \printglossary \end{document} ````

Then I have to

pdflatex file.tex
makeglossaries file
pdflatex file.tex

Notice the lack of extension in makeglossaries: it will not work if you put the extension.

Now, the next thing would be to make Emacs do this automatically, but my Elisp-fu is quite bad at the moment.

Ma-Nu-El commented 1 year ago

Noticed that my solution didn't involve features of org-ref-glossary.el.