5

I am typing this code in overleaf, but I am not getting the list of symbols.

\documentclass{article}
\usepackage{bm}
\usepackage[toc,symbols]{glossaries}

\newglossaryentry{mass}{%
name={\ensuremath{m}},
description={The mass of the object},
type=symbols
}

\newglossaryentry{disp}{%
name={\ensuremath{\bm\lambda}},
description={The absolute displacement},
type=symbols
}


\makeglossaries


\begin{document}
\section{Normal section}
The \gls{mass} of the Sun can be determined by the centripetal force 
being given by the gravitional force and the orbiting period of    
the Earth. 

The \gls{disp} can not be used alone for determing the solar mass. 



\appendix
\printglossary[numberedsection,type=symbols,style=list,nogroupskip]

\end{document}

But by this post I am supposed to get the list of symbols.

Tiuri
  • 7,749
  • @campa Overleaf is supposed to detect if the glossary files need creating but it doesn't if the main glossary isn't used. – Nicola Talbot May 18 '18 at 13:07
  • @NicolaTalbot Could you please explain what changes I am supposed to make? – user534666 May 18 '18 at 13:16
  • 1
    Tip (unrelated to the problem): move \makeglossaries before the definitions. (Doesn't make much difference in this case, but you will notice a problem if you use the see key, so it's best to get in the habit of use \makeglossaries first.) – Nicola Talbot May 18 '18 at 13:31

1 Answers1

5

For glossaries to work, the script makeglossaries has to be called. Overleaf uses the rules defined in a file latexmkrc to detect which scripts to called, and uses a default file given here when no such file is present in your project. According to these default rules, makeglossaries is called when there is a .glo or .acn file present after the first run of PDFLaTeX. However, for this specific case, we want to run makeglossaries on a .slo file to produce a .sls file*. So you just need to add this to the rules:

add_cus_dep('slo', 'sls', 0, 'makeglossaries');

Edit: *Actually, we should have a rule that detects whether the .aux file contains @istfilename{...} in order to determine if makeglossaries is required. However, that's not the way how latexmk works.


tl;dr
Add the following file to your Overleaf project and call it latexmkrc:

# support for the glossaries package:
add_cus_dep('glo', 'gls', 0, 'makeglossaries');
add_cus_dep('acn', 'acr', 0, 'makeglossaries');
add_cus_dep('slo', 'sls', 0, 'makeglossaries');
sub makeglossaries {
  system("makeglossaries $_[0]");
}

# support for the nomencl package:
add_cus_dep('nlo', 'nls', 0, 'makenlo2nls');
sub makenlo2nls {
  system("makeindex -s nomencl.ist -o \"$_[0].nls\" \"$_[0].nlo\"");
}

# from the documentation for V. 2.03 of asymptote:
sub asy {return system("asy \"$_[0]\"");}
add_cus_dep("asy","eps",0,"asy");
add_cus_dep("asy","pdf",0,"asy");
add_cus_dep("asy","tex",0,"asy");

# metapost rule from http://tex.stackexchange.com/questions/37134
add_cus_dep('mp', '1', 0, 'mpost');
sub mpost {
  my $file = $_[0];
  my ($name, $path) = fileparse($file);
  pushd($path);
  my $return = system "mpost $name";
  popd();
  return $return;
}

enter image description here

Tiuri
  • 7,749
  • 1
    Really the rule needs to detect if the .aux file contains @istfilename{...} in order to determine if makeglossaries is required but that's not the way that latexmk is configured. – Nicola Talbot May 18 '18 at 13:23
  • 1
    @NicolaTalbot: Thanks for the clarification, I added that to the answer. – Tiuri May 18 '18 at 13:28
  • 1
    @Tiuri Thank you. It is now working on overleaf. I have a question does this work only in document class article? Will these commands work to make a list of symbols in a customthesis.cls type document class? – user534666 May 18 '18 at 13:43
  • 1
    @user534666: The specific problem of "makeglossaries not called when using only a list of symbols" should be solved by this regardless of the document class you are using. – Tiuri May 18 '18 at 13:44
  • 1
    @Tiuri Hey, this code works in both Sharelatex and overleaf, but not on texstudio. Can you tell me why? – user534666 May 21 '18 at 10:09
  • @user534666: Also in Texstudio, you need to run makeindex after the first run of LaTeX. But since I don't know anything about Texstudio, I suggest you ask a new question. – Tiuri May 21 '18 at 13:19