我有一个巨大的 bib 文件,我希望我的参考文献采用句子大小写,而不是标题大小写。我发现了一个可能可以实现的函数,但我不知道如何使用它。我是 Latex 的新手。有人可以指导我如何自动化这个过程吗?
编辑 1:特别是对于我的 .bib 文件中未格式化的标题,我希望我的参考文献采用以下格式:
将标题中的每个单词大写,除了 a、an、the 等单词,除非它们是标题的开头。不要更改带有 $、{} 或 的单词,因为这些是受保护的或 LaTeX 命令。
我上面提到的链接使用的想法是:
我们的想法的要点是获取标题,将其拆分成单词,将每个需要大写的单词大写,将单词连接在一起,然后将条目标题设置为新的大写标题。
编辑2:我上面分享的链接中的功能:
defvar jmax-lower-case-words
'("a" "an" "on" "and" "for"
"the" "of" "in")
"List of words to keep lowercase")
(defun jmax-title-case-article (&optional key start end)
"Convert a bibtex entry article title to title-case. The
arguments are optional, and are only there so you can use this
function with `bibtex-map-entries' to change all the title
entries in articles."
(interactive)
(bibtex-beginning-of-entry)
(let* ((title (bibtex-autokey-get-field "title"))
(words (split-string title))
(lower-case-words '("a" "an" "on" "and" "for"
"the" "of" "in")))
(when
(string= "article" (downcase (cdr (assoc "=type=" (bibtex-parse-entry)))))
(setq words (mapcar
(lambda (word)
(if (or
;; match words containing {} or \ which are probably
;; LaTeX or protected words
(string-match "\\$\\|{\\|}\\|\\\\" word)
;; these words should not be capitalized, unless they
;; are the first word
(-contains? lower-case-words (s-downcase word)))
word
(s-capitalize word)))
words))
;; Check if first word should be capitalized
(when (-contains? jmax-lower-case-words (car words))
(setf (car words) (s-capitalize (car words))))
;; this is defined in doi-utils
(bibtex-set-field
"title"
(mapconcat 'identity words " "))
(bibtex-fill-entry))))