# Use latex math macro

#### andrewchengchou

31 May, 2015 05:34 PM

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.

1. Support Staff Posted by Brett on 31 May, 2015 06:36 PM

Under Style preferences, you'll see an "Additional MathJax Config"
object to that field and save:

TeX: {
Macros: {
tr: "{\scriptscriptstyle\mathrm{T}}",
}
}

-Brett

2. Support Staff 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

TeX: {
Macros: {
tr: "{\scriptscriptstyle\mathrm{T}}",
}
}

and
{
TeX: {
Macros: {
tr: "{\scriptscriptstyle\mathrm{T}}",
}
}
}

Neither works. And there was an error popped out. Error parsing additional mathjax configuration.
4. Support Staff 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.

6. Support Staff 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.

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

### »

#### Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

# Keyboard shortcuts

### Generic

? Show this help Blurs the current field

### Comment Form

r Focus the comment reply box Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

## Recent Discussions

 25 Sep, 2020 05:18 PM Marked 2 hangs while loading images 25 Sep, 2020 04:21 PM Bear underline 25 Sep, 2020 02:43 PM Fountain Preview of non-fountain text files. 24 Sep, 2020 04:22 PM Exporting to PDF Highlights Words 22 Sep, 2020 02:48 PM Bear & Markdown Metadata

## Recent Articles

 Using Ulysses with Marked Fenced code blocks inside indented code blocks Using JavaScript in Marked Custom CSS: Writing custom CSS for Marked License code has already been utilized