Closed ixil closed 4 years ago
Could the glossaries / glossaries-extra packages commands be supported? e.g. \acr, \gls, \glspl etc commands
Thanks for the feedback! I could include the packages. But I do not use them and cannot include all their macros. So, could you provide a list of the macros / environments you need or consider to be essential? Then, I could add them according to the package documentation.
Thanks for YaLafi, it's really great!
You are welcome. Glad you like it.
Having used Yalafi a bit more now it's not much of an issue with the glossaries, it's mainly the 'key' for the glossary items that are flagged as incorrect spelling when they are the acronyms - which is only a minor annoyance.
Looking at the [beginner guide]() or wiki probably shows the most common use cases. I've tried to put them below
There are two main types of usage.
Restricting checking the description and name is probably all that is required. I don't know if you can then use these later on for the usages, or if that is necessary - it can be made complicated as you can have multiple glossaries.
\newacronym[〈key-val list〉]{〈label〉}{〈abbrv〉}{〈long〉}
\newglossaryentry{〈label〉}{name={〈name〉},description={〈description〉},〈other options〉}
\longnewglossaryentry{〈label〉}{name={〈name〉},〈other options〉}{〈description〉}
From the glossaries-extra
there is also
\newabbreviation[〈options〉]{〈label〉}{〈short〉}{〈long〉}
From the base package: glossaries
here are the essential commands:
\gls
\glslink[〈options〉]{〈label〉}{〈link text〉}
\glsdesc
\glstext[〈options〉]{〈label〉}[〈insert〉]
\glsdisp[〈options〉]{〈label〉}{〈link text〉}
There are also a dizzying array of plural and uppercase variants, only the main \gls
form is worth doing this:
Uppercase variants
Plural variants:
These all take the form: \GLS[〈options〉]{〈label〉}[〈insert]〉]
There are also the acronym usages, with shortcuts, personally I do not use these - although for the acronyms it's probably easy to implement, I'm not sure about the shortcuts. base package acronyms and shortcut table see the preceding pages (179-180) for the definitions.
And the glossaries-extra
version.
[http://mirrors.ibiblio.org/CTAN/macros/latex/contrib/glossaries-extra/glossaries-extra-manual.pdf#9f]
There is also a rather complete listing of samples tex files if that is of any use.
Does this help? Is this too much?
Thanks for this nice intro!
Does this help? Is this too much?
Yes. No. :)
It seems to me that this would be a very useful new feature. But it seems, too, that implementation would require quite some work.
If I understand correctly, we would have to parse the file, e.g., main.glsdefs
that contains the replacement texts (field name
). On \gls{label}
or similar, we then could insert the correct expansion. For acronyms, we should insert the full text (fields description
or long
?). To be fully correct, the latter only should be done on the first occurence, which is difficult in case of a multi-file-document.
Additionally, we would need to generate a list with fields name
and description
on macro \printglossary
.
Would do you think? Does this cover the main points? Could one omit something?
You're understanding is correct.
Since the glossaries
package is so general, (you can make glossary terms appear as acronyms in shortened form with \gls,\acr
depending on various package options, which further complicates being fully-correct.
I'm not sure what grammar rules there are for acronyms, but perhaps we can sidestep the issue.
I assume that wherever an acronym might appear the full term could be substituted, the problem being in mixing acronym and the full term after usage is considered bad.
AFAIK this is not even considered by the grammar checkers anyway.
So just replacing on every occurrence either the acronym or replacement term (name
) would be sufficient?
I think we can omit the \printglossary part, (at least for my usage as I include the definitions as \input{glossary.tex}
).
Doesn't yalafi already parse the terms of the definition?
There is (also a .bib
method to store glossary terms)[http://tug.ctan.org/macros/latex/contrib/glossaries/glossariesbegin.pdf#option4], but I haven't used this so I cannot comment - is that out of scope for YaLafi
?
(YaLafi
has really improved my Masters thesis, so thanks again :) )
So just replacing on every occurrence either the acronym or replacement term (name) would be sufficient?
I agree. We can simply insert the replacement for both acronyms and other glossary entries. The long version of an acronym can be checked by the proofreader when expanding the glossary itself. It seems that the text
or plural
values are the right entries from the .glsdefs file, but I will have to check that further.
I think we can omit the \printglossary part, (at least for my usage as I include the definitions as \input{glossary.tex}). Doesn't yalafi already parse the terms of the definition?
Will have to think that over. Others might place their definitions directly in the preamble. It appears that implementing \printglossary
will be a rather small task, once the .glsdefs file has been parsed. And yes, currently the arguments of, e.g., \newglossaryentry
are simply copied to the plain-text output of the filter. But this includes the field names as description=
, too.
There is (also a .bib method to store glossary terms)[http://tug.ctan.org/macros/latex/contrib/glossaries/glossariesbegin.pdf#option4], but I haven't used this so I cannot comment - is that out of scope for YaLafi?
This is probably for 'further study' :)
(YaLafi has really improved my Masters thesis, so thanks again :) )
You are welcome, happy to hear that. But main thanks are due to the people from LanguageTool. Without this software, there would have been no reason to develop YaLafi.
OK, I have added an experimental version to branch glossaries.
For \newacronym etc., I followed your suggestion. These macros extract plain text from the description / long field directly at the original place. First letter is capitalised, a final dot is appended. This gives the right problem location in case there is a spelling / grammar error. The 'name' field is seen by the proofreader in the normal text, so it is checked there.
There are some caveats, see glossaries.py.
\LTinput{main.glsdefs}
into each LaTeX source file that uses \gls etc.Could you please have a look at it? Does it work for your documents?
Seems to be working well! (I'm using the docdef=atom
option).
Ony my first usage the only problem I have is with the appending of the full-stop (.).
In my glossaries, I have quite long entries, and so I include a full-stop and punctuation. ~~So in the document's usage, when I use something at the end of the sentence I get an error saying Don't put a space before the full stop.
e.g.
The orientation is due to \gls{CD}.
~~
EDIT: The definitions don't seem to be substituted (or detected?) Now that I look at the full output (rather than just the VIM summary) so the example above becomes "The orientation is due to ."
In the glossary definitions, I also get the error saying Two consecutive dots
.
\newglossaryentry{motionprimitives}{%
name={motion primitives},
description={A motion primitive is a pre-computed motion that a robot can use in some manner.} % <-- Two consecutive dots [E]:[lty]
}
Perhaps I am abusing how a glossary is normally used, the annoyance is minor. I assume for most users who just have a single line definition the full-stop injection is probably necessary for the other rules.
Thanks for testing! Your example seems to show that the substitutions with \gls etc. work properly "in real life".
Perhaps I am abusing how a glossary is normally used, the annoyance is minor. I assume for most users who just have a single line definition the full-stop injection is probably necessary for the other rules.
This is just a first proposal, and your usage eventually should be covered, too. One solution that comes to my mind: the filter could only append a full stop, if the description does not end with one of '.!?'.
OK, the idea concerning the full stop is included in branch glossaries.
Does it now work flawlessly with your documents? I then would merge into master.
There must be a problem in my usage,
error:
Line 46, column 63, rule ID THE_SENT_END[1]
Message: Did you forget something after 'a'?
Suggestion:
... by a . If ...
for usage: ...by a \gls{TO}. If blah blah
\newacronym{TO}{TO}{trajectory optimization or trajectory optimizer}
In my report.glsdefs
I have the term:
\ifglsentryexists{TO}{}%
{%
\gls@defglossaryentry{TO}%
{%
name={\protect \glsabbrvfont {TO}},%
sort={TO},%
type={acronym},%
first={\protect \glsfirstlongfont {trajectory optimization or trajectory optimizer}\protect \glsxtrfullsep {TO}(\protect \glsfirstabbrvfont {TO})},%
firstplural={\protect \glsfirstlongfont {trajectory optimization or trajectory optimizers}\protect \glsxtrfullsep {TO}(\protect \glsfirstabbrvfont {TOs})},%
text={\protect \glsabbrvfont {TO}},%
plural={\protect \glsabbrvfont {TOs}},%
description={trajectory optimization or trajectory optimizer},%
descriptionplural={trajectory optimization or trajectory optimizer},%
symbol={\relax },%
symbolplural={\relax },%
user1={},%
user2={},%
user3={},%
user4={},%
user5={},%
user6={},%
long={trajectory optimization or trajectory optimizer},%
longplural={trajectory optimization or trajectory optimizers},%
short={TO},%
shortplural={TOs},%
counter={page},%
parent={},%
see={},%
alias={},%
seealso={},%
category={acronym},%
%
}%
}%
FWIW: I reinstalled using pip3 install --user --upgrade git+https://github.com/matze-dd/YaLafi.git@glossaries
This is strange. When copying your excerpts to my system with YaLafi downloaded from the glossaries branch, the TO is correctly inserted for \gls{TO}.
Did you insert
\newcommand{\LTinput}[1]{} % only if not yet seen by LaTeX --> better placed in the preamble
\LTinput{report.glsdefs}
in the file containing ...by a \gls{TO}. If blah blah
before usage of \gls?
EDIT: I have added an error message for the case that a \gls etc. does not find the given label.
I have these both in my preamble.
I have also tried putting \LTinput{report.glsdefs} \LTinput{../build/report.glsdefs}
in the relevant files
chapters/chapterX.tex
. Also in the main report.tex
.
Any ideas?
On Wed, 12 Aug 2020 at 20:43, matze-dd notifications@github.com wrote:
This is strange. When copying your excerpts to my system with YaLafi downloaded from the glossaries branch, the TO is correctly inserted for \gls{TO}.
Did you insert
\newcommand{\LTinput}[1]{} % only if not yet seen by LaTeX --> better placed in the preamble \LTinput{report.glsdefs}
in the file containing ...by a \gls{TO}. If blah blah before usage of \gls?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/matze-dd/YaLafi/issues/41#issuecomment-673045040, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPWSWZG7HDAI3YWAUGINMDSALPGRANCNFSM4PUXCDFQ .
Any ideas?
Not really. But ... :)
With your above report.glsdefs, it should be possible to say in some file xyz.tex:
\LTinput{report.glsdefs}
This is a \gls{TO}.
On
python[3] -m yalafi xyz.tex
you should get the output This is a TO.
.
Here is my working minimal example. Main file z.tex:
\documentclass{article}
\usepackage[docdef=atom]{glossaries-extra}
\makeglossaries
\newcommand{\LTinput}[1]{}
\input{gloss.tex}
\begin{document}
\input{sec.tex}
\end{document}
sec.tex:
\LTinput{z.glsdefs}
This is a \gls{TO}.
gloss.tex:
\newacronym{TO}{TO}{TO description}
z.glsdefs:
\ifglsentryexists{TO}{}%
{%
\gls@defglossaryentry{TO}%
{%
name={\protect \glsabbrvfont {TO}},%
sort={TO},%
type={main},%
first={\protect \glsfirstabbrvfont {TO}},%
firstplural={\protect \glsfirstabbrvfont {TOs}},%
text={\protect \glsabbrvfont {TO}},%
plural={\protect \glsabbrvfont {TOs}},%
description={TO description},%
descriptionplural={TO description},%
symbol={\relax },%
symbolplural={\relax },%
user1={},%
user2={},%
user3={},%
user4={},%
user5={},%
user6={},%
long={TO description},%
longplural={TO descriptions},%
short={TO},%
shortplural={TOs},%
counter={page},%
parent={},%
see={},%
alias={},%
seealso={},%
category={acronym},%
%
}%
}%
Too fast! I didn't read your error description exactly enough.
How do you edit file chapters/chapterX.tex
? If you go to directory chapters/
and open it there, then report.glsdefs
cannot be found by YaLafi, it is now ../report.glsdefs
!
If you use Vim, then best stay in the project's root directory and say vi chapters/chapterX.tex
. Otherwise, you have to write \LTinput{../report.glsdefs}
in chapters/chapterX.tex
.
It was a path error! Had to do build/report.glsdefs
. My CWD was at the
root of the project, but I was trying to do relative to a chapter in a
subfolder, into the build
folder! Seems to work well now
On Thu, 13 Aug 2020 at 17:13, matze-dd notifications@github.com wrote:
Too fast! I didn't read your error description exactly enough.
How do you edit file chapters/chapterX.tex? If you go to directory chapters and open it there, then report.glsdefs cannot be found by YaLafi, it is now ../report.glsdefs!
If you use Vim, then best stay in the project's root directory and say vi chapters/chapterX.tex. Otherwise, you have to write \LTinput{../report.glsdefs} in chapters/chapterX.tex.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/matze-dd/YaLafi/issues/41#issuecomment-673537005, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPWSW5UGXCDOOYAI5NTUN3SAP7IDANCNFSM4PUXCDFQ .
It was a path error! ... Seems to work well now
Great :)
I have added a comment concerning the path problem to the intro in glossaries.py. This is now merged to the master branch.
Thanks again for proposing this improvement, and for the testing!
Could the glossaries / glossaries-extra packages commands be supported? e.g.
\acr, \gls, \glspl
etc commandsI know you've written some documentation on how to extend and support different packages, but I haven't got the time currently to do it myself (though hopefully, I'll revisit this issue at some time). Thanks for YaLafi, it's really great!