5

I'm very new to Latex so apologies if this is a newbie question. However I have looked around online and can't find an answer.

I'm trying to compile my file in TeXShop (on mac) using the following but I'm not sure how to go about it (using the 'Typeset' button alone is not sufficient). Please can someone help me out?

(pdf)latex
makeglossaries
(pdf)latex
(pdf)latex

When I tried compiling the document with the script provided it got stuck. Here is a screenshot of what I see:

enter image description here

  • 1
    Use latexmk. It's in the disabled engines folder by default, but can be enabled easily. See this related question for how to do that. I think it will automatically figure out when you need to run makeglossaries or any other tool, but it can definitely be configured to do so. – Mike Renfro Jan 31 '12 at 22:56
  • Re latexmk and glossaries: tex.stackexchange.com/questions/1226/… – lockstep Jan 31 '12 at 23:10
7

You create a file with

#!/bin/sh 
bfname=$(dirname "$1")/"`basename "$1" .tex`"  
pdflatex --shell-escape "$1"
makeindex -s "$bfname".ist -t "$bfname".glg -o "$bfname".gls "$bfname".glo 
pdflatex --shell-escape "$1" 
pdflatex --shell-escape "$1" 

You save this file with a name like glossaries.engine inside
/Users/yourusername/Library/TeXShop/Engines

You need also to make excutable the script :

Go to the terminal : cd ~/Library/TeXShop/Engines and then chmod u+x glossaries.engine use the name of your engine.

Then you can compile with the engine glossaries . Before to click on the compilation button, you need to chice the engine inside the list near the button "typeset", I suppose because in french, i have a "composition" button.

  • Hi thanks for your help. However when I try to compile the document it gets stuck. I have added a screenshot to my question. Any ideas what's going wrong? – The Crazy Chimp Feb 1 '12 at 10:31
  • Go to the terminal : cd ~/Library/TeXShop/Engines and then chmod u+x glossaries.engine use the name of your engine. I don't know if the encoding of the engine is important. I always use utf8. – Alain Matthes Feb 1 '12 at 10:54
  • You can also compile manually. Perhaps you have a problem with the file .ist if you use a specific file. You need to adapt the line makeindex -s "$bfname".ist -t "$bfname".glg -o "$bfname".gls "$bfname".glo . – Alain Matthes Feb 1 '12 at 10:57
  • I recommend changing the explicit makeindex call to either makeglossaries "$bfname" (if Perl is installed) or makeglossaries-lite "$bfname". That way it will also work with \usepackage[xindy]{glossaries} or \usepackage[acronyms]{glossaries} etc. – Nicola Talbot Jun 17 '17 at 10:37
0

Here's a modification to Alain Matthes' answer that determines whether to use makeglossaries (makeindex/xindy) or bib2gls. Edit the glossaries.engine file to:

#!/bin/sh 

bfname=${1%\.*}

pdflatex "$1"

if grep -q "glsxtr@resource" "$bfname.aux"; then
  bib2gls --group "$bfname"

  # hybrid
  if grep -q "@istfilename" "$bfname.aux"; then
    pdflatex "$1"
    makeglossaries "$bfname"
  fi

elif grep -q "@istfilename" "$bfname.aux"; then
  makeglossaries "$bfname"
fi

pdflatex "$1"

This should work for all the following documents:

  1. \makenoidxglossaries & \printnoidxglossary:

    \documentclass{article}
    
    \usepackage[acronym,symbols]{glossaries}
    
    \makenoidxglossaries
    
    % define entry in default 'main' glossary:
    \newglossaryentry{sample}{name={sample},description={an example}}
    
    % define entry in 'acronym' glossary:
    \newacronym{ex}{EX}{example}
    
    % define entry in 'symbols' glossary:
    \newglossaryentry{fx}{name={\ensuremath{f(x)}},
     sort={fx},
     description={a function of $x$},
     type=symbols
    }
    
    \begin{document}
    A \gls{sample} document with an \gls{ex} function \gls{fx}.
    
    \printnoidxglossary % default: type=main
    \printnoidxglossary[type=acronym]
    \printnoidxglossary[type=symbols]
    \end{document}
    
  2. \makeglossaries & \printglossary and makeindex:

    \documentclass{article}
    
    \usepackage[acronym,symbols]{glossaries}
    
    \makeglossaries
    
    % define entry in default 'main' glossary:
    \newglossaryentry{sample}{name={sample},description={an example}}
    
    % define entry in 'acronym' glossary:
    \newacronym{ex}{EX}{example}
    
    % define entry in 'symbols' glossary:
    \newglossaryentry{fx}{name={\ensuremath{f(x)}},
     sort={fx},
     description={a function of $x$},
     type=symbols
    }
    
    \begin{document}
    A \gls{sample} document with an \gls{ex} function \gls{fx}.
    
    \printglossary % default: type=main
    \printglossary[type=acronym]
    \printglossary[type=symbols]
    \end{document}
    
  3. \makeglossaries & \printglossary and xindy:

    \documentclass{article}
    
    \usepackage[xindy,acronym,symbols]{glossaries}
    
    \makeglossaries
    
    % define entry in default 'main' glossary:
    \newglossaryentry{sample}{name={sample},description={an example}}
    
    % define entry in 'acronym' glossary:
    \newacronym{ex}{EX}{example}
    
    % define entry in 'symbols' glossary:
    \newglossaryentry{fx}{name={\ensuremath{f(x)}},
     description={a function of $x$},
     type=symbols
    }
    
    \begin{document}
    A \gls{sample} document with an \gls{ex} function \gls{fx}.
    
    \printglossary % default: type=main
    \printglossary[type=acronym]
    \printglossary[type=symbols]
    \end{document}
    
  4. bib2gls:

    \RequirePackage{filecontents}
    \begin{filecontents*}{terms.bib}
    @entry{sample,
      name = {sample},
      description = {an example}
    }
    \end{filecontents*}
    
    \begin{filecontents*}{abbrvs.bib}
    @abbreviation{ex,
      short = {EX},
      long = {example}
    }
    \end{filecontents*}
    
    \begin{filecontents*}{syms.bib}
    @symbol{fx,
      name = {\ensuremath{f(x)}},
      description = {a function of $x$}
    }
    \end{filecontents*}
    
    \documentclass{article}
    
    \usepackage[record,abbreviations,symbols]{glossaries-extra}
    
    \GlsXtrLoadResources[src={terms,abbrvs}]
    
    \GlsXtrLoadResources[src={syms},type={symbols}]
    
    \begin{document}
    A \gls{sample} document with an \gls{ex} function \gls{fx}.
    
    \printunsrtglossary % default: type=main
    \printunsrtglossary[type=abbreviations]
    \printunsrtglossary[type=symbols]
    \end{document}
    
  5. \printunsrtglossary only:

    \documentclass{article}
    
    \usepackage[abbreviations,symbols]{glossaries-extra}
    
    % define entry in default 'main' glossary:
    \newglossaryentry{sample}{name={sample},description={an example}}
    
    % define entry in 'abbreviations' glossary:
    \newabbreviation{ex}{EX}{example}
    
    % define entry in 'symbols' glossary:
    \glsxtrnewsymbol
     [description={a function of $x$}]
     {fx}{\ensuremath{f(x)}}
    
    \begin{document}
    A \gls{sample} document with an \gls{ex} function \gls{fx}.
    
    \printunsrtglossary % default: type=main
    \printunsrtglossary[type=abbreviations]
    \printunsrtglossary[type=symbols]
    \end{document}
    
  6. Hybrid bib2gls+makeglossaries (for example, if you have a custom xindy style that can't be replicated by bib2gls, but you want the convenience of storing entry definitions in .bib files):

    \RequirePackage{filecontents}
    \begin{filecontents*}{terms.bib}
    @entry{sample,
      name = {sample},
      description = {an example}
    }
    \end{filecontents*}
    
    \begin{filecontents*}{abbrvs.bib}
    @abbreviation{ex,
      short = {EX},
      long = {example}
    }
    \end{filecontents*}
    
    \begin{filecontents*}{syms.bib}
    @symbol{fx,
      name = {\ensuremath{f(x)}},
      description = {a function of $x$}
    }
    \end{filecontents*}
    
    \documentclass{article}
    
    \usepackage[record=alsoindex,xindy,abbreviations,symbols]{glossaries-extra}
    
    \makeglossaries
    
    \GlsXtrLoadResources[src={terms,abbrvs},sort=none,save-locations=false]
    
    \GlsXtrLoadResources[src={syms},type={symbols},sort=none,save-locations=false]
    
    \begin{document}
    A \gls{sample} document with an \gls{ex} function \gls{fx}.
    
    \printglossary % default: type=main
    \printglossary[type=abbreviations]
    \printglossary[type=symbols]
    \end{document}
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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