Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better glossaries #800

Closed
Nathan-Furnal opened this issue Sep 29, 2020 · 5 comments
Closed

Better glossaries #800

Nathan-Furnal opened this issue Sep 29, 2020 · 5 comments

Comments

@Nathan-Furnal
Copy link

Hi,

This is both a question and a somewhat helpful post. I had to use glossaries recently and when I tried the minimal example from the manual, it didn't work as makeglossaries was not ran in the shell.

This can easily be fixed by creating an ~/.latexmkrc file (on Linux) and write to it:

add_cus_dep('glo', 'gls', 0, 'run_makeglossaries');
add_cus_dep('acn', 'acr', 0, 'run_makeglossaries');

sub run_makeglossaries {
  if ( $silent ) {
    system "makeglossaries -q '$_[0]'";
  }
  else {
    system "makeglossaries '$_[0]'";
  };
}

and it'll be running smoothly, this is explained here.

My question the following : how do I get large latex_header_extra blocks to write glossary entries? It's a real pain to write multi-line headers and I wondered in there was a better way?

Thanks for the excellent package

@jkitchin
Copy link
Owner

jkitchin commented Oct 1, 2020

I manage this in a custom make pdf function defined at https://github.com/jkitchin/scimax/blob/master/ox-manuscript/ox-manuscript.el#L435.

You could consider using #INCLUDE: files to put them in another file. I haven't tried that in a while. I am sure it is a pain to use latex_header_extra though. I don't know how easy it is to include a texfile in the right place though.

@Nathan-Furnal
Copy link
Author

Thanks for the function, I'll look into ox-manuscript, I'm satisfied with the .latexmkrc solution for the most part though.

I've been trying to use org-mode macros to simplify using the headers, such as
this snippet in my init.el.

  (setq org-export-global-macros
	'(("glossentry" . "#+latex_header_extra: \\newglossaryentry{$1}{name=$2, description={$3}}")))

So with

#+latex_header: \usepackage{glossaries}
#+latex_header: \makeglossaries
{{{glossentry(comp, computer, A machine of immense mysteries)}}}

* Introduction

We present a method to uncover the hidden world of the gls:comp. 

\printglossaries

We should get something decent, possibly multi-line as long as the macro encompasses the description part of the glossary entry.

For some reason this doesn't always work, I could reproduce the example in the doc with this method but a long description tripped up LaTeX, I don't know if it's because of line wrapping or because I had commas in the description, which have to be escaped because macros use commas to separate arguments.

Thanks for the help!

@jkitchin
Copy link
Owner

jkitchin commented Jan 8, 2021

You can now use #+latex_header: \loadglsentries[main]{glossary} (see https://github.com/jkitchin/org-ref/blob/master/org-ref.org#glossaries-and-acronyms). This should work with the tooltips, although I haven't tested it super thoroughly with long multiline definitions.

@Nathan-Furnal
Copy link
Author

Inserting them in the table at the top works great, thanks!

@mcraveiro
Copy link
Contributor

mcraveiro commented Apr 16, 2021

Thanks very much for org-ref, an amazing tool which I rely upon daily. I'd like to add a somewhat related comment to this discussion. Hopefully, it will preserve the sanity of any further reader who, like myself, tries to combine classic thesis [1] with org-ref. If, after the suggestions above, your makeglossaries fails with an error such as this one:

(./chapter_2.acr [9] [10]
! Undefined control sequence.
<argument> \letcs {\glo@name 
                             }{glo@\glsdetoklabel {acmdsd}@name}\expandafter...
l.5 ...etentrycounter[]{page}\glsnumberformat{3}}}
                                                  %

Then your probably hit the same bug as me. The problem is on an obscure combination of classic thesis with glossary as per this SO question [2]. I personally solved it by adding the following (nolist being the important option):

#+latex_header: \usepackage[acronym,nomain,nolist]{glossaries}

I do not claim this to be the best solution. The SO question provides a lot of detail, which is probably meaningful to someone who actually knows LaTeX. But this would at least allow you to get on with your life.

[1] ClassicThesis – A “classically styled” thesis package
[2] Glossaries: error when compiling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants