Word count in LyX which does not include Figure captions

2,213

Solution 1

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

  1. Remove all Caption insets
  2. Word count
  3. Undo "Remove all Caption insets"

Solution 2

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.

Share:
2,213

Related videos on Youtube

joshlk
Author by

joshlk

Updated on February 18, 2022

Comments

  • joshlk
    joshlk over 1 year

    Is they a way of obtaining a word count in LyX that does not include text inside captions (Figures, tables etc.)?

  • scottkosty
    scottkosty over 10 years
    @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).
  • joshlk
    joshlk over 10 years
    is there a way of extending the command above to exclude notes and appendices as well?
  • scottkosty
    scottkosty over 10 years
    @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.
  • Oded R.
    Oded R. over 1 year
    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
  • scottkosty
    scottkosty over 1 year
    @OdedR. Nice fix! I edited it in.