当前位置:网站首页>【latex异常和错误】Missing $ inserted.<inserted text>You can‘t use \spacefactor in math mode.输出文本要注意特殊字符的转义
【latex异常和错误】Missing $ inserted.<inserted text>You can‘t use \spacefactor in math mode.输出文本要注意特殊字符的转义
2022-08-11 06:12:00 【键盘即钢琴】
一、背景
问题代码如下
\documentclass{article}
\usepackage{verbatim}
\usepackage{amsmath}
\begin{document}
Roman number_XII\@. Yes.
\end{document}使用xelatex引擎进行渲染后,出现下面的错误——【Missing $ inserted.<inserted text>】和【You can't use `\spacefactor' in math mode.\@->\spacefactor 】

二、解决方法
参考:Getting the error "Missing $ inserted" in LaTeX - Stack Overflow
由于下划线符号_属于数学公式中的下标符号,所以正文出现它的时候,应该予以转义;不然就会让引擎误以为这是公式的代码,从而警告用户为啥不加公式环境符$$。
知道原因后,我们在正文部分将_用\转义,结果就正常输出了。
或者,用逐字输出命令\verb将所有符号原封不动地输出出来,而不需要考虑对特殊符号(比如下划线符号_,再比如分组符号{},再比如公式环境符号$,当然还有其他)的转义。
\documentclass{article}
\usepackage{verbatim}
\usepackage{amsmath}
\begin{document}
Roman number\_XII\@. Yes.\\
\verb!Roman number_XII\@. Yes.!
\end{document}渲染结果

边栏推荐
猜你喜欢
随机推荐
Edge provides label grouping functionality
梅科尔工作室——BP神经网络
已解决EROR 1064 (42000): You have an error in. your SOL syntax. check the manual that corresponds to yo
Amazon Get AMAZON Product Details API Return Value Description
HCIA knowledge review
姿态解算-陀螺仪+欧拉法
淘宝API常用接口与获取方式
Redis + lua implements distributed interface current limiting implementation scheme
【预约观看】Ambire 智能钱包 AMA 活动第四期即将举行
ssh服务攻防与加固
Douyin API interface
Unity3D learning route?
Implementation of FIR filter based on FPGA (5) - FPGA code implementation of parallel structure FIR filter
Go语言实现Etcd服务发现(Etcd & Service Discovery & Go)
Shell:三剑客之awk
NTT的Another Me技术助力创造歌舞伎演员中村狮童的数字孪生体,将在 “Cho Kabuki 2022 Powered by NTT”舞台剧中首次亮相
联想集团:2022/23财年第一季度业绩
Unity3D 学习路线?
How Unity handles C# under the hood
Taobao API interface reference









