Write, code and publish with Emacs Org Mode
This page serves as an example of org-tufte, which is exported by a simple org file.
Introduction to org mode
Org mode is for keeping notes org-roam is a mature note-taking solution in org-mode if you like back-linked notes! , maintaining TODO lists, planning projects, and authoring documents with a fast and effective plain-text system A great article elaborates on this. .
Nice bits of org mode
As being members of Emacs cult, org-mode is a natural choice for note-taking, authoring, publishing and literate programming.
- Authoring and publishing: org can be exported to various formats TeX, PDF and HTML. great for writers and academics.
- Literate programming: org-babel is more powerful than rmarkdown, quarto. nice for teaching and reproducible research.
- Get Tings Done.
- And so on.
We use Lorem ipsum text to demonstrate all elements you would expect to see in the org-exported HTML pages.
Code highlighting
(require 'org-tufte)
(setq org-tufte-htmlize-code t)
click the caption of cold block to fold/unfold
class ArnoldiOpData
{
public:
ArnoldiOpData(Data * data_) : data(data_)
{
data->nops = 1;
}
~ArnoldiOpData() {}
using Scalar = double;
inline uint64 rows() const
{
return n;
}
inline uint64 cols() const
{
return n;
}
// y = G * G' * x ; data.G is n x m;
void perform_op(const double * x_in, double * y_out) const;
MyMatrix U, VT;
MyVector S;
private:
Data * data;
uint64 n;
bool update = false;
};
The ordered list
- Lorem ipsum dolor sit amet, consectetur adipiscing elit.
- Donec et massa sit amet ligula maximus feugiat.
- Morbi consequat orci et tincidunt sagittis.
Unordered list
- Aliquam non metus nec elit pellentesque scelerisque.
- In accumsan nunc ac orci varius hendrerit.
- Suspendisse non eros eu nisi finibus maximus.
Definition list
- Lorem ipsum
- dolor sit amet, consectetur adipiscing elit. Mauris laoreet sollicitudin venenatis. Duis sed consequat dolor.
- Etiam feugiat
- pharetra sapien et semper. Nunc ornare lacus sit amet massa auctor, vitae aliquam eros interdum. Mauris arcu ante, imperdiet vel purus ac, bibendum faucibus diam. Ut blandit nec mi at ultricies. Donec eget mattis nisl. In sed nibh felis. Cras quis convallis orci.
- Sed aliquam
- odio sed faucibus aliquam, arcu augue elementum justo, ut vulputate ligula sem in augue. Maecenas ante felis, pellentesque auctor semper non, eleifend quis ante. Fusce enim orci, suscipit ac dapibus et, fermentum eu tortor. Duis in facilisis ante, quis faucibus dolor. Etiam maximus lorem quis accumsan vehicula.
Quotes
Org was born in 2003, out of frustration over the user interface of the Emacs Outline mode. I was trying to organize my notes and projects, and using Emacs seemed to be the natural way to go. However, having to remember eleven different commands with two or three keys per command, only to hide and show parts of the outline tree, that seemed entirely unacceptable to me. Also, when using outlines to take notes, I constantly wanted to restructure the tree, organizing it parallel to my thoughts and plans. Visibility cycling and structure editing were originally implemented in the package ‘outline-magic.el’, but quickly moved to the more general ‘org.el’. As this environment became comfortable for project planning, the next step was adding TODO entries, basic timestamps, and table support. These areas highlighted the two main goals that Org still has today: to be a new, outline-based, plain text mode with innovative and intuitive editing features, and to incorporate project planning functionality directly into a notes file.
Citation
org-cite is a very exciting feature See this blog for details. . In my field Test figure in sidenote , there is a cutting-edge ultra-fast PCA method (Li, Zilong and Meisner, Jonas and Albrechtsen, Anders, 2023).
Inline Math
This is an inline math \(\mathcal{F}(a) = \frac{1}{2\pi i}\oint_\gamma \frac{f(z)}{z - a}\,dz\). And it can also look like equation but without equation number.
\[ \int_D (\nabla\cdot \mathcal{F})\,dV =\int_{\partial D}\mathcal{F}\cdot n\, dS \]
Math equation
The follows are equations with number label.
\begin{align} \mathcal{F}(a) &= \frac{1}{2\pi i}\oint_\gamma \frac{f(z)}{z - a}\,dz\\ \int_D (\nabla\cdot \mathcal{F})\,dV &=\int_{\partial D}\mathcal{F}\cdot n\, dS \end{align}Unicode and ligatures
Org-tufte uses et-book-ligatures font for ligatures. Julia has native unicode support such that the code itself just looks like math written with greek symbol. nice for mathematical writting.
ρ(i, s, z) = sum(α[i, s, z, :] .* β[i, s, z, :]) / θ[i]
ρ(i, s) = map(z -> ρ(i, s, z), 1:size(α)[3])
κ(i, s, z, k; Q, F, ρ, h) = ρ[z] * Q[i, k] * F[z, s, k] / h[z]
κ(i, s; Q, F, ρ, h) = begin
C×K = product(1:size(F)[1], 1:size(F)[3])
map(((z, k),) -> κ(i, s, z, k; Q=Q, F=F, ρ=ρ, h=h), C×K)
end
ν(i, s, z1, z2, k1, k2; Q, F, h) =
α[i, s, z1, z2] * β[i, s, z1, z2] / θ[i] *
Q[i, k1] * F[z1, s, k1] / h[z1] *
Q[i, k2] * F[z2, s, k2] / h[z2]
Table
\(N\) | \(N^2\) | \(N^3\) | \(N^4\) | \(\sqrt n\) | \(\sqrt[4]N\) |
---|---|---|---|---|---|
1 | 1 | 1 | 1 | 1 | 1 |
2 | 4 | 8 | 16 | 1.4142 | 1.1892 |
3 | 9 | 27 | 81 | 1.7321 | 1.3161 |
Figures
Fullwidth image is only supported for html5 doctype, and can be enabled via #+attr_html: :class fullwidth
References
Li, Zilong and Meisner, Jonas and Albrechtsen, Anders (2023). Fast and Accurate Out-of-Core PCA Framework for Large Scale Biobank Data, Genome Research.