I want to control the size of a piece of text in my Latex document (for an application for research funding), and ignore the latex code. I want to count also the whitespaces. I really want to measure the size of the text generated in the PDF. I coded this macro getting inspiration from here.
\documentclass{article}
\usepackage{stringstrings}
\newcommand{\numchars}[1]{%
\convertchar[q]{#1}{ }{}
{\noindent
\textit{(\stringlength{\thestring} signs)}
#1}}
\begin{document}
\numchars{Longtemps, je me suis couché de bonne heure. Parfois, à peine ma bougie éteinte, mes yeux se fermaient si vite que je n’avais pas le temps de me dire : " Je m’endors. " \label{À la recherche du temps perdu}}
\end{document}
I have three issues here:
- Exotic characters like "é" count as several characters
- It looks like beyond 500 characters the code fails
- Any Latex code, any citation for instance, will generate an error
pandoc -t asciidoc test.tex. You could then pipe the output towc -c. If you want to exclude new line characters insertsed -z "s:\n::g"in the pipe. If you also want to exclude spaces, add\sto the pattern. for instance:pandoc -t asciidoc test.tex | sed -z "s:\n\|\s::g" | wc -c. – Celdor Feb 15 '24 at 13:15stringstrings(which I wrote). Don't use it. – Steven B. Segletes Feb 15 '24 at 19:48