Open A-Daneel opened 2 months ago
as the title states, when using the apa7 document class
VimtexCountWords
gives an inaccurate word count when done over a range. From my (minimal) testing, it seems to include the title.
That's fascinating. The :'<,'>VimtexCountWords
is actually slightly hacky. Notice the implementation:
When you use a selection, VimTeX will create a temporary file that keeps the current preamble. Notice that you will get 7 words even if you remove the \maketitle
command. Thus, it seems the apa7
class will include the title even if you don't use that command?
Thanks for responding, my viml isn't that great and I wondered how texcount worked on a range.
Am I correct in assuming that it creates a temporary file with the same class as the primary file (apa7 in this case)?
If so, the temp file should look like this when Some text.
is highlighted, right?
\documentclass[stu]{apa7}
\title{A title}
\shorttitle{A short title}
\author{An author}
\begin{document}
Some text.
\end{document}
which would render the following
This to me makes it less understandable, since the minimal version renders the shorttitle
but when asking the count it adds the title
. (notice that if you keep the title empty \title{}
it will give you the correct word count, but the rendered image does not change)
Yes, that's precisely what happens. Notice that the word count of this temp file is the count that texcount
provides, so if it is wrong, then that's not a bug in VimTeX, but a bug in texcount
.
Thanks for walking me through the VimTeX part of it. I'll open an issue on the texcount git, it sadly does look pretty stale (last commit is 4 years ago and it has 3 open issues and 1 pr). Or would you be open to including a workaround?
From some quick testing the behavior also seems to appear if you change the class to minimal. If it is a bug with \title
regardless of the class it could be something that hinder more people. (though, I don't really see a straight forward solution)
Thanks for walking me through the VimTeX part of it. I'll open an issue on the texcount git, it sadly does look pretty stale (last commit is 4 years ago and it has 3 open issues and 1 pr).
I think that is a good idea, even if it is apparently state. However, the maintainer did reply to the existing issues, so he might still suddenly be motivated to fix things?
Or would you be open to including a workaround?
Well, it seems somewhat fragile to add workarounds for texcount
to VimTeX. I would be much more interested if there happen to be valid alternative tooling that we could hook into.
Description
as the title states, when using the apa7 document class
VimtexCountWords
gives an inaccurate word count when done over a range. From my (minimal) testing, it seems to include the title.The odd thing is, if you run it over the entire document it seems to give the correct word count. Not sure how I'd go about debugging it further (and if it's an issue that belongs here or on the apa7 package).
Would love to take a shot at it, but I'll need some pointers to get started :)
Steps to reproduce
minimal latex file
if you highlight the "some text." line, and run
:'<,'>VimtexCountWords
it'll say it's 4 long. ("some text." + "A title")if you highlight the "some more text" line, and run
:'<,'>VimtexCountWords
it'll say it's 5 long. ("some more text." + "A title")If you highlight nothing and run
:VimtexCountWords
it'll give you the correct word count of 7.Expected behavior
When following the steps, I'd expect to only get the word count of the selection.
Actual behavior
Currently I get the selection and the title.
Do you use a latexmkrc file?
no
VimtexInfo