I'd like a warning to show up in my document as soon as it exceeds a defined length. I found how to print the the total word count of my document (assuming the main file to be main.tex):
\newcommand{\mytexcount}{%
\immediate\write18{texcount -merge -sum -0 main.tex > main.wcdetail }%
\verbatiminput{main.wcdetail}%
}
...
\mytexcount
further, I can print a warning dependent on a threshold condition like so:
\def\mywordthreshold{3000}
\newcommand{\countwarning}{
\ifnum [some number]>\mywordthreshold
\emph{CAUTION: THIS TEXT SEEMS LONGER THAN \mywordthreshold WORDS}
\fi
}
...
\countwarning
However, I'm not sure, how to get the the output from \mytexcount into the condition, as it seems not to be interpreted as a number. If anyone can help with that or has an alternative suggestion, any feedback would be much appreciated!
I've created a minimal working example on Overleaf with what I've got so far. Here is its code:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{verbatim}
\title{Word Count Example}
\newcommand{\mytexcount}{%
\immediate\write18{texcount -merge -sum -0 main.tex > main.wcdetail }%
\verbatiminput{main.wcdetail}%
}
\def\mywordthreshold{3000}
\newcommand{\countwarning}{
\ifnum 3001>\mywordthreshold
\emph{CAUTION: THIS TEXT SEEMS LONGER THAN \mywordthreshold WORDS}
\fi
}
\begin{document}
\maketitle
\section{Ipsum}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
\section{Word Count}
Number of words is: \mytexcount
Warning should follow this questionmark? \countwarning
\end{document}
\expandafter\newcommand\expandafter\doccount{\input{main.wcdetail}}but I couldn't make that (or something similar) work. You could do a simpler version of https://tex.stackexchange.com/a/547259/107497 if nothing else. – Teepeemm Jun 03 '20 at 16:23