2

I need to figure out how many percent of the text in my latex document which consists of quotes (in block quotes, particularly). I have wrapped all quotes in the block quotes command:

\begin{quote}
\end{quote}

Is there any tool which would easily allow me to either:

  1. Calculate the percentage directly, or
  2. Extract all content within the block quotes command, and also (in a separate output) extract all content which is outside of the block quotes command. So that I can input both texts into an online word counter, and calculate the percentage from comparing the resulting amount of words.

I am using Overleaf, so it's limited what packages I can run, but I think it can run most.

Magne
  • 221
  • It would be a nice programming exercise for e.g. Python. Would running a Python Script be okay for you? – Uwe Ziegenhagen Mar 16 '20 at 18:16
  • 1
    @UweZiegenhagen Yeah, it would be, but I'd rather not bother to fiddle with it. I was able to find a neat and quick LaTeX solution though. See my answer. – Magne Mar 16 '20 at 19:25
  • 3
    texcount is able to count words of delimited parts of the text, as well as text of some common LaTeX structures. See https://tex.stackexchange.com/a/277734/11604 – Fran Mar 16 '20 at 19:56
  • @Fran Yup, that was the one I ended up using. I found the online service, and linked it in my answer below. – Magne Mar 19 '20 at 15:52

1 Answers1

3

I was able to use the extract package to get just the quotes out in a separate tex document:

% To extract all block quotes to a separate quotes.txt file, downloadable in the bottom of the "log and output files" page in Overleaf
\usepackage[active,generate=quotes,extract-env={quote}]{extract}

Then I was able to use the LaTeX word counter found here:

https://app.uio.no/ifi/texcount/online.php

Running it first on the original file, and then on the quotes.tex file, and compare the word counts.

Magne
  • 221