Is they a way of obtaining a word count in LyX that does not include text inside captions (Figures, tables etc.)?
2 Answers
One way is to remove the insets for which you don't want the words to be counted. First backup your document. Then, to remove all of the caption insets try the following on the mini-buffer (alt+x). For LyX versions newer than 2.3.0, use the following command:
command-sequence inset-forall Caption char-delete-forward force; statistics; undo
For LyX versions before 2.3.0, remove the "force" in the command above.
What this does is the following
- Remove all Caption insets
- Word count
- Undo "Remove all Caption insets"
- 13,164
-
is there a way of extending the command above to exclude notes and appendices as well? – joshlk May 06 '13 at 15:18
-
@Josh For notes, yes. You can see an example of inset-forall for notes in Help > LFUNs and searching for LFUN_INSET_FORALL. So you would just add that new command as another element in the ';'-delimited command-sequence and then probably you need another 'undo' at the end. For appendices I don't think this would work. You could use an LFUN to find (see e.g. LFUN_WORD_FIND) a certain phrase and and then use LFUNS to delete until the end. It's all about looking for the right LFUNs. Note that if you have View > Messages, when you do something in the GUI it will often list the corresponding LFUNs. – scottkosty May 06 '13 at 15:41
-
One correction: at least as of Lyx 2.3, you must add 'force' after 'char-delete-forward' for the delete action to take place on a large inset – Oded R. Feb 13 '22 at 01:18
-
1@OdedR. Nice fix! I edited it in. – scottkosty Feb 17 '22 at 15:16
The simplest but most tiresome way (and as far as I know only way in LyX) would be to select step by step parts of the LyX document skipping the parts you do not want to count and use "Tools > Statistics" to note a word count. Finally, all word counts need to be added.
Alternatively, one can export the LyX document to a LaTeX file and apply all sorts of TeX related methods as shown in: Is there any way to do a correct word count of a LaTeX document? Especially, TeXcount offers ways to exclude captions and certain environments.
-
@Josh This way could be set up automatically by using a custom converter (see Help > Customization) or maybe plyx, which is a third-party tool to run quick python scripts (I've never tried it out though). – scottkosty Apr 25 '13 at 15:29