An archived instance of discourse for discussion in undergraduate Real and Numerical Analysis.

# How do I enter groovy typeset mathematics, images and code?

mark

This site is here to facilitate mathematical and computational discussion. As such, it is often nice to format your questions and responses as nicely as possible - including typeset mathematics, images, and code as appropriate.

## Sections and other formatting

Textual entry into discourse is based on Markdown - a lightweight markup language that makes formatting relatively easy. I should mention that Markdown is also used in the Jupyter notebook. To start this particular section, for example, I simply entered:

## Sections and other formatting

There many other things you can do with Markdown. You can really use it as much or as little as you want. The only things you really need are the remaining things you see in this post.

## Code

Entering code is easy! To enter a block of code, simply indent your block four spaces - that's it! For example:

%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
xs = np.linspace(-3,3,100)
ys = xs*np.cos(xs**2)
plt.plot(xs,ys)
plt.savefig('pic.png')

You can enter inline code using the backtick character. For example, we can stylize x=2 by entering x=2 .

## Images

Note the plt.savefig('pic.png') at the end of the above code block. That should produce a PNG file on your computer. You can then use the upload button in the editor to display it:

## Typeset mathematics

Like the Jupyter notebook, Discourse uses LaTeX to display mathematics. For example, to display

$$\int_{-\infty}^{\infty} e^{-x^2} \, dx = \sqrt{\pi},$$

as a center displayed typeset expression, you's enter:

$$\int_{-\infty}^{\infty} e^{-x^2} \, dx = \sqrt{\pi},$$

To typeset something inline like $f'(x) = -2xe^{-x^2}$, you'e enter $f'(x) = -2xe^{-x^2}$ inline. You can read a lot more about LaTeX and how it is implemented in a webpage in this stackexchange thread.

mark