tonyfast / nsf-goali

A Testing Environment for Mini-Research Sites
tonyfast.com/nsf-goali
1 stars 3 forks source link

LaTeX equations #5

Closed mwpriddy closed 10 years ago

mwpriddy commented 10 years ago

Getting the LaTeX equations up-and-running for us. Thanks :)

tonyfast commented 10 years ago

Working on this

tonyfast commented 10 years ago

I added MathJax to the Jekyll boilerplate so you can write Latex equations.

Using MathJax in the Template

MathJax adds some overlays and annoying load times. I am assuming that Latex will be used less frequently than plain text. You need to active MathJax in individual posts.

Activating MathJax in YAML Front Matter

In the YAML Front Matter of a post containing Latex, used the following key.

---
layout: post
latex: true
---

When latex: true is assigned:

  1. The post.html layout calls an include latex.html
  2. The include activates the MathJax script and interprets inline and block Latex.

An Example Page

Writing MathJax

Tex and Latex MathJax Inputs

@PaymanSh Can you make add this where it needs to be?

tonyfast commented 10 years ago

Best Practice for Equations

Placing information in YAML front matter makes it much easier to use later on. Placing an equation in the middle of a webpage will provide the necessary presentation layer. However, this information is harder to scrape and use later on. The following outlines a best practice for reusing equations.

Please see this example.

YAML Front matter

In this YAML front matter of a post use the following statements to create a post, equation, and activiate mathjax

---
layout: post  # Use post layout
latex: true  # Activate MathJax
eq1: |       # Block String referenced in HTML
  $$ \mathbf{L}_0^\mathrm{p} =
  \sum_{\alpha=1}^{\mathrm{N}}\dot{\gamma}^{(\alpha)}
  \left(\mathbf{s}_0^{(\alpha)} \otimes \mathbf{n}_0^{(\alpha)}\right) =
  \dot{\mathbf{F}}^{\mathrm{p}} \cdot \left({\mathbf{F}^{\mathrm{p}}}\right)^{-1} $$
---

Strings Types in YAML

StackOverflow: String Literals and Multiline Strings in YAML

Post Body

An equation can then be referenced in the post body using Liquid syntax.

The following equation explains how Jello emits X-rays:
{{page.eq1}}

Advantages

mwpriddy commented 10 years ago

Looks great! Thanks for the example links and stuff. I will definitely start placing equations in the YAML front matter now.

tonyfast commented 10 years ago

Here is a better example page