Showing posts with label markdown. Show all posts
Showing posts with label markdown. Show all posts

Wednesday, October 14, 2015

A simple LaTeX editor in iOS: MMD

LaTeX with MMD or Org-mode with MathJax

LaTeX with MMD or Org-mode with MathJax


This post is written with e[ ⎋Esc ]m[ ⌥Meta ]a[ ⌥Alt ]c[ ^Ctrl ]s[ ⇧Shift ] org-mode.


System Environments

Operating Systems

  • Main- : OS X Yosemite (10.10.5)
  • Sub- : Debian GNU/Linux Wheezy (7.9)
  • Server: Debian GNU/Linux Wheezy || Squeeze
  • Mobile: iOS 9.0.2

$$ \newcommand{\dd}{\mathrm{d}} $$


A brief comment on MultiMarkdown

MultiMarkDown(MMD) with LaTeX, particularly mathematical formulae, isn't hard in any text editor supporting markdown preview. All we need is adding the following code probably on the beginning of your MMD file.

<script type="text/javascript"
  src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

It's gonna automatically render a mathematical formula written in LaTeX into HTML by means of MathJax engine. List of softwares I've tested is

Remember that an equation has to be enclosed by $ and $, \( and \), \\[ and \\], or etc. as suggested by MathJax or Fletcher T. Penney. For the others, you can follow the usual Markdown or Multi-markdown syntaxes.

Rendering MMD with LaTeX to HTML may not work properly as expected. Sadly, usage of LaTeX in MMD is not recommendable (yet) by comparison with Org-mode working perfectly. For example, an HTML output rendered from any of above first three would be seen appropriately in Safari (or Mobile Safari), but might not in the others like Firefox(or even not in Safari sometimes).

Nevertheless, it is worth mentioning that an MMD editor supporting MD preview would be a great alternative to use LaTeX in iOS, such as Nebulous Notes.

22154811262_9daab98c1e_o.gif

Figure 1: LaTeX and its rendering in Nebulous Notes


LaTeX example and a tip

In order to use a manual command you want, it can be easily done by putting the following code somewhere in your MMD file or Emacs Org-mode file. It works in both.

$$
\newcommand{\dd}{\mathrm{d}}
$$

I here present the almost same output from the one LaTeX expression w/ two different markup languages: MMD and Emacs Org-mode.

Output

The famous Euler formula is $${e}^{i\pi }+1=0\,.$$

……………………………………………………

The Wigner function \(d^{(J)}_{mn}(\theta)\) satisfy the orthogonality and the completeness relation respectively as follows

\begin{align} (2\,J+1) \, \int_{-1}^{1}\frac{\dd\cos\theta}{2}\,d^{(J)}_{mn}(\theta)\,d^{(J')}_{mn}(\theta) = \delta_{JJ'} \,,\\ \sum_{J}(2J+1)\,d^{(J)}_{mn}(\theta)\,d^{(J)}_{mn}(\theta') = 2\,\delta(\cos\theta - \cos\theta') \,. \end{align}

It relates to the Legendre polynomial as

\begin{align} d^{(l)}_{00}(\theta) & = {} P_l(\cos\theta) \,, \qquad d^{(l)}_{10}(\theta) = - \frac{\sin\theta}{\sqrt{l(l+1)}}\,P_l'(\cos\theta) \,, \end{align}

where \(P_l'(z) = \dd P_l(z)/\dd z\). Using these altogether, we can recover the orthogonality and the completeness relation of the Legendre polynomials.

Source for MMD

<script type="text/javascript"
  src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

$$
\newcommand{\dd}{\mathrm{d}}
$$

The famous Euler formula is $${e}^{i\pi }+1=0\,.$$

***............................................................***

The Wigner function \\(d^{(J)}_{mn}(\theta)\\) satisfy the orthogonality and the completeness relation respectively as follows
\\[
\begin{align}
  (2\,J+1) \, \int_{-1}^{1}\frac{\dd\cos\theta}{2}\,d^{(J)}_{mn}(\theta)\,d^{(J')}_{mn}(\theta) = \delta_{JJ'}
  \,,\\
  \sum_{J}(2J+1)\,d^{(J)}_{mn}(\theta)\,d^{(J)}_{mn}(\theta') = 2\,\delta(\cos\theta - \cos\theta')
  \,.
\end{align}
\\]
It relates to the Legendre polynomial as
\\[
\begin{align}
  d^{(l)}_{00}(\theta)
  & = {}
  P_l(\cos\theta)
  \,, \qquad 
  d^{(l)}_{10}(\theta)
  = 
  - \frac{\sin\theta}{\sqrt{l(l+1)}}\,P_l'(\cos\theta)
  \,,
\end{align}
\\]
where \\(P_l'(z) = \dd P_l(z)/\dd z\\). Using these altogether, we can recover the orthogonality and the completeness relation of the Legendre polynomials.

Source for Emacs Org-mode

#+HTML_HEAD: <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> </script>

$$
\newcommand{\dd}{\mathrm{d}}
$$

The famous Euler formula is $${e}^{i\pi }+1=0\,.$$

*............................................................*

The Wigner function $d^{(J)}_{mn}(\theta)$ satisfy the orthogonality and the completeness relation respectively as follows
\begin{align}
  (2\,J+1) \, \int_{-1}^{1}\frac{\dd\cos\theta}{2}\,d^{(J)}_{mn}(\theta)\,d^{(J')}_{mn}(\theta) = \delta_{JJ'}
  \,,\\
  \sum_{J}(2J+1)\,d^{(J)}_{mn}(\theta)\,d^{(J)}_{mn}(\theta') = 2\,\delta(\cos\theta - \cos\theta')
  \,.
\end{align}
It relates to the Legendre polynomial as
\begin{align}
  d^{(l)}_{00}(\theta)
  & = {}
  P_l(\cos\theta)
  \,, \qquad 
  d^{(l)}_{10}(\theta)
  = 
  - \frac{\sin\theta}{\sqrt{l(l+1)}}\,P_l'(\cos\theta)
  \,,
\end{align}
where $P_l'(z) = \dd P_l(z)/\dd z$. Using these altogether, we can recover the orthogonality and the completeness relation of the Legendre polynomials.


Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Created: 2015-10-14 Wed 18:16

Emacs 24.3.1 (Org mode 8.2.10)

Sunday, January 20, 2013

emacs markdown-mode

markdown-mode.md

emacs markdown-mode


이 문서는 emacs markdown-mode 로 작성된 글입니다.

Operating System Environments

  • Main- : OS X Mountain Lion (10.8.2)
  • Sub- : Debian GNU/Linux Squeeze (6.0.6)
  • Server : Debian GNU/Linux Squeeze || Lenny
  • Mobile : iOS 6.0.1

준비물

설치

  1. 위에서 받은 Markdown_1.0.1.zip 파일의 압축을 풀어 적당한 경로(path_01)에 Markdown.pl 을 저장한다.
  2. 역시 위에서 받은 (혹은 복사한) markdown-mode.el 을 적당한 경로(path_02)에 저장한다.
  3. ~/.emacs 파일을 열어 아래를 복사하고 붙이고 저장한다.

    in .emacs

    (add-to-list 'load-path "path_02")
    ;;for markdown-mode.el
    (load "markdown-mode.el")
    (setq auto-mode-alist (cons '("\.md$" . markdown-mode) auto-mode-alist))
    

  4. M-x customize-mode 쳐서, Markdown Command: 에 path_01/Markdown.pl 을 적어넣는다.

PS) 3.에 ...("\\.md$"... 에서 .md 는 markdown extension 이다. 아직 official extension 이 정해지지 않았다고 하며, .mdwn, .mdt 등도 쓰인다. 다른 확장자를 가지고 있는 파일도 자동으로 markdown-mode로 부르고 싶으면, 그 이름만 바꾸어 3.에 네 번째 문장을 붙여넣으면 된다.

한글

한글을 사용하기 위해서는

  • Aquamacs 상단 메뉴 {Options} -> {Language} -> {Set Language Environment} 에서 {Korean} 혹은 {UTF-8} 을 선택한다.
  • 그리고 Aquamacs 상단 메뉴 {Options} -> {Save Options}

Epilog

markdown, 확실히 매력적인 면이 있는 programming language 인 것만은 분명하다. 우선 coding 이 너무 간단해서 쉽게 익힐 수 있고, 이에따라 source code도 굉장히 간단해서, 그 자체로 바로 읽을 수 있으며 debugging도 용이하다. 거기다가 compile 후의 .html 결과물은 마치 .tex을 compile 한 후의 .pdf (혹은 .dvi, .ps) 를 보는 듯할 정도로 깔끔하다.

당장 눈에 보이는 단점은 확장성이다. LaTeX 형식은 원래 html 함께 쓰기 쉽지는 않으므로 그렇다 치더라도, 표가 바로 지원이 되지 않는 점이 불편하다. emacs org-mode 와 문법이 매우 유사한데, 확장성은 심하게 떨어진다. org-mode 도 blogging 하는데 굉장히 좋은 툴인데, 조금더 비교해 보는 글들을 앞으로 몇 올려볼 요량이다.


source code in markdown language

emacs markdown-mode
====================
* * * * *

***이 문서는 emacs markdown-mode 로 작성된 글입니다.***

##  Operating System Environments
*  Main- : OS X Mountain Lion (10.8.2)
*  Sub- : Debian GNU/Linux Squeeze (6.0.6)
*  Server : Debian GNU/Linux Squeeze || Lenny
*  Mobile : iOS 6.0.1


[markdown_jGruber]: http://daringfireball.net/projects/markdown/  "Optional Title Here"

## 준비물
* [aquamacs](http://www.aquamacs.org/) (or emacs)
* **Markdown.pl** by ***John Gruber*** : [Markdown.pl 받으러 바로가기][markdown_jGruber]
* **markdown-mode.el** from ***jblevins.org*** [markdown-mode.el 받으러 바로가기](http://jblevins.org/projects/markdown-mode/)

## 설치

> 1. 위에서 받은 *Markdown_1.0.1.zip* 파일의 압축을 풀어 적당한 경로(`path_01`)에 *Markdown.pl* 을 저장한다.
> 2. 역시 위에서 받은 (혹은 복사한) *markdown-mode.el* 을 적당한 경로(`path_02`)에 저장한다.
> 3. ~/.emacs 파일을 열어 아래를 복사하고 붙이고 저장한다.
>> ### in .emacs
>>       (add-to-list 'load-path "path_02")
>>     ;;for markdown-mode.el
>>     (load "markdown-mode.el")
>>     (setq auto-mode-alist (cons '("\\.md$" . markdown-mode) auto-mode-alist))
>>
> 4. *M-x customize-mode* 쳐서, Markdown Command: 에 *path_01/Markdown.pl* 을 적어넣는다.

***PS)*** 3.에 `...("\\.md$"...` 에서 `.md` 는 markdown extension 이다. 아직 official extension 이 정해지지 않았다고 하며, `.mdwn`, `.mdt` 등도 쓰인다. 다른 확장자를 가지고 있는 파일도 자동으로 *markdown-mode*로 부르고 싶으면, 그 이름만 바꾸어 3.에 네 번째 문장을 붙여넣으면 된다.


## 한글

**한글을 사용하기** 위해서는 

* Aquamacs 상단 메뉴 {Options} -> {Language} -> {Set Language Environment} 에서 {Korean} 혹은 {**UTF-8**} 을 선택한다.
* 그리고 Aquamacs 상단 메뉴 {Options} -> {**Save Options**}