Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
$\{A\leqslant x\leqslant B\}$

Copy the code into Notebook, and you'll lose the less sign, this can be rendered well in Mathematica.StackExchange

$\{A\leqslant x\leqslant B\}$

And you can also ImportString["$\{A\\leqslant x\\leqslant B\\}$","TeX"]//CreateDocument,

Here is the problem, the leqslant was removed, are there any options of ImportString or are there any other methods to Import some latex codes without losing some information?

share|improve this question
It seems you need something like the "ConversionRules" option but in the opposite direction, as that appears to be only for conversion into LaTex. – Mr.Wizard Sep 3 '13 at 10:38
up vote 7 down vote accepted

No, there are no (documented) options of ImportString directly.

But who cares? Just get rid of leqslant, e.g., like this:

ImportString["$\{A\\leqslant x\\leqslant B\\}$" /.
  s_ String :> StringReplace[s,"leqslant" -> "leq"], "TeX"] // CreateDocument
share|improve this answer
yes, this is one way, the bad thing, I should build one replace rules, I'll use it if no better methods. – HyperGroups Sep 3 '13 at 10:26

This is longer than a comment, but does not provide a solution (obviously, Rolf's answer does the job perfectly).

Spelunking in ImportString reveals that it uses the same options as Import. Import on the other hand uses a set of private functions, one for each import format, with different option-sets. We are interested in $TeX$ import options. Ultimately, in the definition of System`Convert`TeXImportDump`validateInput, the following options are listed:

"InstallDir" :> System`Convert`TeXImportDump`$TeX2NBDir,
"OutputFile" -> None,
"InputPath" -> {},
"TeXCommand" -> "\\input amsmath.tns %\n",
"Verbose" -> False,
"StyleDefinitions" -> Null,
"MathLink" -> True,
"FEKernel" -> True,
"MathCommand" -> "math",
"MathLinkDebug" -> False,
"NotebookDebug" -> False,
"FullDebug" -> False,
"LogFile" -> Null,
"BaseFormat" -> Null,
"Flush" -> False,
"CoreDump" -> False,
"Raw" -> False,
"Normalize" -> True

General options are:

Path :> $Path,
ConversionOptions,(* Obsolete after v6.0 *)
CharacterEncoding -> "UTF8"

Using ImportString[..., "Verbose" -> True] reveals that we are indeed using the amsmath.tns file, that is the Wolfram interface for amsmath.sty. It's quite easy to figure out that \leqslant is defined in the amssymb.sty and amssymb.tns files (the .tns files can be found at FileNameJoin@{$InstallationDirectory, "\\SystemFiles\\IncludeFiles\\TeX\\Import"}, the same location the "InstallDir" option uses as a default). I'm not a $TeX$ expert, so I've tried simply to include more packages with \include in the "TeXCommand" option, perhaps this is not the way to go (though "Verbose" -> True indicates that both packages are parsed):

   ImportString["$\\{A\\leqslant x\\leqslant B\\}$", "TeX", (* "Verbose" -> True, *)
    "TeXCommand" -> "\\input amsmath.tns \\input amssymb.tns %\n"]

enter image description here

indicating that the symbols are there, but are displayed incorrectly. I've tried different encodings (found under FileNameJoin@{$InstallationDirectory, "\\SystemFiles\\CharacterEncodings"}), with no avail. According to amssymb.tns, the unicode character code for \leqslant is unicode 2270 (it also means that Mathematica in theory does support \leqslant).

One might want to play with CharacterEncoding, or with the "InstallDir" option (by pointing to a non-WRI $TeX$ installation) or with the "StyleDefinitions" option. If you have more experience with $TeX$ than me, please feel free to improve this post!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.