Use latex math macro
I was trying to define a latex math macro throughout one
markdown file. The latex macro is to define a matrix transpose:
\newcommand{\tr}{{\scriptscriptstyle\mathrm{T}}}
I managed to do it by adding the following scripts at the
beginning of the markdown file.
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
TeX: {
Macros: {
tr: "{\scriptscriptstyle\mathrm{T}}",
}
}
});
</script>
I can then use the command \tr
throughout the markdown
file. For example,
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
TeX: {
Macros: {
tr: "{\scriptscriptstyle\mathrm{T}}",
}
}
});
</script>
The tranpose of a real matrix $A$ is denoted by $A^\tr$.
QUESTION: How can I make the above macro as a
user default in marked 2
app? So I don't have to copy
and paste the scripts for a new markdown document.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Brett on 31 May, 2015 06:36 PM
Under Style preferences, you'll see an "Additional MathJax Config"
field. Add the part of your script that's inside the MathJax.Hub.Config
object to that field and save:
TeX: {
Macros: {
tr: "{\scriptscriptstyle\mathrm{T}}",
}
}
-Brett
Support Staff 2 Posted by Brett on 31 May, 2015 06:36 PM
You may need the include the outer curly brackets around that, I can't
recall offhand how I have that injected. Let me know if you have issues
and I can dig back into it.
-Brett
3 Posted by andrewchengchou on 31 May, 2015 11:23 PM
I tried both
andNeither works. And there was an error popped out. Error parsing additional mathjax configuration.
Support Staff 4 Posted by Brett on 31 May, 2015 11:48 PM
Ok, I dug into it further and I have an error in the parser that
converts the string in the preferences into a config object for MathJax.
I'll try to have this worked out for the next update. In the meantime,
you could use the raw include syntax to put your macros into a separate
file and include it in documents that need it:
<<{filename.js}
Let me know if that helps.
Thanks,
Brett
5 Posted by andrewchengchou on 01 Jun, 2015 12:15 AM
Thanks Brett. Including the outer file works well. But there is one minor issue. Instead of saving the original script, I need to modify it slightly.
```
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
TeX: {
Macros: {
tr: "{\\scriptscriptstyle\\mathrm{T}}",
}
}
});
</script>
```
Note the double slash (`\\`) rather `\` in front of `scriptscriptstyle` and `mathrm`.
Support Staff 6 Posted by Brett on 01 Jun, 2015 01:08 AM
The code in your comment doesn't show a double slash. It's possible that somewhere along the line it's being unescaped, but Marked shouldn't be doing anything to it when using the raw syntax. I'll double check, though.
7 Posted by andrewchengchou on 01 Jun, 2015 03:19 AM
I don't know why. My comment in the raw text form has double slashes. After formatting it in markdown, it became one slash. So I edited the comment so it is displayed in raw text.