Is it possible to import a Latex macro file, for instance
\newcommand{\Xcal}{\mathcal{X}
so that I can then use it between $...$ as $\Xcal$?
Yes, this seems to work:
---
title: "Presentation Ninja"
subtitle: "⚔<br/>with xaringan"
author: "Yihui Xie"
date: "2016/12/12 (updated: `r Sys.Date()`)"
output:
  xaringan::moon_reader:
    lib_dir: libs
    nature:
      highlightStyle: github
      highlightLines: true
      countIncrementalSlides: false
---
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  TeX: {
    Macros: {
      Xcal: "{\\mathcal{X}}",
      water: "{H_2O}"
    }
  }
});
</script>
$\water$    
$\Xcal$

It is important to use type=text/x-mathjax-config on the script tag, so mathjax finds the block. Details on defining macros in 
MathJax can be found here.
An alternative is to include the definition using the before_body YAML option:
---
title: "Presentation Ninja"
subtitle: "⚔<br/>with xaringan"
author: "Yihui Xie"
date: "2016/12/12 (updated: `r Sys.Date()`)"
output:
  xaringan::moon_reader:
    lib_dir: libs
    nature:
      highlightStyle: github
      highlightLines: true
      countIncrementalSlides: false
    includes:
      before_body: local.html
---
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With