我正在尝试使用 Texcount 在我的 overleaf 文件中添加自动字数统计。我已按照https://www.overleaf.com/learn/how-to/Is_there_a_way_to_run_a_word_count_that_doesn%27t_include_LaTeX_commands%3F确切地。
但是我的输出总是(使用 quickwordcount 时):x 个单词(错误:1)
字数统计实际上是正确的,所以我的第一个问题是:为什么 texcount 的 -q 参数不起作用?错误应该被隐藏!
经过进一步检查,使用详细输出,我发现错误实际上是:“!!! 在路径 [./] 中未找到文件 main.bbl。!!!”
我也觉得很奇怪,因为目录中有一个 main.bbl 文件。
我该如何解决这个问题?
我的代码:
文件 main.tex
\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\title{Bibliography management: BibTeX}
\usepackage{verbatim}
\newcommand{\detailtexcount}[1]{%
\immediate\write18{texcount -merge -sum -incbib #1.tex output.bbl > #1.wcdetail }%
\verbatiminput{#1.wcdetail}%
}
\newcommand{\quickwordcount}[1]{%
\immediate\write18{texcount -1 -sum -merge -q #1.tex output.bbl > #1-words.sum }%
\input{#1-words.sum} words%
}
%TC:incbib
\begin{document}
\maketitle
\detailtexcount{main}
This document is an example of BibTeX using in bibliography management. Three items are cited: \textit{The \LaTeX\ Companion} book \cite{latexcompanion}, the Einstein journal paper \cite{einstein}, and the Donald Knuth's website \cite{knuthwebsite}. The \LaTeX\ related items are \cite{latexcompanion,knuthwebsite}.
\medskip
\bibliographystyle{unsrt}%Used BibTeX style is unsrt
\bibliography{sample}
\end{document}
样本
@article{einstein,
author = "Albert Einstein",
title = "{Zur Elektrodynamik bewegter K{\"o}rper}. ({German})
[{On} the electrodynamics of moving bodies]",
journal = "Annalen der Physik",
volume = "322",
number = "10",
pages = "891--921",
year = "1905",
DOI = "http://dx.doi.org/10.1002/andp.19053221004"
}
@book{latexcompanion,
author = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
title = "The \LaTeX\ Companion",
year = "1993",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts"
}
@misc{knuthwebsite,
author = "Donald Knuth",
title = "Knuth: Computers and Typesetting",
url = "http://www-cs-faculty.stanford.edu/\~{}uno/abcde.html"
}
目录中还添加了一个 latexmkrc 文件,内容如下:
END { system('cp', 'output.bbl', 'main.bbl'); }