TeX - LaTeX Asked on November 1, 2021
I’m trying to work out how to recursively nest text and math mode. The following example seems to fail to compile, and does not render the right)
:
% "text, {$$int$$}, text" is an arbitrary string provided by software I
% do not control,
$$ operatorname{foo}left( text{text, {$$int$$}, text} right)$$
Is there a simple way to make this work?
The software you're using is flawed and there's essentially no safe method for making such generated code to work.
The problem is that text
eventually makes an hbox
in which the code is typeset using restricted horizontal mode where $$
has a peculiar behavior. Since display math makes no sense, TeX simply considers $$
as an empty math formula, when in restricted horizontal mode. So your int
appears outside math mode and an error ensues.
TeX now tries to enter math mode before rescanning int
, then finds the closing $
which ends math mode. It finds another one, which starts again math mode and now it finds a misplaced }
. Another error.
Fix the software producing that code, which is bad LaTeX under many other respects. To begin with, $$
should never be used in LaTeX.
Answered by egreg on November 1, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP