Notes on Emacs and Org-mode

Table of Contents

#+LEARNING EMACS AND ORG -- mode: org --

1 IN-PROGRESS Emacs for notes

you can add a todo tag by calling org-insert-todo-heading which is mapped to M-Shift-RET, in SpaceMacs it appears to be SPC m :

Consider adding extra states to the for todo 1 something like:

#+TODO: TODO IN-PROGRESS WAITING DONE

1.1 DONE Images   diagrams

1.1.1 Images may be inserted as links

Look at the following example:

The documentation implies that [[ ]] are required but it seems that the export works fine without that and the inline preview is fine without it as well:

1551604985277.png

This may be inline previewed with C-c C-x C-v

1.2 DONE How do attach external files that I can follow?   Attachments

Does the filetype matter? like markdown pdf whatever? This Link to the manual suggests that any file can be linked to be using C-u C-c C-l PDF to this doc, pretend it's a tutorial sheet or a learning guide or something

You may also want to consider using the insert menu , i a / <SPC> i a to reach the attach menu org-attach / , i a a <SPC> i a a which might do a lot of the work for you:

2 DONE Tag Filtering   tagging

2.1 General Informagion

  • According to the documentation on Tag Inheritance, Tags respect the heirachy of the document.
  • you can also put (setq org-complete-tags-always-offer-all-agenda-tags t) in the ~/.emacs.d/init.el in order to have autocompletion from all other documents in the agenda.
  1. Global Tags

    In order for tags to appear in the agenda buffer they must be added to the org-agenda-files variable, Files can be added /removed from this variable with C-c [ / C-c ] respectively.

    use C-c a / <SPC> m a to get up the agenda view, from there you can open an agenda-buffer:

    • m will take you to tag matching
      • M will take you to tag matching for items marked todo
    • t will take you to all the todo lists
      • T will let you choose WAITING=/=done etc.

    If I do agenda search with C-c a then I can further filter with org-agenda-filter-tags tied do \, but the tags listed aren't pruned which is a problem, can I filter based on the tags based on the top first or between?

    After the agenda buffer has been generated you can use \ to filter by tag or use <ALT>-<SPC> to open the transient state, which will offer many different ways to filter the tags.

    You can't filter which tags popup when you try and filter by tags, so the best method, for now, is to use \ tag by tag and read-off whats in the list one-by one, using nested tags and sensible names will help.

    In order to have all the global tags listed, you need to the following in the ~/.emacs.d/.init.el:

    (setq org-complete-tags-always-offer-all-agenda-tags t)
    
    1. Progressive Filtering

      I haven't found anyway to do do this, but org-global-tags-completion-table might be a start.

  2. LocalTags

    Local tags are managed by Sparse Trees which collapses and flattens the tree but for matching tags, certainly preferable for a local document.

    using , / allows me to create Sparse Trees, I can choose to do that either by todo status or by tag, although this broke in these notes so it may not be reliable?

    After creating the sparse tree I don't believe further filtering is possible, however you can use Boolean Logic when creating the tree in order to have it even sparser.

    it appears that if I press <SPC> m a m (for mode-agenda-match) I can search for all tags, it also implies that tags apply per headline? A local sparse tree can be generated by using c-c / m or C-c \ First you need to list the org-file in the variable org-agenda-files, this could be customised manually but you usually just do C-c [.

    • if you press <SPC> m b it will take you to a buffer only with what is beneath that headline, this is amazing, just like Beorg , really good!
      • to kill this buffer: <SPC> m b / C-x k
      • it's also possible to jump straight to the buffer list with C-x C-b and:
        1. mark buffers for deletion with d d=/=C-k
        2. eXecute the deletion with x
  3. Listing Empty Headlines

    use the special property TAGS like so:

    TAGS=""
    
  4. Tag Heirachy

    If you list tags in the preamble or org-tag-alist like this:

    #+TAGS: [ Control : Context Task ]
    #+TAGS: [ Persp : Vision Goal AOF Project ]
    

    you will get a scheme like this:

    • ‘GTD’
      • ‘Persp’
        • ‘Vision’
        • ‘Goal’
        • ‘AOF’
        • ‘Project’
      • ‘Control’
        • ‘Context’
        • ‘Task’

    So if you search for 'GTD' you will get back everything beneath that (e.g. 'persp' and 'Goal'), if you search for 'Control' you will only get back matches for 'context' and 'task')

    This is better than using tag inheritance because something tagged as 'PCA' may not necessarily be underneath a heading like "Unsupervised" Learning.

    It's probably better to set these up in the org-tag-alist variable in the config but I can't get it to work, so instead list them in the preamble and leverage the fact that all files in the agenda will be listed as valid tags.

  5. DONE Capture Templates

    Say I want to take a math note, can I just use <SPC a o c> and open the right template? There is some info in the Manual and on This Site.

2.2 TimeStapms

Type Description
Deadline When a task is due
Scheduled When you intend to start working on that task
Timestamp a specification of a date or a range ofdates.

2.3 Keyboard Shortcuts

Shortcut Description command
C-c / m , / or C-c \ or <SPC> m / Create a sparse tree with all headlines matching a tags search. (org-match-sparce-tree)
C-c [ Adds the current file to the agenda variable so it is included in agenda searches (the file can be removed with C-c ] (org-agenda-file-to-front)
C-’ cycle through agenda file list  
<SPC> a m Create a global list oftag matches from all agenda files (files must be listed in the agenda variable) (org-tags-view)
<SPC> a t Create a global to do list  
\ Only works in an agenda bugger, filters that buffr by the given tag. (org-agenda-fiter-tags)
(* or %) then B Bulk Change matches in agenda view ??
C-c C-q et tag for current heading  
'C-u C-c C-q' / <SPC> u C-c C-q realign tag in all heading  
C-c C-o globally (agenda) match tag at curor  
C-c . insert SCHEDULE timestamp via prompt  
C-c C-d insert DEADLINE timestamp  
C-c C- insert CHEDULED timestamp  
C-c / d create pare tree with all deadline due  
C-c C-x C-i start clock on current item  
C-c C-x C-o/x stop/cancel clock on current item  
C-c C-x C-d display total subtree times  
C-c C-c remove displayed times  
C-c C-x C-r insert/update table with clock report  

there are way more more shortcuts inside this drawer 2

================================================================================
Org-Mode Reference Card (for version 7.8.11)
================================================================================



================================================================================
Getting Started
================================================================================
To read the on-line documentation try             M-x org-info

================================================================================
Visibility Cycling
================================================================================

rotate current subtree between states             TAB
rotate entire buffer between states               S-TAB
restore property-dependent startup visibility     C-u C-u TAB
show the whole file, including drawers            C-u C-u C-u TAB
reveal context around point                       C-c C-r

================================================================================
Motion
================================================================================

next/previous heading                             C-c C-n/p
next/previous heading, same level                 C-c C-f/b
backward to higher level heading                  C-c C-u
jump to another place in document                 C-c C-j
previous/next plain list item                     S-UP/DOWN\notetwo

================================================================================
Structure Editing
================================================================================

insert new heading/item at current level          M-RET
insert new heading after subtree                  C-RET
insert new TODO entry/checkbox item               M-S-RET
insert TODO entry/ckbx after subtree              C-S-RET
turn (head)line into item, cycle item type        C-c -
turn item/line into headline                      C-c *
promote/demote heading                            M-LEFT/RIGHT
promote/demote current subtree                    M-S-LEFT/RIGHT
move subtree/list item up/down                    M-S-UP/DOWN
sort subtree/region/plain-list                    C-c ^
clone a subtree                                   C-c C-x c
copy visible text                                 C-c C-x v
kill/copy subtree                                 C-c C-x C-w/M-w
yank subtree                                      C-c C-x C-y or C-y
narrow buffer to subtree / widen                  C-x n s/w

================================================================================
Capture - Refile - Archiving
================================================================================
capture a new item (C-u C-u = goto last)          C-c c \noteone
refile subtree (C-u C-u = goto last)              C-c C-w
archive subtree using the default command         C-c C-x C-a
move subtree to archive file                      C-c C-x C-s
toggle ARCHIVE tag / to ARCHIVE sibling           C-c C-x a/A
force cycling of an ARCHIVEd tree                 C-TAB

================================================================================
Filtering and Sparse Trees
================================================================================

construct a sparse tree by various criteria       C-c /
view TODO's in sparse tree                        C-c / t/T
global TODO list in agenda mode                   C-c a t \noteone
time sorted view of current org file              C-c a L

================================================================================
Tables
================================================================================

--------------------------------------------------------------------------------
Creating a table
--------------------------------------------------------------------------------

just start typing, e.g.                           |Name|Phone|Age RET |- TAB
convert region to table                           C-c |
... separator at least 3 spaces                   C-3 C-c |

--------------------------------------------------------------------------------
Commands available inside tables
--------------------------------------------------------------------------------

The following commands work when the cursor is inside a table.
Outside of tables, the same keys may have other functionality.

--------------------------------------------------------------------------------
Re-aligning and field motion
--------------------------------------------------------------------------------

re-align the table without moving the cursor      C-c C-c
re-align the table, move to next field            TAB
move to previous field                            S-TAB
re-align the table, move to next row              RET
move to beginning/end of field                    M-a/e

--------------------------------------------------------------------------------
Row and column editing
--------------------------------------------------------------------------------

move the current column left                      M-LEFT/RIGHT
kill the current column                           M-S-LEFT
insert new column to left of cursor position      M-S-RIGHT

move the current row up/down                      M-UP/DOWN
kill the current row or horizontal line           M-S-UP
insert new row above the current row              M-S-DOWN
insert hline below (C-u : above) current row      C-c -
insert hline and move to line below it            C-c RET
sort lines in region                              C-c ^

--------------------------------------------------------------------------------
Regions
--------------------------------------------------------------------------------

cut/copy/paste rectangular region                 C-c C-x C-w/M-w/C-y
fill paragraph across selected cells              C-c C-q

--------------------------------------------------------------------------------
Miscellaneous
--------------------------------------------------------------------------------

to limit column width to N characters, use        ...| <N> |...
edit the current field in a separate window       C-c `
make current field fully visible                  C-u TAB
export as tab-separated file                      M-x org-table-export
import tab-separated file                         M-x org-table-import
sum numbers in current column/rectangle           C-c +

--------------------------------------------------------------------------------
Tables created with the table.el package
--------------------------------------------------------------------------------

insert a new table.el table                       C-c ~
recognize existing table.el table                 C-c C-c
convert table (Org-mode <-> table.el)             C-c ~

--------------------------------------------------------------------------------
Spreadsheet
--------------------------------------------------------------------------------

Formulas typed in field are executed by TAB,
RET and C-c C-c.  = introduces a column
formula, := a field formula.

Example: Add Col1 and Col2                        |=$1+$2      |
... with printf format specification              |=$1+$2;%.2f|
... with constants from constants.el              |=$1/$c/$cm |
sum from 2nd to 3rd hline                         |:=vsum(@II..@III)|
apply current column formula                      | = |

set and eval column formula                       C-c =
set and eval field formula                        C-u C-c =
re-apply all stored equations to current line     C-c *
re-apply all stored equations to entire table     C-u C-c *
iterate table to stability                        C-u C-u C-c *
rotate calculation mark through # * ! ^ _ $       C-#
show line, column, formula reference              C-c ?
toggle grid / debugger                            C-c }/{

--------------------------------------------------------------------------------
Formula Editor
--------------------------------------------------------------------------------

edit formulas in separate buffer                  C-c '
exit and install new formulas                     C-c C-c
exit, install, and apply new formulas             C-u C-c C-c
abort                                             C-c C-q
toggle reference style                            C-c C-r
pretty-print Lisp formula                         TAB
complete Lisp symbol                              M-TAB
shift reference point                             S-cursor
shift test line for column references             M-up/down
scroll the window showing the table               M-S-up/down
toggle table coordinate grid                      C-c }

================================================================================
Links
================================================================================

globally store link to the current location       C-c l \noteone
insert a link (TAB completes stored links)        C-c C-l
insert file link with file name completion        C-u C-c C-l
edit (also hidden part of) link at point          C-c C-l

open file links in emacs                          C-c C-o
...force open in emacs/other window               C-u C-c C-o
open link at point                                mouse-1/2
...force open in emacs/other window               mouse-3
record a position in mark ring                    C-c %
jump back to last followed link(s)                C-c &
find next link                                    C-c C-x C-n
find previous link                                C-c C-x C-p
edit code snippet of file at point                C-c '
toggle inline display of linked images            C-c C-x C-v

================================================================================
Working with Code (Babel)
================================================================================

execute code block at point                       C-c C-c
open results of code block at point               C-c C-o
check code block at point for errors              C-c C-v c
insert a header argument with completion          C-c C-v j
view expanded body of code block at point         C-c C-v v
view information about code block at point        C-c C-v I
go to named code block                            C-c C-v g
go to named result                                C-c C-v r
go to the head of the current code block          C-c C-v u
go to the next code block                         C-c C-v n
go to the previous code block                     C-c C-v p
demarcate a code block                            C-c C-v d
execute the next key sequence in the code edit bu C-c C-v x
execute all code blocks in current buffer         C-c C-v b
execute all code blocks in current subtree        C-c C-v s
tangle code blocks in current file                C-c C-v t
tangle code blocks in supplied file               C-c C-v f
ingest all code blocks in supplied file into the  C-c C-v i
switch to the session of the current code block   C-c C-v z
load the current code block into a session        C-c C-v l
view sha1 hash of the current code block          C-c C-v a

================================================================================
Completion
================================================================================

In-buffer completion completes TODO keywords at headline start, TeX
macros after `\', option keywords after `#-', TAGS
after  `:', and dictionary words elsewhere.

complete word at point                            M-TAB




================================================================================
TODO Items and Checkboxes
================================================================================

rotate the state of the current item              C-c C-t
select next/previous state                        S-LEFT/RIGHT
select next/previous set                          C-S-LEFT/RIGHT
toggle ORDERED property                           C-c C-x o
view TODO items in a sparse tree                  C-c C-v
view 3rd TODO keyword's sparse tree               C-3 C-c C-v

set the priority of the current item              C-c , [ABC]
remove priority cookie from current item          C-c , SPC
raise/lower priority of current item              S-UP/DOWN\notetwo

insert new checkbox item in plain list            M-S-RET
toggle checkbox(es) in region/entry/at point      C-c C-x C-b
toggle checkbox at point                          C-c C-c
update checkbox statistics (C-u : whole file)     C-c #

================================================================================
Tags
================================================================================

set tags for current heading                      C-c C-q
realign tags in all headings                      C-u C-c C-q
create sparse tree with matching tags             C-c \\
globally (agenda) match tags at cursor            C-c C-o

================================================================================
Properties and Column View
================================================================================

set property/effort                               C-c C-x p/e
special commands in property lines                C-c C-c
next/previous allowed value                       S-left/right
turn on column view                               C-c C-x C-c
capture columns view in dynamic block             C-c C-x i

quit column view                                  q
show full value                                   v
edit value                                        e
next/previous allowed value                       n/p or S-left/right
edit allowed values list                          a
make column wider/narrower                        > / <
move column left/right                            M-left/right
add new column                                    M-S-right
Delete current column                             M-S-left


================================================================================
Timestamps
================================================================================

prompt for date and insert timestamp              C-c .
like C-c . but insert date and time format        C-u C-c .
like C-c . but make stamp inactive                C-c !
insert DEADLINE timestamp                         C-c C-d
insert SCHEDULED timestamp                        C-c C-s
create sparse tree with all deadlines due         C-c / d
the time between 2 dates in a time range          C-c C-y
change timestamp at cursor A+/-1 day                S-RIGHT/LEFT\notetwo
change year/month/day at cursor by A+/-1            S-UP/DOWN\notetwo
access the calendar for the current date          C-c >
insert timestamp matching date in calendar        C-c <
access agenda for current date                    C-c C-o
select date while prompted                        mouse-1/RET
toggle custom format display for dates/times      C-c C-x C-t


--------------------------------------------------------------------------------
Clocking time
--------------------------------------------------------------------------------

start clock on current item                       C-c C-x C-i
stop/cancel clock on current item                 C-c C-x C-o/x
display total subtree times                       C-c C-x C-d
remove displayed times                            C-c C-c
insert/update table with clock report             C-c C-x C-r

================================================================================
Agenda Views
================================================================================

add/move current file to front of agenda          C-c [
remove current file from your agenda              C-c ]
cycle through agenda file list                    C-'
set/remove restriction lock                       C-c C-x </>

compile agenda for the current week               C-c a a \noteone
compile global TODO list                          C-c a t \noteone
compile TODO list for specific keyword            C-c a T \noteone
match tags, TODO kwds, properties                 C-c a m \noteone
match only in TODO entries                        C-c a M \noteone
find stuck projects                               C-c a # \noteone
show timeline of current org file                 C-c a L \noteone
configure custom commands                         C-c a C \noteone
agenda for date at cursor                         C-c C-o

--------------------------------------------------------------------------------
Commands available in an agenda buffer
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
View Org file
--------------------------------------------------------------------------------

show original location of item                    SPC/mouse-3
show and recenter window                          L
goto original location in other window            TAB/mouse-2
goto original location, delete other windows      RET
show subtree in indirect buffer, ded.\ frame      C-c C-x b
toggle follow-mode                                F

--------------------------------------------------------------------------------
Change display
--------------------------------------------------------------------------------

delete other windows                              o
view mode dispatcher                              v
switch to day/week/month/year/def view            d w vm vy vSP
toggle diary entries / time grid / habits         D / G / K
toggle entry text / clock report                  E / R
toggle display of logbook entries                 l / v l/L/c
toggle inclusion of archived trees/files          v a/A
refresh agenda buffer with any changes            r / g
filter with respect to a tag                      /
save all org-mode buffers                         s
display next/previous day,week,...                f / b
goto today / some date (prompt)                   . / j

--------------------------------------------------------------------------------
Remote editing
--------------------------------------------------------------------------------

digit argument                                    0-9
change state of current TODO item                 t
kill item and source                              C-k
archive default                                   $ / a
refile the subtree                                C-c C-w
set/show tags of current headline                 : / T
set effort property (prefix=nth)                  e
set / compute priority of current item            , / P
raise/lower priority of current item              S-UP/DOWN\notetwo
run an attachment command                         C-c C-a
schedule/set deadline for this item               C-c C-s/d
change timestamp one day earlier/later            S-LEFT/RIGHT\notetwo
change timestamp to today                         >
insert new entry into diary                       i
start/stop/cancel the clock on current item       I / O / X
jump to running clock entry                       J
mark / unmark / execute bulk action               m / u / B

--------------------------------------------------------------------------------
Misc
--------------------------------------------------------------------------------

follow one or offer all links in current entry    C-c C-o

--------------------------------------------------------------------------------
Calendar commands
--------------------------------------------------------------------------------

find agenda cursor date in calendar               c
compute agenda for calendar cursor date           c
show phases of the moon                           M
show sunrise/sunset times                         S
show holidays                                     H
convert date to other calendars                   C

--------------------------------------------------------------------------------
Quit and Exit
--------------------------------------------------------------------------------

quit agenda, remove agenda buffer                 q
exit agenda, remove all agenda buffers            x

================================================================================
LaTeX and cdlatex-mode
================================================================================

preview LaTeX fragment                            C-c C-x C-l
expand abbreviation (cdlatex-mode)                TAB
insert/modify math symbol (cdlatex-mode)          ` / '
insert citation using RefTeX                      C-c C-x [

================================================================================
Exporting and Publishing
================================================================================

Exporting creates files with extensions .txt and .html
in the current directory.  Publishing puts the resulting file into
some other place.

export/publish dispatcher                         C-c C-e

export visible part only                          C-c C-e v
insert template of export options                 C-c C-e t
toggle fixed width for entry or region            C-c :
toggle pretty display of scripts, entities        C-c C-x {\tt\char`\}

--------------------------------------------------------------------------------
Comments: Text not being exported
--------------------------------------------------------------------------------

Lines starting with # and subtrees starting with COMMENT are
never exported.

toggle COMMENT keyword on entry                   C-c ;

================================================================================
Dynamic Blocks
================================================================================

update dynamic block at point                     C-c C-x C-u
update all dynamic blocks                         C-u C-c C-x C-u

================================================================================
Notes
================================================================================
[1] This is only a suggestion for a binding of this command.  Choose
your own key as shown under ACTIVATION.

[2] Keybinding affected by org-support-shift-select and also
 org-replace-disputed-keys.


2.4 Tags

There are two types of tags, todo tags and :patt1: tags, working with them is essentailly the difference between using t and m respectively.

There is a tag line at the top of the file that lists tags included in this file, and you can add tags to the org-tag-alist variable, this is worth doing to prevent you from creating double tags.

You can also merely specify any tag in the headline using :patt1: which can be triggered by using C-c C-q, it's probably better to specify tags in the preamble and/or variable because you can set mutually exclusive and nested tags. after doing this make cure to press C-c C-c on the #+TAGS: line in order to activate the changes

3 Inline Code

3.1 First Steps

First you have to activate languages, this is what I used:

;; Active Babel languages
;; Active Babel languages
(org-babel-do-load-languages
   'org-babel-load-languages
    '((R          . t)
     (latex       . t)
     (python      . t)
     (gnuplot     . t)
     (java        . t)
     (sed         . t)
     (shell       . t)
     (mathematica . t)
     (emacs-lisp  . t)))

You need to specify how you want the code block to behave:

  • :exports code
    • use this if you don't want the code evaluated (but want highlighting)
  • : exports both
    • Code listing and result
  • :exports results
    • Only the results of the code
  • :exports none
    • The code just doesn't get exported

If you don't want something to evauluate set :exports none

3.2 Execute External Language

External languages can be executed by pressing C-c C-c and then pressing y for yes

print(rnorm(3))
-1.0983654591016
-0.95587377920224
-0.329583305530361

This can be handy for complicated things like:

words <- tolower(scan("1.org", what="", na.strings=c("|",":")))
t(sort(table(words[nchar(words) > 3]), decreasing=TRUE)[1:3])
with current that
71 51 51

3.3 Working with R   R diagrams

3.3.1 Integrating ESS Auto Complete

first you need to add ESS to the spacemacs layers3.

  1. Using ESS

    once it's installed load any .R file (preferably in a new frame with C-x 5 C-f and it should just worktm and be in ESS[R] mode, if not activate that mode by using M-x r-mode.

    Next you will want to opon a REPL console underneath, which should be in iESS mode with the name R, do this by using M-x R, it will ask for a project location / directory, this is annoying and 90% of the time you're happy to have that as the working directory location of the original file, in order for that to happen put the following in your .emacs.d/init.el:

    ;R Binding for <-
    (setq-default dotspacemacs-configuration-layers '((ess :variables
                                                           ess-assign-key "\M--")))
    
    ;Set starting project directory to location of buffer =M-x pwd=
    ;https://ess.r-project.org/Manual/ess.html#Customizing-startup
    (setq ess-ask-for-ess-directory nil)
    

    if you want to open a seperate frame use SPC w F (remember a frame is an external X window and a window inisde by the Emacs language) and if you want to have the source code scroll over multiple panes use follow-mode by typing SPC w f

  2. Using ESS inside Org

    So one way is to just open an indirect buffer and/or change the mode, but that's a little painful because sometimes the point will be moved away and C-o / g; don't always work.

    another way is to switch to the buffer for that chunk using org-edit-special which is mapped to C-c ' / , ' , this works for other environments (read C-h f org-edit-special), when it's used in src code it will take copy code to a seperate buffer and when you finish by using M-Ret ' it will copy it back, so here I've used it to make a plot of MtCars:

    library(tidyverse)
    mtcars <- as_tibble(mtcars)
    ggplot(mtcars, aes(x = disp, y = mpg, col = hp, shape = as.factor(cyl))) +
      geom_point() +
      theme_classic() +
      labs(col = "HorsePower", shape = "Cylinders")
    

    test.png

    The best part is you can even split the window up to get an R iESS console underneath, follow mode on the right and the org-edit-src-code in one of the corners.

3.3.2 Plotting

You can produce plots as well, but what gets complicated is using the correct options in the header, they are reasonably self explanatory though, for example the following code: (You need to include output if you want to use ggplot2 etc., look at this answer and the docs )

#+BEGIN_SRC R :cache yes :exports both :results output graphics :file test.png
  library("ggplot2")
  ggplot(iris, aes(x = Sepal.Width, y = Sepal.Length, color = Species)) +
  geom_point() +
  theme_bw()
\#+END_SRC

will produce the following plot and list the code appropriately:

library("ggplot2")
ggplot(iris, aes(x = Sepal.Width, y = Sepal.Length, color = Species)) +
geom_point() +
theme_bw()

test.png

3.4 DONE Syntax Highlighting

By default the r-code doesn't have synatx highlighting. In order to get syntax highlighting in LaTeX export you need to either use the minted or listings package, to use the minted package specify the following in your ~/.emacs.d/init.el:

(require 'org-latex)
(setq org-export-latex-listings 'minted)
(add-to-list 'org-export-latex-packages-alist '("" "minted"))

3.4.1 Would it be worth using org-mode to manage code notes over boostnote?

Because boostnote is just open source *.md files, switching out is no drama, given how good org-mode is i'd probably be better off just abandoning Notable all togethr and using Boostnote for want of the features (and hey open source) and use org-mode for everything else.

  1. Using Org-Mode to replace Boostnote
    Pros cons
    + Closer to Terminal and Code + Less User Friendly
    + Easier to switch into because always open and bookmarks/recents + tags aren't as nice/usable
    + Way better text editing  
    + Can open fles externally  
    + Brings all notes together  

3.5 DONE How do I include ggplot inline?   R

  1. ESS or R-org

    A really good tutorial on using R in org-mode is org-mode Worg tutorials

3.6 TODO Java Example

Write an example of java code

4 DONE Including Tikz Plots   diagrams Buffers

4.0.1 DONE Using a tikz picture

I could only get this to work in HTML following the example from UCL there's reference to this orgmode.org/worg tutorial on LaTeX in org where the idea is:

  • If it's exported to HTML
    • then convert the tikz to zvg and insert the svg's
  • else if it's exported to LaTeX
    • just include the LaTeX
  • else just leave it raw
  • the t backend refers to the inline org-mode toggling
    • I just remember it as toggling because I can find no documentation on it.
    • it is always triggered so you must put it at the end or it won't work properly

but it only works in HTML so far. The +#_Header: = arguments are the same as putting them on the line =#+BEGIN_SRC, but that would be a really long line.

In order to use the if then statements as I have add the following to the ~/.emacs.d/init.el file:

(setq org-babel-latex-htlatex "htlatex")
(defmacro by-backend (&rest body)
  `(case (if (boundp 'backend) (org-export-backend-name backend) nil) ,@body))
  1. Making it work across formats

    So the trick is, execute this tikz like this with C-c C-c:

    #+LATEX_HEADER: \usepackage{tikz}
    #+HEADER: :headers '("\\usepackage{tikz}")
    #+HEADER: :fit yes :imoutoptions -geometry 400 :iminoptions -density 600
    #+header: :file (by-backend (html "./img/dosage.svg") ) :imagemagick yes
    #+header: :results (by-backend (pdf "latex")  (html "raw") (t "raw"))
    \#+BEGIN_SRC latex  :file (by-backend (t "./img/dosage.svg") ) :imagemagick yes 
    \begin{tikzpicture}[domain = 0:10, scale = (2/3)]
      \clip (-1,-1) rectangle (12,12);
      \draw[->, thick] (0,0) -- (0,10) node[right] {$C$ {\scriptsize nmol $\cdot  $ L$^{-1}$}};
      \draw[->, thick] (0,0) -- (10, 0) node[right] {$t$ };
      \draw[] [out=270, in = 180]  (0,5) to (3,2); 
      \draw[dashed] (3,2)--(3,5);
      \draw[] [out=270, in=180] (3,5) to (6,3) ;
      \draw[dashed] (6,3)--(6,6);
      \draw[] [out=270, in=180] (6,6) to (9,4) ;
      \draw[dashed] (9,4)--(9, 7);
      \draw[ ] [out=270, in=180] (9,7) to (12,4);
      \draw[dotted]  (0,7)--(12,7) node[below left] {$C_n = H$};
      \draw[dotted]  (0,4)--(12,4) node[below left] {$R_\infty = L$};
      \node [left] at (0,5) {$C_0$};
      \draw[<-> ] (0.4,4)--(0.4,7) node[below right] {\tiny $C_0 = H-L$};
    \end{tikzpicture}
    \#+END_SRC
    

    Then that should create, below it a section that looks like this:

    #+RESULTS:
    [[file:./img/dosage.svg]]
    

    This results section will inline preview but it won't get pulled in by an export process, so now that the inline preview is done we can take the line immediately preceeding the code fence and 'comment it out' delete it (comments, either #_ or = or whatever DO NOT WORK between header and source so do not use it. you should delete the line after latex that matches:

    :file (by-backend (t "./img/dosage.svg") ) :imagemagick yes
    

    And then we have tikz that compiles in LaTeX and an SVG that will 'just worktm' when exporting to HTML and that can be leveraged for other exports.

  2. Example Tikz Export   Tikz
    \begin{tikzpicture}[domain = 0:10, scale = (2/3)] \clip (-1,-1) rectangle (12,12); \draw[->, thick] (0,0) -- (0,10) node[right] {$C$ {\scriptsize nmol $\cdot $ L$^{-1}$}}; \draw[->, thick] (0,0) -- (10, 0) node[right] {$t$ }; \draw[] [out=270, in = 180] (0,5) to (3,2); % node[right] {\scriptsize \(\left( t_{\textit{min}}, c_{\textit{min}} \right)\)}; \draw[dashed] (3,2)--(3,5); \draw[] [out=270, in=180] (3,5) to (6,3) ; \draw[dashed] (6,3)--(6,6); \draw[] [out=270, in=180] (6,6) to (9,4) ; \draw[dashed] (9,4)--(9, 7); \draw[ ] [out=270, in=180] (9,7) to (12,4); \draw[dotted] (0,7)--(12,7) node[below left] {$C_n = H$}; \draw[dotted] (0,4)--(12,4) node[below left] {$R_\infty = L$}; \node [left] at (0,5) {$C_0$}; \draw[<-> ] (0.4,4)--(0.4,7) node[below right] {\tiny $C_0 = H-L$}; \end{tikzpicture}

    and it will create below something that says #+RESULTS: file:./img which should also inline display the image, now you can freely delete everything after latex in the header and it will work in all exports and you'll get to have the inline display, just copy it back if you want it again.

  3. Example 2
    \begin{tikzpicture} \draw[->] (-3,0) -- (-2,0) arc[radius=0.5cm,start angle=-180,end angle=0] (-1,0) -- (1,0) arc[radius=0.5cm,start angle=180,end angle=0] (2,0) -- (3,0); \filldraw (-1.5,0) circle[radius=1mm]; \filldraw (1.5,0) circle[radius=1mm]; \end{tikzpicture}
    1. Snippet   Snippets

      Using the tutorial here and the YaSnippets manual I turned this into a snippet in orgmode/plot. The snippet can be triggered by typing in plot and positinioning the cursor over and then running M-x yas-expand / :yas-expand / <SPC> <SPC> yas-expand.

      • If the minor mode is enabled with M-x yas-minor-mode then I think you could just press TAB / M-/ after plot and then jumping to the next field with M-s-/
    2. Exporting Guidelines

      If the svg files get deleted, they won't show up in exports, but they can be regenerated by moving the line back up and recompiling the tikz, the thing is, this code was intended to be fool-proof automatic, but it's not, and it might be more complicated that it needs to be, maybe just let sleeping dogs lie though.

5 DONE How do I use LaTeX) snippets   Snippets

  • Is there anything built into spacemacs?
    • there is yasnippets but it's going to be a bit of work to implement it
  • Is it close enough to what I've been using?
    • it's not but it sounds like the tex mode might be
  • should I just jump back to vim when necessary?
    • for now yes, but maybe long-term something could be implemented.
    • for live tex preview you can always open a new vim-buffer with an md extension and then use <leader>-lv to watch the TeX form as md while you write it and then paste that back into the .org file.

5.1 Example LaTeX

5.1.1 previewing latex

Write, let's take a math problem, in this case I'll use something from Mathematical Modelling:

In order to change the defaults of the image preview, use M-x customize RET org-format-latex-options:

  • set foreground to 'auto'
    • this is single '
  • set background to "transparent"
    • this is double "
  • in order to reset the images use rm ./ltximg/*
    • be careful, I deleted everything by putting * in the wrong place, don't do that.
\begin{align} \frac{1}{x^2} \times \left[2x \cdot \frac{\operatorname{d}y }{\operatorname{d} x} + x^2 \frac{\operatorname{d} }{\operatorname{d} x}\left( \frac{\operatorname{d}y }{\operatorname{d} x} \right) \ight] \end{align}

This answer fixed all previews (however it makes them ann png rather than svg which means they are a little blurry) put this in .emacs.d/init.el, and make sure you leave org-format-latex-options as default.

;; fix color handling in org-preview-latex-fragment
(let ((dvipng--plist (alist-get 'dvipng org-preview-latex-process-alist)))
  (plist-put dvipng--plist :use-xcolor t)
  (plist-put dvipng--plist :image-converter '("dvipng -D %D -T tight -o %O %f")))

I've left it disabled for the moment (you can just run it from within emacs) because i'd rather svg's to just start working again and I feel like it has something to do with themes and desktop session files).

5.1.2 Using the snippets

Take the equation and open it in org-edit-special mode with , ' :

\begin{align} \frac{1}{x^2} \times \left[2x \cdot \frac{\operatorname{d}y }{\operatorname{d} x} + x^2 \frac{\operatorname{d} }{\operatorname{d} x}\left( \frac{\operatorname{d}y }{\operatorname{d} x} \right) \ight] \\ x &= \frac{- b \pm \sqrt{b^2 - 4ac} }{2a} \end{align}

Doing that though, the LaTeX environment just wasn't that amazing really, I might just be better off staying with vim externally?

honestly, if you need fast vim with a preview, and/or tikz, this might be the simplest way:

  1. open a new destkop in i3/cinnamon
  2. open a terminal and create a new directory
  3. Either use vim to create a temp.tex and have the default template be pulled in (or use the older texnote command)
  4. edit in that window leveraging the almost live preview offered by vimtex
  5. use zf to fold and <Spc> y to copy relevant things to the clipboard.
  6. paste it back into emacs
    • if you get better with i3 you could probably have a really elegant way to do this on one desktop, may mod a a couple times and mod enter works pretty well tbh.

I don't see any much need to re invent the wheel with snippets when vim works well and I can't sync them between so I'm just going to leave it.

6 Set up a workflow

Images

  • How do I do screenshots
  • How do I do ipad drawings?
  • How do I do drawings from inkscape
  • How do I just do outright tikz?

6.1 DONE Install the /Prelude/Starter Kit.

6.2 DONE How do I deal with headlines?

use M-left/right to demote and promote them, use M-up/down to move them. To do items may be cycled by using =S-left/right.

6.2.1 Moving Headlines

6.2.2 Demoting and promoting headlines

6.3 DONE Can I Hide all the ToDo Tags from export?

Let's say that I use the todo tags to manage my notes and dates etc. Could I hide that from an export? It looks like no but I could filter the tree and just toggle the state with t, export it, and not save the buffer, a hacky work arround but sufficient for now, I could also just use regex

6.4 DONE Using Emacs for Notes

6.4.1 DONE Browsing all ToDO item   Todo

If you've added a file to the agenda-variable with C-c [ all todo items in the agenda can be searched using <Spc> m a t

6.4.2 DONE Navigating a file

How do I jump to the top of a headline so that I can use TAB to fold it ? You can use C-c C-f=/=C-c C-n / gj / gl will go forward headlines and C-c C-b / gk / g; / C-c C-p will go back headlines. I have remapped these to z k and z j respectively

  1. Folding

    How do I fold and unfold the entire document?

  2. Marking Location

    Can I still use m CHAR to mark a location and jump back to it?

  3. Frames and windows

    often you will want to use <SPC> m b | , b to open an indirect buffer for items beneath a headline, it will then open a second window below that is out of focus C-w C-w / C-x o / <SPC> w w / M-m w w can be used to pull that window into focus (or any window with SPC <NUM> and then that window can be maximized with C-x 1 / <SPC> w m

  4. Finding Shortcuts   Buffers

    If you're using spacemacs and you know a single shortcut it isn't usually difficult to find more shortcuts:

    1. Switch to fullscreen
    2. Move to a headline and press , b
    3. Slowly enter the key-sequence C-x
    4. Observe that the option o corresponds to the function maximize-buffer
    5. Press C-g to clear out of the minibuffer
    6. Press <SPC> <SPC> / M-x and type in maximize-bu
    7. At or around the top should be the text spacemacs/toggle maximize-buffer (M-m w m)
    8. Usually spacemacs will map SPC to M-m and in this case the corresponding shortcut is indeed <SPC> w m, if however it wasn't there's Google because you have the corresponding command.

    It's also possible to switch buffers with <SPC> b n.

    Listing buffers is weird, if you use C-x b / :ls you can just start typing in the file name, but if you get up the list of buffers with C-x C-b it won't take focus which is really annoying.

    press <SPC> <SPC> / M-x

6.4.3 DONE Attaching files   Attachments

Attachments are really cool, they can be copied or symlinked using <SPC> m i a, that's even cause to give up on dropbox, the file can also just be linked to.

If you want to just link the file, open the org in vim and then use fzf.

fzf can be enabled in spacemacs using the AshyIsMe/fzf-spacemacs-layer

6.4.4 DONE Reading an Emacs File

  • How do I fold a section rather than the whole thing?
  • To fold the whole thing I can use S+TAB+ which is analogous to zr and zm in vim but it cycles through

6.4.5 DONE Use Vim Can I create a keybinding to open the file or buffer in Vim?   vim

6.4.6 DONE How to mark lines just like in vim?

Using the bookmarks shortcuts are amazing, refer to them in Spacemacs Documentation, basically hit <SPC> f b and you can create and jump to bookmarks across and within files.

  • Bookmarks can be deleted with ,4
    • C-d
  • Opened in another frame (i.e. an entirely new X Window)
    • C-c C-o
  • Opened in anotgher window (i.e. internal to Emacs
    • C-c o

6.5 DONE Opening Current File in vim

  • Is there a way to bring my bindings into space macs?
    • Probably, but it's a lot of work when you can just use both programs with no loss.

The binding (C-c o in Prelude and Spc f 0 in Spacemacs will open the current file in an external editor (I'm not sure if the file or the buffer tbh) just make sure the system has default editor as gvim and that gvim is set to read the correct vimrc and your set, just remember to call PlugUpdate. pure vim stopped working for me recently, I think it's getting traped by the emacs terminal

I've found two solutions for opening the current buffer in vim, on on the Emacs Wiki which causes Emacs to crash and another one on Stack Exchange that works flawlessly and remembers the line number:

(defun my-open-current-file-in-vim ()
  (interactive)
  (async-shell-command
   (format "gvim +%d %s"
       (+ (if (bolp) 1 0) (count-lines 1 (point)))
       (shell-quote-argument buffer-file-name))))

Maybe later having something for notepad/vim etc. would be nice but it's pretty simple to just open stuff from vim win :gedit "%" and remapping that with autocmd BufEnter *.org :map <f12> :w<cr>:!gedit "%" <Enter>.

Actually it might have been C-u C-c o

Also to open a new line (i.e. o in vim) use S-Enter

6.5.1 DONE Navigating Files

  1. DONE Moving to a previous location

    If you are following an internal link (i.e. a link to a target in the org-mode file), then org-mode automatically pushes the position in the mark-ring before jumping.

    So, you follow a link with C-c C-o, then you can jump back with C-c &.5

  2. Recently closed

    Use the key sequence SPC f r for *F*ind *R*ecent file.

6.5.2 WAITING Exporting   Style

  1. WAITING In Line References

    In order to reference code blocks using org-ref you need to install the org-ref package by following the instructions on their GitHub, you need to add a line to your .emacs.d/.init.el but then you should be able to do M-x package-list-packages and find org-ref in order to install it.

    According to this post you need to set org-latex-prefer-user-labels to non-nil in order to use the custom ID given in #+NAME. Refer to the help with C-h v org-latex-prefer-user-labels and the setting can be toggled from there, the reason for the default is if you multiply define a label or use wrong syntax the latex won't generate.

    I can't find a simple way to easily reference figures and source code cross-reference wise or academic wise, this could take a very long time.

    1. Dedicated targets

      maybe an easier way to figure this out is by using a Dedicated target (go to top), and you can reference sections by using [[Section Name]]

    2. WAITING I haven't figured out how to fix labels with HTML though

      I tried looking for org-HTML-prefer-user-labels but no luck, there might be something in the Manual.

  2. DONE Markdown

    I need to figure how to export as markdown without breaking the dam thing

  3. DONE Export as eMail with Math

    The easiest way is to take the exported html and download it using an add on (SingleFile Export) and then copy that html, which is now mathml, into thunderbird, trying to convert mathjax to mathml without losing the inline css is like trying to pull out teeth.

    Telling Org to use math-ml doesn't work, Using SVG's don't get embedded inline, and, I don't really want to use pandoc when I don't have to given that the inline is so nice, if I did however I could probably do something like this:

    pandoc -s --self-contained input.org --toc  -c ~/.emacs.d/org-css/Killercup.css -o out.html
    
    1. Test Email

      So the quadratic formula is given by:

      \begin{align} x&= \frac{- b \pm \sqrt{b^2- 4ac} }{2a} \end{align}

      the geometric series is given by

      \begin{align} S_n &= \sum^{n - 1}_{i = 0 } \left[ a\cdot r^n \right] \\ &= \frac{1- r^n}{1- r} \\ \implies \sum^{\infty}_{n= 0} &= \frac{1- \lim_{n \rightarrow \infty}\left[ r^n \right]}{1- r} \end{align}
  4. WAITING Styles
    1. DONE HTML Styles

      I found this nice Trick on Reddit (insert a link with C-c C-l)6, in order to have inline CSS upon export (rather than two files) put CSS files in ~/.emacs.d/org-css/ and run =toggle-org-custom-inline-style in an org buffer associated with a file, it should now prompt you for a theme on the next HTML export if you use this code shown in ref:some-source-code 7

    2. IN-PROGRESS LaTeX Styles upon Export.

      I can, I believe, set up a custom package for a template (of course that means that I'll have to fix the style that I've been using from Computer algebra) by specifying a header of the form #+LATEX_HEADER: \usepackage{mystyle.sty}.

      I need to fix my LaTeX file so it will play ball externally

      When exporting to latex you need to be careful with loading in svg's, you will need to load a corresponding package

      In order to enable the listings package in a pdf export use the following in your ~/.emacs.d/init.el:

      (require 'ox-latex)
      
      (setq org-latex-listings t)
      (add-to-list 'org-latex-packages-alist '("" "listings"))
      (add-to-list 'org-latex-packages-alist '("" "color"))
      

      It's also important never to include footnotes or hyperlinks in headings, even math should be avoided because LaTeX will throw non-descriptive errors, also I believe you need to be careful using the word LaTeX and this should perhaps be enclosed in code tags or deilberately lowercased.

      the command \LaTeX should never be wrapped in $$ or \( \) because otherwise LaTeX will crash and because it automatically changes upon export..

      Never include multi-line math in tables, that's another thing latex really doesn't like

      Try to avoid unicode because while it can maybe work with XeLaTeX, it doesn't work with listings and is simply not worth the headache.

    3. JavaScript

      A tonne of options for exporting with extended javascript are also at my disposal, look at the Manual, most importantly is view:content and view:info, so for example:

      view:info toc:nil
      #+INFOJS_OPT: view:info toc:nil
      

      Once your in the html, use i to toggle the Table of Contents.

      ;; Put your css files there
      (defvar org-theme-css-dir "~/.emacs.d/org-css/")
      
      (defun toggle-org-custom-inline-style ()
        (interactive)
        (let ((hook 'org-export-before-parsing-hook)
              (fun 'set-org-html-style))
          (if (memq fun (eval hook))
              (progn
                (remove-hook hook fun 'buffer-local)
                (message "Removed %s from %s" (symbol-name fun) (symbol-name hook)))
            (add-hook hook fun nil 'buffer-local)
            (message "Added %s to %s" (symbol-name fun) (symbol-name hook)))))
      
      (defun org-theme ()
        (interactive)
        (let* ((cssdir org-theme-css-dir)
               (css-choices (directory-files cssdir nil ".css$"))
               (css (completing-read "theme: " css-choices nil t)))
          (concat cssdir css)))
      
      (defun set-org-html-style (&optional backend)
        (interactive)
        (when (or (null backend) (eq backend 'html))
       (let ((f (or (and (boundp 'org-theme-css) org-theme-css) (org-theme))))
            (if (file-exists-p f)
                (progn
                  (set (make-local-variable 'org-theme-css) f)
                  (set (make-local-variable 'org-html-head)
                       (with-temp-buffer
                         (insert "<style type=\"text/css\">\n<!--/*--><![CDATA[/*><!--*/\n")
                         (insert-file-contents f)
                         (goto-char (point-max))
                         (insert "\n/*]]>*/-->\n</style>\n")
                         (buffer-string)))
                  (set (make-local-variable 'org-html-head-include-default-style)
                       nil)
                  (message "Set custom style from %s" f))
              (message "Custom header file %s doesnt exist")))))
      
      
      • How to specify a template for LaTeX

      So turn my typical LaTeX template into a \usepackage{}

    4. DONE Create CSS files

      Take the CSS files and merge them with something bare bones to colour the ToDO tags

    5. Shortcuts

      Exporting can be performed by using the shortcut <SPC> m e e=/=C-c C-e.

    6. DONE use spacemacs   Workflow

      when using spacemacs the config file remains as ~/.emacs.d/init.el, the default config for all spacemacs settings however becomes the ~/.spacemacs file, which, by default, has all the default settings in it; it is important to note that spacemacs settings will only be respected in that template and in that very specific style of wrapping, so just open the file and edit the settings of the elisp in place. it's well worth Reading the Documentation because it also mentions things like support for GitHub Flavoured Markdown

    7. Changing Themes

      You can install a bunch of themes by installing the themes-megapack as documented on the GitHub repo, but the only way to change a theme that I've found is to use <M-x spacemacs/helm-themes>.

      You'll need to change the default theme at loading however, because, the \(LaTeX\) will come out wrong otherwise, like black on a white background etc.

      If however you go to the .spacemacs file and locate the string List of themes there will be a list of default themes, these can be cycled through using <SPC> T n.

    8. DONE Toggle status of ToDo

      So this will still work with <s-Right> but preferably do it with just t

      1. dealing with fonts

        you will likely need to fix the font, there is a bug Described here on Github that requires the font size listed at approximately line 135 as:

        dotspacemacs-default-font '("Source Code Pro"
                                       :size 13
                                       :weight normal
                                       :width normal
                                       :powerline-scale 1.1)
        

        to 13.0 otherwise it doesn't set the font to point like it should and the value is entirely ignored, making debugging hard.

      2. Enabling layers

        You will need to uncomment lines in order to enable modes like org and markdown

    9. TODO ReWrite Documents in Org-Mode   Workflow
      1. TODO All Stats
      2. Convert and import all R-Work
      3. TODO All NMR
      4. DONE All Abstract Algebra
      5. TODO All Continuous Mathematical Modelling
      6. WAITING All R DataSci Work

        This is important, I don't think it's going to work until after I've set up ESS, because the source code doesn't seem to want to install packages or remember things (or maybe I needed to set up :cache yes?? no I idea, didn't have time.

    10. TODO Set up an ESS workflow   Workflow R
      1. TODO Install ESS
      2. Compare ESS to RMD
        1. Is there a way I could integrate org mode with my current workflow?

          Well I like how my notes are all RMD files inside R Studio, I like how I can search them all with C-s-f, but clearly, moving toward using org-mode for that would be better.

          For the time being I can just use pandoc to take the .rmd into .org, or, if that doesn't work, I can use RStudio to take the .rmd –> .md and then use pandoc to go to .org

        2. Convert RMD notes into org.

7 Tips and Tricks with Org Mode

7.1 Folding

Open a second window with C-x 2 and swap between the windows with C-x o (for *O*ther), the other window can be scrolled by using C-M v, this is handy for having a second reference window.

The second window can be closed by using C-x 1 (as in keep 1 window i'm already in )

7.2 Working with ToDo/HeadLine/list items

You can add a new TODO item with M-S RET. Using M-up/down a headlines may be moved, they may be demoted with M-left/right Using S-left/right will toggle to do list items.

7.2.1 Folding

You can fold a headline by using TAB if you are on a headline, the fold level of the entire document may be toggled with S-TAB

7.2.2 Trees

Refer to 8

Key Binding Description Description
SPC m S l org-demote-subtree Move Right
= SPC m S h = org-promote-subtree Move Left
= SPC m S k = org-move-subtree-up Move UP
= SPC m S j = org-move-subtree-down Move Down

7.3 Note Taking Guidlines   Workflow

7.3.1 Links

You can create a link by using C-c C-l and I think C-u C-c C-l will attach an internal link

7.4 Exporting Org to Markdown

You should customize org-export-backends and enable the markdown backend. That's: M-x customize-option and then org-export-backends and then arrow down to the checkbox to the left of 'md' and press enter to enable it (or just click on it, if running emacs grqAphically). Then arrow back up and over to 'Apply and Save' (or click on it)

7.5 Including LaTeX Fragments   LaTeX

To preview LaTeX documents install dvipng, dvisvgm or conver.

In order to customise the preview customise the variables org-format-latex-options and org-format-latex-header.

(in order to enable the inline preview use the following press <s TAB> to insert a code block.) As hown in \eqref{Quad}

C-c C-x C-l (org-toggle-latex-fragment)

7.5.1 Example LaTeX

\begin{align} \sum^{n- 1}_{n= 0} \left[ ar^n \right] &= a \cdot \frac{1-r^n}{1-r} \\ \implies \sum^{\infty}_{n=0}\left[ ar^n \right] &= a\cdot \frac{1- \lim_{n \rightarrow \infty}\left[ r^n\right]}{1-r}\notag \\ \left| r \right| < 1 \iff \sum^{\infty}_{n = 0} \left[ ar^n \right] &= \frac{1}{1- r} \end{align}

7.6 DONE Tables   Tables

Let's make a table of key bindings, first we need to insert a table, we'll do this wit a tamplate by typing in SPC-m-t-n for *M*ajor mode command, *T*able, *N*ew.

Description for Tables Key Binding Notes
Move to next field SPC m t l .
Move along Table Cells (only for =table.el) TAB and s-TAB There are other bindings
Convert table between org-mode=/=table.el SPC m t c This only works well if you tab between cells/fields
Export to a file SPC m t E  
Plot using GnuPlot SPC m t p sudo apt install gnuplot
Toggle Numbers SPC m t t o think *T*oggle *O*rg Coordinates
Move Table Rows SPC m t H/J/K/L Just use capital directions
Including LaTeX should work \(\oint z \operatorname{d}x = {\scriptsize 1} {\big /}_{2} \cdot z^2 + C\)  
  • Why can't I export this as a table?
    • You have to be super careful with the formatting, the table MUST have bar lines on the sides, it doesn't need top and bottom \hrule indicators though.
    • The conversion sometimes fucks up and this is where the problem comes in, make sure to use TABS to fill in data and when things go wrong just use Block mode to put | on the sides of the converted org-mode table, for some reason the conversion puts + there.
  • Can my tables include \(LaTeX\)
    • yeah if it stops working just delete the LaTeX and start again, it's reall finnicky
  • Why does the org-mode table not include the mark up upon export?
  • Why does the org-mode table not respect the HTML CSS upon export when the table.el clearly does?

7.6.1 Multi-Column Cells

If you want to merge cells etc. that's also doable, but it's real finnicky 9 and it doesn't work in BeOrg.

 Region 
        
        
        
        
                      Sales                      
      Q1          Q2          Q3          Q4     
 foo     bar   foo   bar   foo   bar   foo   bar 
 North    350      46   253    34   234    42   382    68 
 South    462      84   511    78   435    45   534    89 

7.7 Drawers   Drawers

Insert a drawer with SPC m a / , D.

  • Basically this will appear as ordinary text but with the capacity to fold away in emacs
    • So when you perform Visibility Cycling The drawer will not unfold unless you pull it out with TAB

\(\int 4x^3 dx\)

7.8 DONE How to include links to files

7.8.1 DONE Internal links

  1. Anchors

    Anchors can be created by using <<TargetLandingText>> and then accessed by using [[TargetLandingText][Display Text]].

7.8.2 DONE External Files

External files can be linked to by using the syntax [[./myfile.ext]] and they can be jumped to with Enter, which would be gf / gx in Vim.

8 DONE Can I tag a specific lines

OK so i have all these notes in here now, like for example multi-column tables, can I tag the specific line or subtree so that I can just jump straight to it??

This would be good for things like analysis where I might need a tag that says, say for example, analysis/real/sequence.

To toggle inline images use C-c C-x C-v and to insert them just insert them as a link using C-c C-l.

Dragging and Dropping does not work.

Footnotes:

1

I got this from the O'Toole Tutorial

5

Refer to the documentation here.

6

The shortcut for footnotes is C-c C-x f as described in the manual and the shortcut for links is C-c C-l

7

having emacs-lisp after means it will be (atleast-partially) evaluated upon HTML export, you will need to install emacs-htmlize in order to export it, this can be done by typing in the following M-x package-install RET htmlize; confusing that it isn't emacs-htmlize, maybe that's a standard?

8

Most of this is taken from the ReadTheDocs Spacemacs link

9

Refer to the Mailing List for org-mode

Author: ryan

Created: 2019-11-12 Tue 22:24

Validate