为什么你应该避免在LaTeX/Overleaf中使用`\it`和`\bf`:加粗/斜体文本的正确方式
In the world of LaTeX, one of the most popular typesetting systems, there are several commands that have become outdated over the years. Two such commands are \\it
and \\bf
. While you might find these commands in older documents, there are compelling reasons to avoid them in modern LaTeX documents.
需要一个简单的解决方案来管理您的BibTeX条目吗?探索CiteDrive!
- 基于Web的现代参考文献管理
- 与研究同行合作和分享
- 与Overleaf集成
- 全面的BibTeX/BibLaTeX支持
- 直接从您的浏览器保存文章和网站
- 从包含数千万参考文献的数据库中搜索新文章
1. They Overwrite Each Other
One of the primary reasons to avoid using \\it
and \\bf
is that they don’t nest as one might expect. This means that if you attempt to set text in both italic and bold by using both commands, only the last command specified will be applied.
Example:
\\it\bf My Text
This won’t display the text in both italic and bold as one might expect. Instead, only the bold command will be applied because \\bf
overwrites the \\it
command.
2. Modern Alternatives are Available
Fortunately, there are modern alternatives that don’t have this issue. The commands \textit{}
and \textbf{}
can be combined seamlessly to achieve the desired effect.
Example:
\textit{\textbf{My Text}}
This will display the text in both italic and bold, just as expected.