TransWikia.com

How to add Latex packages to markdown?

TeX - LaTeX Asked by consideration on May 9, 2021

I am writing some text with Markdown on the Jupyter notebook. But I am not able to import some Latex packages to the notebook. I tried to follow How to include LaTeX package in R Markdown?. I tried to include the mathtools package, but it does not work.

With

title: "Title"
author: "Me"
header-includes:
   - usepackage{mathtools}
output:
    pdf_document

I am still not able to call commands like $xrightarrow[text{sample text}]$ on Jupyter notebook.

One Answer

Welcome to TeX.SE. Don't use square brackets [] in your math expression. Use braces {} only. You wrote: $xrightarrow[text{sample text}]$. It should be: $xrightarrow{text{sample text}}$.

Edit: Updated to show the use of Bracket and Set from the braket package.

enter image description here

---
title: "Title"
author: "Me"
header-includes:
  - usepackage{array}
  - usepackage{booktabs}
  - usepackage{mathtools}
  - usepackage{braket}
output:
  pdf_document:
    keep_tex: true
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

hrule <!-- draw a horizontal line -->

We can _write_ in **markdown** and add content that uses ``LaTeX`` syntax and LaTeX packages to format our document.

## Using ``mathtools`` package

$xrightarrow{text{sample text}}$

<br> <!-- add space, like bigskip % - this is a comment -->

## Using ``array``, ``booktabs`` and ``braket`` packages

begingroup
renewcommand*{arraystretch}{1.7}
setlength{tabcolsep}{10pt}
begin{tabular}{@{}>{footnotesize}r>{$displaystyle}l<{$}@{}}
toprule 
  verb+Braket{ phi | frac{partial^2}{partial t^2} | psi }+ & Braket{ phi | frac{partial^2}{partial t^2} | psi } 
  verb+Set{ xinmathbf{R}^2 | 0<{|x|}<5 }+                     & Set{ xinmathbf{R}^2 | 0<{|x|}<5 }                    
bottomrule
end{tabular}
endgroup

## We can do math

```{r math}
result <- 1 + 2
result
```

Correct answer by Ross on May 9, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP