문서 내에서 단어 수를 표시하려면 어떻게합니까?

Jan 12 2021

잡지의 경우 최대의 작은 기사를 작성해야합니다. 700 단어. 마지막에 단어 수를 갖고 싶습니다. 여기 StackExchange 에서 다음 코드 를 찾았습니다. 그러나 내가 직접 시도했을 때 작동하지 않았습니다. 안타깝게도이 주제에 대해 답변 할 수 없습니다.

\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}

다음과 같은 오류가 발생합니다.

! LaTeX 오류 : 파일`| texcount -inc -sum -0 -template = {SUM} test.tex 'not found.

종료하거나 계속하려면 X를 입력하거나 새 이름을 입력하십시오. (기본 확장자 : tex)

파일 이름 입력 :

아무도 무엇이 잘못되고 있는지 알고 있습니까?

답변

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}