UPDATE: The problem I am having is due to having Python code inside a PythonTeX pycode
environment. Seems this causes a parsing error with the TeXcount Perl script.
I want to use TeXcount to count the words in my thesis. However, I have either run into a limitation of TeXcount or it's difficult to find an explanation (via documentation, here, forums, etc.) detailing how to alleviate my issue.
I have all the chapters in my thesis in a subfolder from the main .tex document. I call these via the following line (or similar, depending on the chapter name, obviously):
\include{\chaptersPath/background_information}
Within many of those chapter files, I have additional files stored a directory deeper for major topics/themes of that chapter, such as:
\input{\chaptersPath/background_information/literature}
The document compiles fine. And honestly, I'm not here currently to debate whether my file and directory structure is proper, the most efficient, etc.
I have tried defining \chaptersPath
variously as:
\newcommand{\buildFilesPath}{_build_files}%
or
\edef\buildFilesPath{./_build_files}%
Same behavior for both - The problem I have is that having this command or definition in the \input
doesn't seem to expand for texcount. TeXcount complains that the file is not found:
[1;31m!!! File not found or not readable: \chaptersPath/background_information !!![0m
I tried using -auxdir
and -dir
, but these seem to not make TeXcount happy because those commands are still in the \input
calls.
I also tried including \immediate\write18{texcount \jobname.tex -inc -out=\buildFilesPath/\jobname.sum}
in the preamble thinking perhaps it would recognize those commands (replaced with plain text path details). I was wrong; it doesn't. Funny thing here is that \buildFilesPath
and \jobname
do get recognized.
Lastly, I've tried playing around with including \expandafter
and this is totally not useful as well. It seems the texcount.exe
(even within the \immediate\write18
method simply cannot expand those file path definitions).
Question: Is it possible to resolve this problem somehow, while maintaining those commands defining the file/chapter paths?
I realize I can just go through and hardcode all the paths manually. But this is rather crappy for flexibility, if I want to create a new document using much of the same (La)TeX preamble and base .tex document but with a different file/folder structure. The current way requires just one change rather than finding and replacing a bunch of stuff every time.
\immediate\write18
, perhaps it had access to the expansions while LaTeX was in the process of compiling (perhaps putting it in ashipout
or somewhere similar). Honestly, I wasn't sure and was hoping for insight from learned people such as yourself!