TeX - LaTeX Asked on September 27, 2020
I am currently writing a research essay and was wondering if it is possible to create a function that links a small part of the output of the texcount function to another location in the file, in my case the title page.
Here is a MWE (minimum working example) of my LaTeX file:
documentclass[12pt,a4paper,footheight=20pt,footsepline,headheight=20pt,headsepline]{article}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage[english]{babel}
usepackage[nottoc,numbib]{tocbibind}
usepackage{scrlayer-scrpage,xcolor,lastpage,verbatim,moreverb,lmodern,textcomp,tikz,float,pgf,pgfplots,hyperref}
pgfplotsset{compat=newest}
ihead{color{gray} ...}
chead{color{gray} ...}
ohead{color{gray} ...}
cfoot{color{gray} thepage of pageref{LastPage} }
setcounter{secnumdepth}{3}
setlength{headheight}{25pt}
usepackage{setspace}
doublespacing
addtokomafont{headsepline}{color{gray}}
addtokomafont{footsepline}{color{gray}}
immediatewrite18{texcount -sum main.tex > wordcount}
newcommandwordcount{verbatiminput{wordcount}}
title{...}
author{...}
date{vspace{8cm} 4000 Words in Essay || 500 Words in RPPF}
begin{document}
maketitle
thispagestyle{empty}
newpage
tableofcontents
newpage
section{Introduction}
newpage
section{...}
newpage
section{Conclusion}
newpage
begin{thebibliography}{}
bibitem{xxx}
bibitem{yyy}
end{thebibliography}
newpage
section{RPPF}
newpage
wordcount
end{document}
I apologize for the unorthodox use of the date function 😀
Essentially what I want to do is replace the “500” in the date by a self-updating word count of the RPPF section.
If this is possible please let me know.
Thanks
I could get the total number of words (including section headers) from texcount by modifying the following idea https://app.uio.no/ifi/texcount/faq.html#latexcall (made some modifications to get the number of words, see MWE below).
To extract the words for the specific subsection, I had to rely on a bash script, see below:
#!/bin/bash
awk '/RPPF/ {print $1}' main.all | awk -F+ '{print $1}'
which I called getwords.sh
. This provides the words (excluding the word 'RPPF') in the section 'RPPF'.
The file main.all
is the output of texcount
. You can put everything together into a single script if you want.
See MWE below.
Since the output files are just a single number, I just have included them instead of importing via verbatiminput
. However, I created the commands as well if that's what you need.
Hope this helps.
documentclass[12pt,a4paper]{article}
usepackage{verbatim}
immediatewrite18{texcount -out=jobname.all jobname.tex; ./getwords.sh > jobname.sec}
immediatewrite18{texcount -out=jobname.wrd -template="{word}" jobname.tex }
newcommandallcount{verbatiminput{jobname.all}}
newcommandwordcount{verbatiminput{jobname.wrd}}
newcommandseccount{verbatiminput{jobname.sec}}
title{A Title}
author{An Author}
date{}
begin{document}
maketitle
begin{center}
Total number of words: input{jobname.wrd}
Total number of words in section RFFP: input{jobname.sec}
end{center}
thispagestyle{empty}
newpage
tableofcontents
newpage
section{Introduction}
Test
section{Problem}
Test Test Test
section{Conclusion}
begin{thebibliography}{}
bibitem{xxx}
bibitem{yyy}
end{thebibliography}
section{RPPF}
Test Test Test
newpage
allcount
end{document}
Answered by geguze on September 27, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP