当前位置:网站首页>【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}
渲染结果
边栏推荐
猜你喜欢
随机推荐
亚马逊API接口大全
When MySQL uses GROUP BY to group the query, the SELECT query field contains non-grouping fields
李沐d2l(十)--卷积层Ⅰ
Implementation of FIR filter based on FPGA (5) - FPGA code implementation of parallel structure FIR filter
Unity底层是如何处理C#的
基于FPGA的FIR滤波器的实现(5)— 并行结构FIR滤波器的FPGA代码实现
你是如何做好Unity项目性能优化的
公牛10-11德里克·罗斯最强赛季记录
maxwell 概念
mmdetection的安装和训练、测试didi数据集的步骤(含结果)
微信小程序功能上新(2022.06.01~2022.08.04)
1688 product interface
恒源云-Pycharm远程训练避坑指南
Find the shops that have sold more than 1,000 yuan per day for more than 30 consecutive days in the past six months
矩阵分析——矩阵分解
Daily sql-statistics of the number of professionals (including the number of professionals is 0)
maxwell concept
Strongly recommend an easy-to-use API interface
矩阵分析——微分、积分、极限
exness:黄金1800关口遇阻,静待美国CPI出炉