Jak mogę wyświetlić liczbę słów w moim dokumencie?

Jan 12 2021

Do magazynu muszę napisać mały artykuł o max. 700 słów. Chciałbym mieć na końcu liczbę słów. Znalazłem następujący kod tutaj na StackExchange. Ale kiedy spróbowałem tego sam, nie zadziałało. Niestety nie mogę ustosunkować się do tematu.

\documentclass{article}

\newcommand\wordcount{\input{|"texcount -inc -sum -0 -template={SUM} \jobname.tex"}}

\begin{document}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec eleifend pulvinar quam, vel suscipit urna tincidunt eget.

This document has \wordcount words.

\end{document}

Otrzymuję następujący błąd:

! Błąd LaTeX: Nie znaleziono pliku `| texcount -inc -sum -0 -template = {SUM} test.tex '.

Wpisz X, aby zakończyć lub kontynuować, albo wprowadź nową nazwę. (Domyślne rozszerzenie: tex)

Wpisz nazwę pliku:

Czy ktoś wie, co się dzieje?

Odpowiedzi

1 Fran Jan 13 2021 at 04:28

\documentclass{article}
\parskip1em\parindent0pt
\immediate\write18{texcount -1 -sum  \jobname.tex > wordcount.aux }
\begin{document}
\section*{How to compile this file}
From the command line (The damn buttonless  black window): \par
\hfil\texttt{pdflatex --shell-escape  \jobname .tex}\par  
From  your favourite  \LaTeX\ editor: \par
\hangindent1em\hangafter0 Edit your editor configuration to enable the  option \texttt{--shell-escape} of  the \texttt{pdflatex} compiler. You should {\em not} use this option by foreing  documents (like this) without know if the source is safe.\par

% This part is not counted
%TC:ignore 
 Word count = {\bfseries\large \input{wordcount.aux}}
%TC:endignore   
\end{document}