Using Org-Mode to Write Journal Articles
Sat, Jun 24, 2017Table of Contents
1 Summary of Org-Mode Documentation
You can get org-mode documention in many forms from the Org Home Page. Below is a very small list of pages in the manual that you should read to get going in org-mode.
2 Math
To include a mathematical formula in-line using org-mode, just use normal latex syntax. Here is some in-line math a = α × β. For latex equations or displaymath just type them in the file as usual:
Boy hard to get https
\begin{equation}
\frac{n!}{k!(n-k)!} = \binom{n}{k}
\end{equation}
which gives,
\begin{equation} \frac{n!}{k!(n-k)!} = \binom{n}{k}. \end{equation}3 Tables
Hugo is limited to simple tables, org-mode provides much more flexibility. Here is the Hugo (default markdown) table syntax, followed by it's html rendering. The code block is fancier than it's rendering…
Here is a table using org-mode, followed by the code. Unfortunately, there is a bug in org-mode that doesn't put a carriage-return, line-feed after a left-justified table, so avoid those for now.
Name | Age |
---|---|
Bob | 27 |
Alice | 23 |
The code. If you don't center the table, the rendering goes bad.
#+ATTR_html: :align center :width 200 #+CAPTION: the caption Name | Age -------|------ Bob | 27 Alice | 23
4 Figures
The material below is a bit old, and assumes you have put your figures on our ftp site. But with the new Hugo Bundle capability, figures are easier, in that you can just put them in the directory with your source code. Below is an example.
Figure 1: A figure using the new Bundle capability of hugo.
Here is the source code:
#+CAPTION: A figure using the new Bundle capability of hugo. #+ATTR_HTML: :width 400 [[./test.png]]
Orgmode has it's own syntax for including figures. However, remember
you have to be careful with URL's as discussed above.
The figure syntax assuming you have copied /asl/ftp/pub/xxx
to your
local machine is:
#+CAPTION: Another caption for a figure. #+ATTR_HTML: :width 400 [[hpub:pub_test.png]]
Figure 2: Another caption for a figure.
Here is another example, using an absolute URL
#+CAPTION: A caption for a figure. #+ATTR_HTML: :width 600 [[https://asl.umbc.edu/pub/strow/figs/desert_rtp.png]]
Figure 3: A caption for a figure.
5 Orgmode Syntax
I will give examples for the most important things you need to know about org-mode here, for a full (and lengthly) view see the Org-Mode on-line docs
Code blocks, examples, prose, etc can be done a number of ways, two ways are shown below, see the source code of this document to see how these are done.
#+BEGIN_SRC text Here is the rendering of an =in-line code block=. Is was done by enclosing the code block in =, as shown below where we repeat these last two sentences. #+END_SRC
Here is the rendering of an =in-line code block=. Is was done by enclosing the code block in =, as shown below where we repeat these last two sentences.
Note that the code block rendering will render carriage return, line feeds if they exist.
To render a matlab file (or latex, or html, etc) just use the backticks, and put the language right after the first set of three backticks. I would generally put language of "text" for notes, or if you do not want automatic colorization, etc. I can't figure out how to render a code block inside a code block, so look at the source of this file (/strow/hugo_orgmode.md) to see how this works.
% A matlab code snippet for i=1:n a(i) = fact(i); end
If you want to make this look like the Hugo markdown, there is a slightly more complicated way to do the above, shown below and then rendered.
#+BEGIN_EXPORT HTML <pre><code class="language-matlab">% A matlab code snippet for i=1:n a(i) = fact(i); end </code></pre> #+END_EXPORT
% A matlab code snippet
for i=1:n
a(i) = fact(i);
end