最近使用overleaf,vscode对论文进行排版,遇到了一些报错,因此总结一些经验和技巧,记录下来,供自己日后查阅。
1. overleaf无法实现反向搜索
在使用overleaf的过程中,发现双击PDF的某一行无法跳转到tex文件的源代码处,同时发现每次编译时PDF加载很慢。
原因:选择浏览器作为PDF阅读器。
解决方法:点击menu,选择overleaf作为PDF阅读器。
2. 将论文里面的表格转换为Latex格式的在线工具
将表格转换为Latex格式的在线工具,它可以轻松实现单元格元素的居中对齐,加边界线,合并单元格等操作。
3. 编译错误
3.1 编译表格时报错
- LaTeX Error: Environment tblr undefined.
解决方法:在文档开始处,\documentclass后面加上\usepackage{tabularray}
又出现了新的错误:LaTeX Error: File `tabularray.sty’ not found.
经查阅,这个帖子提供了问题出现的原因和解决方法(The package tabularray doesn’t seem to work on Overleaf)。
解决方法:把texlive的版本换成2022版
3.2 undefined control sequence
- 使用\captionsetup{font={small,stretch=1.25}, justification=justified}命令时出现undefined control sequence错误,
解决办法:在文档开始处,加上\usepackage{caption}命令。
\usepackage{caption}
3.3 使用\usepackage{apacite}报错
因为期刊要求参考文献是APA格式,所以我使用\usepackage{apacite},在文中使用\cite{}引用参考文献,出现编译错误,
User
Extra \endgroup.
\@cite ...#3\fi \NAT@@close \else #1\fi \endgroup
解决方案:使用apalike包
\usepackage{babel}
\usepackage{apelike}
\bibliographystyle{apalike}
3.4 报错“I found no \citation commands”
前提:已经引用\usepackage{cite}和\usepackage{iopams}
出现错误:
I found no \citation commands
出现错误的原因:在整个tex文件中没有引用参考文献,\cite{cite_key}
3.5 .bbl文件报错:.bbl: Error: LaTeX Error: Something’s wrong–perhaps a missing \item.
出现错误:
LaTeX Error: Something's wrong--perhaps a missing \item.
解决方案:删除原有的.log .aux .bbl .blg文件
3.6 .bbl文件报错:Missing $ inserted. _ LaTeX Extra }, or forgotten $.
使用iopart.cls时,出现错误:
对应的.bib文件中的内容
出现错误的原因:url和DOI字段中有下划线(_),需要转义该下划线。
解决方案:把_改为{\_}
@Inbook{Ching2013,
author="Ching, Wai-Ki
and Huang, Ximin
and Ng, Michael K.
and Siu, Tak-Kuen",
title="Higher-Order Markov Chains",
bookTitle="Markov Chains: Models, Algorithms and Applications",
year="2013",
publisher="Springer US",
address="Boston, MA",
pages="141--176",
isbn="978-1-4614-6312-2",
doi="10.1007/978-1-4614-6312-2{\_}6",
url="https://doi.org/10.1007/978-1-4614-6312-2{\_}6"
}
4. 如何使连续的参考文献能够中间用破折号连起来?比如[6,7,8,9]变成[6-9]?
在tex文件开始,加上
\usepackage[numbers,sort&compress]{natbib}
5. 在使用浏览器预览PDF的前提下,如何实现正向+反向搜索?
5.1 正向搜索
5.2 反向搜索
Ctrl+左键:由PDF定位到源代码
四级标题
五级标题
参考教程
[1] https://tex.stackexchange.com/questions/194084/apacite-not-working-in-tex
[2] https://tex.stackexchange.com/questions/350907/error-latex-error-somethings-wrong-perhaps-a-missing-item
[3] https://tex.stackexchange.com/questions/18045/problem-with-compiling-bibtex-no-citation-commands-error
[4] latex中同一处引用多篇文献